diff --git a/include/znordic.h b/include/znordic.h index ebeb534..6da394b 100644 --- a/include/znordic.h +++ b/include/znordic.h @@ -44,6 +44,9 @@ *******************************************************************************/ typedef struct tm ztm_t; +void wd_init(); +void wd_feed(); + void znordic_init(); void znordic_loop(); diff --git a/src/znordic.c b/src/znordic.c index 80aa6e6..0fe4f5a 100644 --- a/src/znordic.c +++ b/src/znordic.c @@ -13,6 +13,23 @@ #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "nrfx_rtc.h" +/********************************************************************* + * INCLUDES + */ +#include "nrf_drv_wdt.h" +nrf_drv_wdt_channel_id m_channel_id; + +void wd_init() { + // WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms + nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; + config.reload_value = WDT_CONFIG_RELOAD_VALUE; + ret_code_t err_code = nrf_drv_wdt_init(&config, NULL); + ZERROR_CHECK(err_code); + err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); + ZERROR_CHECK(err_code); + nrf_drv_wdt_enable(); +} +void wd_feed() { nrfx_wdt_feed(); } /******************************************************************************* * RTC * @@ -24,7 +41,7 @@ static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) * CODE * *******************************************************************************/ void znordic_init() { - { + { /******************************************************************************* * 日志系统初始?? * *******************************************************************************/