50 #include "nrfx_config.h" 52 #include "nrfx_clock.h" 55 const nrfx_rtc_t
rtc = NRFX_RTC_INSTANCE(0);
57 static volatile uint32_t ticks;
58 void clock_update(
void);
67 if(int_type == NRFX_RTC_INT_TICK) {
77 nrfx_err_t err_code = nrfx_clock_init(NULL);
79 if(err_code != NRFX_SUCCESS) {
83 nrfx_clock_lfclk_start();
94 nrfx_rtc_config_t
config = NRFX_RTC_DEFAULT_CONFIG;
95 config.prescaler = 255;
96 config.interrupt_priority = 6;
101 if(err_code != NRFX_SUCCESS) {
106 nrfx_rtc_tick_enable(&
rtc,
true);
109 nrfx_rtc_enable(&
rtc);
123 return (clock_time_t)(ticks & 0xFFFFFFFF);
138 return (
unsigned long)ticks / CLOCK_CONF_SECOND;
146 while(
clock_time() - start < (clock_time_t)i) {
const nrfx_rtc_t rtc
RTC instance used for platform clock.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
static void start(void)
Start measurement.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
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 RTC0 interrupts.
int etimer_pending(void)
Check if there are any non-expired event timers.
static void lfclk_config(void)
Function starting the internal LFCLK XTAL oscillator.
void clock_init(void)
Initialize the clock library.
clock_time_t clock_time(void)
Get the current clock time.
static void rtc_config(void)
Function initialization and configuration of RTC driver instance.