20230201_1811_emb/1811Project_LPc/Src/Usr/Bsp/McuBspWatchdog.c
Rjh913828050 fddc46ab1b 类型:更新
内容:1811项目下位机软件第一版完整程序
人员:任家豪
2024-07-31 08:45:23 +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();
}