Browse Source

添加无看门狗版本的初始化函数

master
zhaohe 1 year ago
parent
commit
e75326b00a
  1. 1
      include/znordic.h
  2. 22
      src/znordic.c

1
include/znordic.h

@ -48,6 +48,7 @@ void wd_init();
void wd_feed(); void wd_feed();
void znordic_init(); void znordic_init();
void znordic_init_without_wd();
void znordic_loop(); void znordic_loop();
void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull); void znrf_gpio_cfg_output(uint32_t pin_number, nrf_gpio_pin_pull_t pull);

22
src/znordic.c

@ -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,14 +14,14 @@
#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;
void wd_init() {
static bool m_wd_is_enable = false;
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;
config.reload_value = WDT_CONFIG_RELOAD_VALUE; config.reload_value = WDT_CONFIG_RELOAD_VALUE;
@ -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()) {

Loading…
Cancel
Save