20231023_InSituLab_emb/InsituLabProject_QRS/Src/Usr/Bsp/McuBspWatchdog.c
Rjh913828050 4e26d518da 类型:更细
内容:更新十四五程序
人员:任家豪
2024-07-31 08:56:07 +08:00

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();
}