|
@ -4,6 +4,7 @@ |
|
|
#include <stdbool.h> |
|
|
#include <stdbool.h> |
|
|
#include <stdint.h> |
|
|
#include <stdint.h> |
|
|
|
|
|
|
|
|
|
|
|
#include "ble_dfu.h" |
|
|
#include "boards.h" |
|
|
#include "boards.h" |
|
|
#include "nrf_delay.h" |
|
|
#include "nrf_delay.h" |
|
|
#include "nrf_drv_clock.h" |
|
|
#include "nrf_drv_clock.h" |
|
@ -13,13 +14,13 @@ |
|
|
#include "nrf_log_ctrl.h" |
|
|
#include "nrf_log_ctrl.h" |
|
|
#include "nrf_log_default_backends.h" |
|
|
#include "nrf_log_default_backends.h" |
|
|
#include "nrfx_rtc.h" |
|
|
#include "nrfx_rtc.h" |
|
|
#include "ble_dfu.h" |
|
|
|
|
|
/********************************************************************* |
|
|
/********************************************************************* |
|
|
* INCLUDES |
|
|
* INCLUDES |
|
|
*/ |
|
|
*/ |
|
|
#include "nrf_drv_wdt.h" |
|
|
#include "nrf_drv_wdt.h" |
|
|
nrf_drv_wdt_channel_id m_channel_id; |
|
|
nrf_drv_wdt_channel_id m_channel_id; |
|
|
|
|
|
|
|
|
|
|
|
static bool m_wd_is_enable = false; |
|
|
void wd_init() { |
|
|
void wd_init() { |
|
|
// WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms |
|
|
// WDT_CONFIG_RELOAD_VALUE 修改这个数值修改喂狗周期,单位ms |
|
|
nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; |
|
|
nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG; |
|
@ -29,8 +30,11 @@ void wd_init() { |
|
|
err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); |
|
|
err_code = nrf_drv_wdt_channel_alloc(&m_channel_id); |
|
|
ZERROR_CHECK(err_code); |
|
|
ZERROR_CHECK(err_code); |
|
|
nrf_drv_wdt_enable(); |
|
|
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 * |
|
|
* RTC * |
|
@ -41,8 +45,7 @@ static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) |
|
|
/******************************************************************************* |
|
|
/******************************************************************************* |
|
|
* CODE * |
|
|
* 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() { |
|
|
void znordic_loop() { |
|
|
while (true) { |
|
|
while (true) { |
|
|
app_sched_execute(); |
|
|
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) { |
|
|
void znordic_rtc_settime_s(uint32_t timestampNow) { |
|
|
if (timestampNow < znordic_getpower_on_s()) { |
|
|
if (timestampNow < znordic_getpower_on_s()) { |
|
|