52 lines
1.2 KiB
C
52 lines
1.2 KiB
C
#include "McuBspWatchdog.h"
|
|
|
|
static void McuBspWatchdogIntHandler(void);
|
|
static void McuBspWatchdogFreedDog(void);
|
|
|
|
static uint8_t gMcuBspWatchdogTick = 0;
|
|
static uint8_t gMcuBspWatchdogFlag = 0;
|
|
|
|
void McuBspWatchdogInit(void)
|
|
{
|
|
SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
|
|
IntEnable(INT_WATCHDOG);
|
|
WatchdogUnlock(WATCHDOG0_BASE);
|
|
WatchdogReloadSet(WATCHDOG0_BASE, SysFreqGet());
|
|
WatchdogResetEnable(WATCHDOG0_BASE);
|
|
WatchdogLock(WATCHDOG0_BASE);
|
|
BSP_IntVectSet((CPU_INT08U)BSP_INT_ID_WDTO_WDT1, (CPU_FNCT_VOID)McuBspWatchdogIntHandler);
|
|
BSP_IntEn(BSP_INT_ID_WDTO_WDT1);
|
|
WatchdogEnable(WATCHDOG0_BASE);
|
|
}
|
|
|
|
void McuBspWatchdogFreedWatchdog(void)
|
|
{
|
|
gMcuBspWatchdogTick = 0;
|
|
}
|
|
|
|
void McuBspWatchdogStopFreedWatchdog(void)
|
|
{
|
|
gMcuBspWatchdogFlag = 1;
|
|
}
|
|
|
|
static void McuBspWatchdogFreedDog(void)
|
|
{
|
|
WatchdogUnlock(WATCHDOG0_BASE);
|
|
WatchdogReloadSet(WATCHDOG0_BASE, SysFreqGet());
|
|
WatchdogLock(WATCHDOG0_BASE);
|
|
}
|
|
|
|
static void McuBspWatchdogIntHandler(void)
|
|
{
|
|
OSIntEnter();
|
|
gMcuBspWatchdogTick++;
|
|
if (gMcuBspWatchdogTick > 30) {
|
|
gMcuBspWatchdogFlag = 1;
|
|
}
|
|
if (gMcuBspWatchdogFlag == 0) {
|
|
WatchdogIntClear(WATCHDOG0_BASE);
|
|
McuBspWatchdogFreedDog();
|
|
}
|
|
OSIntExit();
|
|
}
|