Add watchdog
This commit is contained in:
parent
18264a638c
commit
d512b49a6a
|
@ -12,3 +12,7 @@ menuconfig BSP_USING_SPI
|
||||||
if BSP_USING_SPI
|
if BSP_USING_SPI
|
||||||
source "$BSP_DIR/third_party_driver/spi/Kconfig"
|
source "$BSP_DIR/third_party_driver/spi/Kconfig"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
menuconfig BSP_USING_WDT
|
||||||
|
bool "Using watchdog timer device"
|
||||||
|
default y
|
||||||
|
|
|
@ -10,4 +10,8 @@ ifeq ($(CONFIG_BSP_USING_SPI),y)
|
||||||
SRC_DIR += spi
|
SRC_DIR += spi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_BSP_USING_WDT),y)
|
||||||
|
SRC_DIR += wdt
|
||||||
|
endif
|
||||||
|
|
||||||
include $(KERNEL_ROOT)/compiler.mk
|
include $(KERNEL_ROOT)/compiler.mk
|
||||||
|
|
|
@ -461,4 +461,4 @@ int SpiFlashTest(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
test_spi, SpiFlashTest, test spi);
|
SpiFlashTest, SpiFlashTest, test spi);
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
SRC_FILES := connect_wdt.c
|
||||||
|
|
||||||
|
include $(KERNEL_ROOT)/compiler.mk
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2020 AIIT XUOS Lab
|
||||||
|
* XiUOS is licensed under Mulan PSL v2.
|
||||||
|
* You can use this software according to the terms and conditions of the Mulan
|
||||||
|
* PSL v2. You may obtain a copy of Mulan PSL v2 at:
|
||||||
|
* http://license.coscl.org.cn/MulanPSL2
|
||||||
|
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
|
||||||
|
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
|
||||||
|
* NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* Mulan PSL v2 for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file connect_usart.c
|
||||||
|
* @brief support ch569 uart function and register to bus framework
|
||||||
|
* @version 1.0
|
||||||
|
* @author AIIT XUOS Lab
|
||||||
|
* @date 2025-04-07
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "CH56x_common.h"
|
||||||
|
#include "xizi.h"
|
||||||
|
#include "board.h"
|
||||||
|
#include "shell.h"
|
||||||
|
|
||||||
|
#define WDOG_MSECOND_MAX ( (0xff << 19) / (FREQ_SYS / 1000) ) // watchdog timer is clocked at Fsys/524288, arround 3~228Hz
|
||||||
|
int g_feed_wdt_stop = 0;
|
||||||
|
|
||||||
|
int InitHwWdt(void)
|
||||||
|
{
|
||||||
|
KPrintf("InitHwWdt WDOG_MSECOND_MAX is %d ms\n", WDOG_MSECOND_MAX);
|
||||||
|
|
||||||
|
WWDG_SetCounter(0);
|
||||||
|
WWDG_ClearFlag();
|
||||||
|
WWDG_ResetCfg(ENABLE);
|
||||||
|
while(1) {
|
||||||
|
WWDG_SetCounter(0);
|
||||||
|
//mDelaymS(100);
|
||||||
|
if (g_feed_wdt_stop == 1) {
|
||||||
|
KPrintf("%s watchdog feed stop!\n", __func__);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description: Watchdog function
|
||||||
|
* @return success: EOK, failure: other
|
||||||
|
*/
|
||||||
|
int StartWatchdog(void)
|
||||||
|
{
|
||||||
|
int ret = EOK;
|
||||||
|
|
||||||
|
int32 WdtTask = KTaskCreate("WdtTask", (void *)InitHwWdt, NONE, 1024, 19);
|
||||||
|
StartupKTask(WdtTask);
|
||||||
|
|
||||||
|
return EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
int WdtTest(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
KPrintf("WdtTest Start\n");
|
||||||
|
g_feed_wdt_stop = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0) | SHELL_CMD_TYPE(SHELL_TYPE_CMD_MAIN),
|
||||||
|
WdtTest, WdtTest, test wdt);
|
Loading…
Reference in New Issue