Browse Source

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

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

1
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);

20
src/znordic.c

@ -4,6 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "ble_dfu.h"
#include "boards.h"
#include "nrf_delay.h"
#include "nrf_drv_clock.h"
@ -13,13 +14,13 @@
#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;
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;
@ -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()) {

Loading…
Cancel
Save