diff --git a/include/znordic.h b/include/znordic.h index f1b605b..e3f5781 100644 --- a/include/znordic.h +++ b/include/znordic.h @@ -48,6 +48,7 @@ void wd_init(); void wd_feed(); void znordic_init(); +void znordic_init_without_wd(); void znordic_loop(); void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull); diff --git a/src/znordic.c b/src/znordic.c index e7339d3..8445f4b 100644 --- a/src/znordic.c +++ b/src/znordic.c @@ -4,6 +4,7 @@ #include #include +#include "ble_dfu.h" #include "boards.h" #include "nrf_delay.h" #include "nrf_drv_clock.h" @@ -13,14 +14,14 @@ #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "nrfx_rtc.h" -#include "ble_dfu.h" /********************************************************************* * INCLUDES */ #include "nrf_drv_wdt.h" nrf_drv_wdt_channel_id m_channel_id; -void wd_init() { +static bool m_wd_is_enable = false; +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; @@ -29,8 +30,11 @@ void wd_init() { err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); ZERROR_CHECK(err_code); nrf_drv_wdt_enable(); + m_wd_is_enable = true; +} +void wd_feed() { + if (m_wd_is_enable) nrfx_wdt_feed(); } -void wd_feed() { nrfx_wdt_feed(); } /******************************************************************************* * RTC * @@ -41,8 +45,7 @@ static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) /******************************************************************************* * CODE * *******************************************************************************/ -void znordic_init() { - wd_init(); +void znordic_init_without_wd() { { /******************************************************************************* * 日志系统初始?? * @@ -103,6 +106,11 @@ void znordic_init() { } } +void znordic_init() { + wd_init(); + znordic_init_without_wd(); +} + void znordic_loop() { while (true) { app_sched_execute(); @@ -158,9 +166,7 @@ uint32_t znordic_haspassed_ms(uint32_t last) { } } -bool znordic_rtc_has_setted(){ - return g_power_on_rtc != DEFAULT_TIME; -} +bool znordic_rtc_has_setted() { return g_power_on_rtc != DEFAULT_TIME; } void znordic_rtc_settime_s(uint32_t timestampNow) { if (timestampNow < znordic_getpower_on_s()) {