add PIC watchdog

This commit is contained in:
2023-09-05 11:06:23 +02:00
parent 32f1bd73b4
commit e0b94c5250
6 changed files with 169 additions and 41 deletions

View File

@@ -53,6 +53,7 @@ void SYSTEM_Initialize(void)
PMD_Initialize();
PIN_MANAGER_Initialize();
OSCILLATOR_Initialize();
WWDT_Initialize();
TMR0_Initialize();
ECAN_Initialize();
}
@@ -92,6 +93,50 @@ void PMD_Initialize(void)
}
void WWDT_Initialize(void)
{
// Initializes the WWDT to the default states configured in the MCC GUI
WDTCON0 = WDTCPS;
WDTCON1 = WDTCWS|WDTCCS;
}
void WWDT_SoftEnable(void)
{
// WWDT software enable.
WDTCON0bits.SEN=1;
}
void WWDT_SoftDisable(void)
{
// WWDT software disable.
WDTCON0bits.SEN=0;
}
bool WWDT_TimeOutStatusGet(void)
{
// Return the status of WWDT time out reset.
return (PCON0bits.nRWDT);
}
bool WWDT_WindowViolationStatusGet(void)
{
// Return the status of WWDT window violation reset.
return (PCON0bits.nWDTWV);
}
void WWDT_TimerClear(void)
{
// Disable the interrupt,read back the WDTCON0 reg for arming,
// clearing the WWDT and enable the interrupt.
uint8_t readBack=0;
bool state = GIE;
GIE = 0;
readBack = WDTCON0;
CLRWDT();
GIE = state;
}
/**
End of File
*/