50 #include "nrf_drv_config.h"
51 #include "nrf_drv_rtc.h"
52 #include "nrf_drv_clock.h"
53 #include "nrf_delay.h"
54 #include "app_error.h"
56 #include "platform-conf.h"
61 static volatile uint32_t ticks;
62 void clock_update(
void);
64 #define TICKS (RTC1_CONFIG_FREQUENCY/CLOCK_CONF_SECOND)
73 if (int_type == NRF_DRV_RTC_INT_TICK) {
78 #ifndef SOFTDEVICE_PRESENT
84 ret_code_t err_code = nrf_drv_clock_init(
NULL);
85 APP_ERROR_CHECK(err_code);
87 nrf_drv_clock_lfclk_request();
101 APP_ERROR_CHECK(err_code);
104 nrf_drv_rtc_tick_enable(&
rtc,
true);
107 nrf_drv_rtc_enable(&
rtc);
114 #ifndef SOFTDEVICE_PRESENT
123 return (clock_time_t)(ticks & 0xFFFFFFFF);
138 return (
unsigned long)ticks/CLOCK_CONF_SECOND;
146 while (
clock_time() - start < (clock_time_t)i) {
#define PLATFORM_RTC_INSTANCE_ID
nRF52 RTC instance to be used for Contiki clock driver.
static void start(void)
Start measurement.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
int etimer_pending(void)
Check if there are any non-expired event timers.
clock_time_t clock_time(void)
Get the current clock time.
const nrf_drv_rtc_t rtc
RTC instance used for platform clock.
void clock_init()
Initialize the clock library.
#define NULL
The null pointer.
static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
Function for handling the RTC0 interrupts.
static void rtc_config(void)
Function initialization and configuration of RTC driver instance.
static void lfclk_config(void)
Function starting the internal LFCLK XTAL oscillator.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
void clock_delay_usec(uint16_t usec)
Delay a given number of microseconds.