50#include "nrfx_config.h"
52#include "nrfx_clock.h"
56#error CLOCK_CONF_SIZE must be 4 (32 bit)
59#ifdef NRF_CLOCK_CONF_RTC_INSTANCE
60#define NRF_CLOCK_RTC_INSTANCE NRF_CLOCK_CONF_RTC_INSTANCE
62#define NRF_CLOCK_RTC_INSTANCE 0
65static void clock_update(
void);
69static const nrfx_rtc_t
rtc = NRFX_RTC_INSTANCE(NRF_CLOCK_RTC_INSTANCE);
71static volatile clock_time_t ticks;
74clock_handler(nrfx_clock_evt_type_t event)
86 if(int_type == NRFX_RTC_INT_TICK) {
97 nrfx_err_t err_code = nrfx_clock_init(clock_handler);
99 if(err_code != NRFX_SUCCESS) {
105 nrfx_clock_lfclk_start();
117 nrfx_rtc_config_t config = NRFX_RTC_DEFAULT_CONFIG;
118 config.prescaler = 255;
119 config.interrupt_priority = 6;
124 if(err_code != NRFX_SUCCESS) {
129 nrfx_rtc_tick_enable(&
rtc,
true);
132 nrfx_rtc_enable(&
rtc);
#define CLOCK_SECOND
A second, measured in system clock time.
int etimer_pending(void)
Check if there are any non-expired event timers.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
void clock_init(void)
Initialize the clock library.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
clock_time_t clock_time(void)
Get the current clock time.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
static void rtc_handler(nrfx_rtc_int_type_t int_type)
Function for handling the RTC<instance> interrupts.
static void rtc_config(void)
Function initialization and configuration of RTC driver instance.
static const nrfx_rtc_t rtc
< RTC instance used for platform clock
static void lfclk_config(void)
Function starting the internal LFCLK XTAL oscillator.
static void start(void)
Start measurement.