Real Timer Counter (RTC) peripheral driver for app_timer. More...
Data Structures | |
struct | drv_rtc_t |
RTC driver instance structure. More... | |
struct | drv_rtc_config_t |
RTC driver instance configuration structure. More... | |
Macros | |
#define | DRV_RTC_MAX_CNT RTC_COUNTER_COUNTER_Msk |
Maximum RTC counter value. | |
#define | DRV_RTC_CONFIG_APPLY_TIME_US 33 |
Time requires to update registers between RTC and MCU domains. | |
#define | DRV_RTC_MIN_TICK_HANDLED 3 |
Minimum delta value between set value and counter value. More... | |
#define | DRV_RTC_US_TO_TICKS(us, freq) |
Macro to convert microseconds into ticks. More... | |
#define | DRV_RTC_INSTANCE(id) |
Macro for creating RTC driver instance. More... | |
#define | DRV_RTC_DEFAULT_CONFIG |
RTC instance default configuration. More... | |
Typedefs | |
typedef void(* | drv_rtc_handler_t )(drv_rtc_t const *const p_instance) |
RTC driver instance handler type. | |
Enumerations | |
enum | { DRV_RTC_ENABLED_COUNT } |
Functions | |
ret_code_t | drv_rtc_init (drv_rtc_t const *const p_instance, drv_rtc_config_t const *p_config, drv_rtc_handler_t handler) |
Function for initializing the RTC driver instance. More... | |
void | drv_rtc_uninit (drv_rtc_t const *const p_instance) |
Function for uninitializing the RTC driver instance. More... | |
void | drv_rtc_start (drv_rtc_t const *const p_instance) |
Function for starting RTC clock. More... | |
void | drv_rtc_stop (drv_rtc_t const *const p_instance) |
Function for stopping RTC clock. More... | |
void | drv_rtc_compare_set (drv_rtc_t const *const p_instance, uint32_t cc, uint32_t abs_value, bool irq_enable) |
Function for configuring compare channel. More... | |
ret_code_t | drv_rtc_windowed_compare_set (drv_rtc_t const *const p_instance, uint32_t cc, uint32_t abs_value, uint16_t safe_window) |
Function for configuring compare channel with safe window. More... | |
void | drv_rtc_overflow_enable (drv_rtc_t const *const p_instance, bool irq_enable) |
Function for enabling overflow event and interrupt. More... | |
void | drv_rtc_overflow_disable (drv_rtc_t const *const p_instance) |
Function for diabling overflow event and interrupt. More... | |
bool | drv_rtc_overflow_pending (drv_rtc_t const *const p_instance) |
Function for checking if overflow event has occured. More... | |
void | drv_rtc_tick_enable (drv_rtc_t const *const p_instance, bool irq_enable) |
Function for enabling tick event and interrupt. More... | |
void | drv_rtc_tick_disable (drv_rtc_t const *const p_instance) |
Function for disabling tick event and interrupt. More... | |
bool | drv_rtc_tick_pending (drv_rtc_t const *const p_instance) |
Function for checking if tick event has occured. More... | |
void | drv_rtc_compare_enable (drv_rtc_t const *const p_instance, uint32_t cc, bool irq_enable) |
Function for enabling compare channel event and interrupt. More... | |
void | drv_rtc_compare_disable (drv_rtc_t const *const p_instance, uint32_t cc) |
Function for disabling compare channel event and interrupt. More... | |
bool | drv_rtc_compare_pending (drv_rtc_t const *const p_instance, uint32_t cc) |
Function for checking if compare channel event has occured. More... | |
uint32_t | drv_rtc_counter_get (drv_rtc_t const *const p_instance) |
Function for getting current value of RTC counter. More... | |
void | drv_rtc_irq_trigger (drv_rtc_t const *const p_instance) |
Function for triggering RTC interrupt. More... | |
Real Timer Counter (RTC) peripheral driver for app_timer.
#define DRV_RTC_DEFAULT_CONFIG |
RTC instance default configuration.
#define DRV_RTC_INSTANCE | ( | id | ) |
Macro for creating RTC driver instance.
#define DRV_RTC_MIN_TICK_HANDLED 3 |
Minimum delta value between set value and counter value.
RTC peripheral requires two ticks to be sure that value it properly set in RTC value. Compare channel function requires additional one tick to avoid problematic situations (lack or additional unspecified event) when Compare Channel register is reseting or setting to N+2 value.
#define DRV_RTC_US_TO_TICKS | ( | us, | |
freq | |||
) |
Macro to convert microseconds into ticks.
void drv_rtc_compare_disable | ( | drv_rtc_t const *const | p_instance, |
uint32_t | cc | ||
) |
Function for disabling compare channel event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc | Compare channel index. |
void drv_rtc_compare_enable | ( | drv_rtc_t const *const | p_instance, |
uint32_t | cc, | ||
bool | irq_enable | ||
) |
Function for enabling compare channel event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc | Compare channel index. |
[in] | irq_enable | True to enable interrupt. |
bool drv_rtc_compare_pending | ( | drv_rtc_t const *const | p_instance, |
uint32_t | cc | ||
) |
Function for checking if compare channel event has occured.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc | Compare channel index. |
void drv_rtc_compare_set | ( | drv_rtc_t const *const | p_instance, |
uint32_t | cc, | ||
uint32_t | abs_value, | ||
bool | irq_enable | ||
) |
Function for configuring compare channel.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc | Compare channel index. |
[in] | abs_value | Absolute value to be set in the compare register. |
[in] | irq_enable | True to enable interrupt. |
uint32_t drv_rtc_counter_get | ( | drv_rtc_t const *const | p_instance | ) |
Function for getting current value of RTC counter.
[in] | p_instance | Pointer to the driver instance structure. |
ret_code_t drv_rtc_init | ( | drv_rtc_t const *const | p_instance, |
drv_rtc_config_t const * | p_config, | ||
drv_rtc_handler_t | handler | ||
) |
Function for initializing the RTC driver instance.
After initialization, the instance is in power off state. The LFCLK (CLOCK driver) has to be started before using RTC driver.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_config | Pointer to the structure with initial configuration. |
[in] | handler | Event handler provided by the user. Must not be NULL. |
NRF_SUCCESS | If successfully initialized. |
NRF_ERROR_INVALID_STATE | If the instance is already initialized. |
void drv_rtc_irq_trigger | ( | drv_rtc_t const *const | p_instance | ) |
Function for triggering RTC interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_overflow_disable | ( | drv_rtc_t const *const | p_instance | ) |
Function for diabling overflow event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_overflow_enable | ( | drv_rtc_t const *const | p_instance, |
bool | irq_enable | ||
) |
Function for enabling overflow event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | irq_enable | True to enable interrupt. |
bool drv_rtc_overflow_pending | ( | drv_rtc_t const *const | p_instance | ) |
Function for checking if overflow event has occured.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_start | ( | drv_rtc_t const *const | p_instance | ) |
Function for starting RTC clock.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_stop | ( | drv_rtc_t const *const | p_instance | ) |
Function for stopping RTC clock.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_tick_disable | ( | drv_rtc_t const *const | p_instance | ) |
Function for disabling tick event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_tick_enable | ( | drv_rtc_t const *const | p_instance, |
bool | irq_enable | ||
) |
Function for enabling tick event and interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | irq_enable | True to enable interrupt. |
bool drv_rtc_tick_pending | ( | drv_rtc_t const *const | p_instance | ) |
Function for checking if tick event has occured.
[in] | p_instance | Pointer to the driver instance structure. |
void drv_rtc_uninit | ( | drv_rtc_t const *const | p_instance | ) |
Function for uninitializing the RTC driver instance.
After uninitialization, the instance is in idle state. The hardware should return to the state before initialization. The function asserts if the instance is in idle state.
[in] | p_instance | Pointer to the driver instance structure. |
ret_code_t drv_rtc_windowed_compare_set | ( | drv_rtc_t const *const | p_instance, |
uint32_t | cc, | ||
uint32_t | abs_value, | ||
uint16_t | safe_window | ||
) |
Function for configuring compare channel with safe window.
Maximum possible relative value is limited by safe window to detect cases when requested compare event has already occured.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc | Compare channel index. |
[in] | abs_value | Absolute value to be set in the compare register. |
[in] | safe_window | Width of the safe window. |
NRF_ERROR_TIMEOUT | If |
NRF_SUCCESS | If successfully set. |