|
@ -14,8 +14,6 @@ |
|
|
#include "nrf_log_default_backends.h" |
|
|
#include "nrf_log_default_backends.h" |
|
|
#include "nrfx_rtc.h" |
|
|
#include "nrfx_rtc.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
/******************************************************************************* |
|
|
* RTC * |
|
|
* RTC * |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
@ -89,9 +87,7 @@ void znordic_loop() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
void znordic_force_flush_log() { |
|
|
|
|
|
NRF_LOG_FLUSH(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void znordic_force_flush_log() { NRF_LOG_FLUSH(); } |
|
|
|
|
|
|
|
|
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) { // |
|
|
nrf_gpio_cfg(pin_number, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, pull, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE); |
|
|
nrf_gpio_cfg(pin_number, NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT, pull, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE); |
|
@ -113,7 +109,29 @@ int16_t znrf_adc_channel_read_val(uint16_t channel) { |
|
|
*******************************************************************************/ |
|
|
*******************************************************************************/ |
|
|
volatile uint32_t g_timestamp = 0; |
|
|
volatile uint32_t g_timestamp = 0; |
|
|
volatile uint32_t g_power_on_rtc = 0; |
|
|
volatile uint32_t g_power_on_rtc = 0; |
|
|
uint32_t znordic_getpower_on_s() { return g_timestamp; } |
|
|
|
|
|
|
|
|
static uint8_t s_timeCount1second = 0; |
|
|
|
|
|
|
|
|
|
|
|
uint32_t znordic_getpower_on_s() { |
|
|
|
|
|
__disable_irq(); |
|
|
|
|
|
uint32_t reg = g_timestamp; |
|
|
|
|
|
__enable_irq(); |
|
|
|
|
|
return reg; |
|
|
|
|
|
} |
|
|
|
|
|
uint32_t znordic_getpower_on_ms() { |
|
|
|
|
|
__disable_irq(); |
|
|
|
|
|
uint32_t ret = g_timestamp * 1000 + s_timeCount1second * 125; |
|
|
|
|
|
__enable_irq(); |
|
|
|
|
|
return ret; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
uint32_t znordic_haspassed_ms(uint32_t last) { |
|
|
|
|
|
uint32_t now = znordic_getpower_on_ms(); |
|
|
|
|
|
if (now < last) { |
|
|
|
|
|
return 0xFFFFFFFF - last + now; |
|
|
|
|
|
} else { |
|
|
|
|
|
return now - last; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void znordic_rtc_settime_s(uint32_t timestampNow) { |
|
|
void znordic_rtc_settime_s(uint32_t timestampNow) { |
|
|
if (timestampNow < g_timestamp) { |
|
|
if (timestampNow < g_timestamp) { |
|
@ -143,7 +161,6 @@ void znordic_rtc_gettime(ztm_t* now) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) { |
|
|
static void rtcCallbackFunc(nrf_drv_rtc_int_type_t interruptType) { |
|
|
static uint8_t s_timeCount1second = 0; |
|
|
|
|
|
if (interruptType == NRF_DRV_RTC_INT_TICK) // ÖжÏÀàÐÍ£ºµÎ´ðÖÐ?? |
|
|
if (interruptType == NRF_DRV_RTC_INT_TICK) // ÖжÏÀàÐÍ£ºµÎ´ðÖÐ?? |
|
|
{ |
|
|
{ |
|
|
if (s_timeCount1second >= 7) // 125ms * 8 = 1s |
|
|
if (s_timeCount1second >= 7) // 125ms * 8 = 1s |
|
|