51 #include "sdk_config.h" 52 #include "nrf_drv_rtc.h" 53 #include "nrf_drv_clock.h" 54 #include "nrf_delay.h" 55 #include "app_error.h" 60 static volatile uint32_t ticks;
61 void clock_update(
void);
63 #define TICKS (RTC1_CONFIG_FREQUENCY / CLOCK_CONF_SECOND) 72 if(int_type == NRF_DRV_RTC_INT_TICK) {
81 ret_code_t err_code = nrf_drv_clock_init();
82 APP_ERROR_CHECK(err_code);
83 nrf_drv_clock_lfclk_request(NULL);
94 nrf_drv_rtc_config_t
config = NRF_DRV_RTC_DEFAULT_CONFIG;
95 config.prescaler = 255;
96 config.interrupt_priority = 6;
100 APP_ERROR_CHECK(err_code);
103 nrf_drv_rtc_tick_enable(&
rtc,
true);
106 nrf_drv_rtc_enable(&
rtc);
120 return (clock_time_t)(ticks & 0xFFFFFFFF);
135 return (
unsigned long)ticks / CLOCK_CONF_SECOND;
143 while(
clock_time() - start < (clock_time_t)i) {
const nrf_drv_rtc_t rtc
RTC instance used for platform clock.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
static void rtc_config(void)
Function initialization and configuration of RTC driver instance.
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.
static void lfclk_config(void)
Function starting the internal LFCLK XTAL oscillator.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
static void start(void)
Start measurement.
int etimer_pending(void)
Check if there are any non-expired event timers.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
clock_time_t clock_time(void)
Get the current clock time.
static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
Function for handling the RTC0 interrupts.
void clock_init(void)
Arch-specific implementation of clock_init for the cc2538.