![]() |
nrfx 4.5.0
|
Real Timer Counter (RTC) peripheral driver. More...
Topics | |
| RTC peripheral driver configuration | |
Data Structures | |
| struct | nrfx_rtc_t |
| RTC driver instance structure. More... | |
| struct | nrfx_rtc_config_t |
| RTC driver instance configuration structure. More... | |
Macros | |
| #define | NRFX_RTC_US_TO_TICKS(us, freq) |
| Macro for converting microseconds into ticks. | |
| #define | NRFX_RTC_INSTANCE(reg) |
| Macro for creating an RTC driver instance. | |
| #define | NRFX_RTC_DEFAULT_CONFIG |
| RTC driver default configuration. | |
| #define | NRFX_RTC_INST_HANDLER_GET(idx) |
| Macro returning RTC interrupt handler. | |
Typedefs | |
| typedef void(* | nrfx_rtc_handler_t) (nrf_rtc_event_t event_type, void *p_context) |
| RTC driver instance handler type. | |
Functions | |
| int | nrfx_rtc_init (nrfx_rtc_t *p_instance, nrfx_rtc_config_t const *p_config, nrfx_rtc_handler_t handler) |
| Function for initializing the RTC driver instance. | |
| void | nrfx_rtc_uninit (nrfx_rtc_t *p_instance) |
| Function for uninitializing the RTC driver instance. | |
| bool | nrfx_rtc_init_check (nrfx_rtc_t const *p_instance) |
| Function for checking if the RTC driver instance is initialized. | |
| void | nrfx_rtc_enable (nrfx_rtc_t *p_instance) |
| Function for enabling the RTC driver instance. | |
| void | nrfx_rtc_disable (nrfx_rtc_t *p_instance) |
| Function for disabling the RTC driver instance. | |
| int | nrfx_rtc_cc_set (nrfx_rtc_t const *p_instance, uint32_t channel, uint32_t val, bool enable_irq) |
| Function for setting a compare channel. | |
| int | nrfx_rtc_cc_disable (nrfx_rtc_t const *p_instance, uint32_t channel) |
| Function for disabling a channel. | |
| void | nrfx_rtc_tick_enable (nrfx_rtc_t const *p_instance, bool enable_irq) |
| Function for enabling the TICK event. | |
| void | nrfx_rtc_tick_disable (nrfx_rtc_t const *p_instance) |
| Function for disabling the TICK event. | |
| void | nrfx_rtc_overflow_enable (nrfx_rtc_t const *p_instance, bool enable_irq) |
| Function for enabling overflow. | |
| void | nrfx_rtc_overflow_disable (nrfx_rtc_t const *p_instance) |
| Function for disabling overflow. | |
| uint32_t | nrfx_rtc_max_ticks_get (nrfx_rtc_t const *p_instance) |
| Function for getting the maximum relative tick value that can be set in the compare channel. | |
| NRFX_STATIC_INLINE void | nrfx_rtc_int_disable (nrfx_rtc_t const *p_instance, uint32_t *p_mask) |
| Function for disabling all instance interrupts. | |
| NRFX_STATIC_INLINE void | nrfx_rtc_int_enable (nrfx_rtc_t const *p_instance, uint32_t mask) |
| Function for enabling instance interrupts. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_rtc_counter_get (nrfx_rtc_t const *p_instance) |
| Function for retrieving the current counter value. | |
| NRFX_STATIC_INLINE void | nrfx_rtc_counter_clear (nrfx_rtc_t const *p_instance) |
| Function for clearing the counter value. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_rtc_task_address_get (nrfx_rtc_t const *p_instance, nrf_rtc_task_t task) |
| Function for returning a requested task address for the RTC driver instance. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_rtc_event_address_get (nrfx_rtc_t const *p_instance, nrf_rtc_event_t event) |
| Function for returning a requested event address for the RTC driver instance. | |
| void | nrfx_rtc_irq_handler (nrfx_rtc_t *p_instance) |
| Driver interrupt handler. | |
Real Timer Counter (RTC) peripheral driver.
| #define NRFX_RTC_DEFAULT_CONFIG |
RTC driver default configuration.
This configuration sets up RTC with the following options:
| #define NRFX_RTC_INST_HANDLER_GET | ( | idx | ) |
Macro returning RTC interrupt handler.
param[in] idx RTC index.
| #define NRFX_RTC_INSTANCE | ( | reg | ) |
Macro for creating an RTC driver instance.
| #define NRFX_RTC_US_TO_TICKS | ( | us, | |
| freq ) |
Macro for converting microseconds into ticks.
| typedef void(* nrfx_rtc_handler_t) (nrf_rtc_event_t event_type, void *p_context) |
RTC driver instance handler type.
| [in] | event_type | RTC event type. |
| [in] | p_context | General purpose parameter set during initialization of the RTC. This parameter can be used to pass additional information to the handler function, for example, the RTC ID. |
| int nrfx_rtc_cc_disable | ( | nrfx_rtc_t const * | p_instance, |
| uint32_t | channel ) |
Function for disabling a channel.
This function disables channel events and channel interrupts.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | channel | One of the channels of the instance. |
| 0 | The procedure is successful. |
| -ETIMEDOUT | Interrupt is pending on the requested channel. |
| int nrfx_rtc_cc_set | ( | nrfx_rtc_t const * | p_instance, |
| uint32_t | channel, | ||
| uint32_t | val, | ||
| bool | enable_irq ) |
Function for setting a compare channel.
The function powers on the instance if the instance was in power off state.
The driver is not entering a critical section when configuring RTC, which means that it can be preempted for a certain amount of time. When the driver was preempted and the value to be set is short in time, there is a risk that the driver sets a compare value that is behind. In this case, if the reliable mode is enabled for the specified instance, the risk is handled. However, to detect if the requested value is behind, this mode makes the following assumptions:
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | channel | One of the channels of the instance. |
| [in] | val | Absolute value to be set in the compare register. |
| [in] | enable_irq | True to enable the interrupt. False to disable the interrupt. |
| 0 | The procedure is successful. |
| -ETIMEDOUT | The compare is not set because the request value is behind the current counter value. This error can only be reported if the reliable mode is enabled. |
| NRFX_STATIC_INLINE void nrfx_rtc_counter_clear | ( | nrfx_rtc_t const * | p_instance | ) |
Function for clearing the counter value.
| [in] | p_instance | Pointer to the driver instance structure. |
| NRFX_STATIC_INLINE uint32_t nrfx_rtc_counter_get | ( | nrfx_rtc_t const * | p_instance | ) |
Function for retrieving the current counter value.
| [in] | p_instance | Pointer to the driver instance structure. |
| void nrfx_rtc_disable | ( | nrfx_rtc_t * | p_instance | ) |
Function for disabling the RTC driver instance.
| [in] | p_instance | Pointer to the driver instance structure. |
| void nrfx_rtc_enable | ( | nrfx_rtc_t * | p_instance | ) |
Function for enabling the RTC driver instance.
| [in] | p_instance | Pointer to the driver instance structure. |
| NRFX_STATIC_INLINE uint32_t nrfx_rtc_event_address_get | ( | nrfx_rtc_t const * | p_instance, |
| nrf_rtc_event_t | event ) |
Function for returning a requested event address for the RTC driver instance.
The event address can be used by the PPI module.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | event | One of the peripheral events. |
| int nrfx_rtc_init | ( | nrfx_rtc_t * | p_instance, |
| nrfx_rtc_config_t const * | p_config, | ||
| nrfx_rtc_handler_t | handler ) |
Function for initializing the RTC driver instance.
After initialization, the instance is in power off state.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_config | Pointer to the structure with the initial configuration. |
| [in] | handler | Event handler provided by the user. Must not be NULL. |
| 0 | Successfully initialized. |
| -EALREADY | The driver is already initialized. |
| bool nrfx_rtc_init_check | ( | nrfx_rtc_t const * | p_instance | ) |
Function for checking if the RTC driver instance is initialized.
| [in] | p_instance | Pointer to the driver instance structure. |
| true | Instance is already initialized. |
| false | Instance is not initialized. |
| NRFX_STATIC_INLINE void nrfx_rtc_int_disable | ( | nrfx_rtc_t const * | p_instance, |
| uint32_t * | p_mask ) |
Function for disabling all instance interrupts.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | p_mask | Pointer to the location where the mask is filled. |
| NRFX_STATIC_INLINE void nrfx_rtc_int_enable | ( | nrfx_rtc_t const * | p_instance, |
| uint32_t | mask ) |
Function for enabling instance interrupts.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | mask | Mask of interrupts to enable. |
| void nrfx_rtc_irq_handler | ( | nrfx_rtc_t * | p_instance | ) |
Driver interrupt handler.
| [in] | p_instance | Pointer to the driver instance structure. |
| uint32_t nrfx_rtc_max_ticks_get | ( | nrfx_rtc_t const * | p_instance | ) |
Function for getting the maximum relative tick value that can be set in the compare channel.
When a stack (for example SoftDevice) is used and it occupies high priority interrupts, the application code can be interrupted at any moment for a certain period of time. If the reliable mode is enabled, the provided maximum latency is taken into account and the return value is smaller than the RTC counter resolution. If the reliable mode is disabled, the return value equals the counter resolution.
| [in] | p_instance | Pointer to the driver instance structure. |
| void nrfx_rtc_overflow_disable | ( | nrfx_rtc_t const * | p_instance | ) |
Function for disabling overflow.
This function disables the overflow event and interrupt.
| [in] | p_instance | Pointer to the driver instance structure. |
| void nrfx_rtc_overflow_enable | ( | nrfx_rtc_t const * | p_instance, |
| bool | enable_irq ) |
Function for enabling overflow.
This function enables the overflow event and optionally the interrupt.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | enable_irq | True to enable the interrupt. False to disable the interrupt. |
| NRFX_STATIC_INLINE uint32_t nrfx_rtc_task_address_get | ( | nrfx_rtc_t const * | p_instance, |
| nrf_rtc_task_t | task ) |
Function for returning a requested task address for the RTC driver instance.
The task address can be used by the PPI module.
| [in] | p_instance | Pointer to the instance. |
| [in] | task | One of the peripheral tasks. |
| void nrfx_rtc_tick_disable | ( | nrfx_rtc_t const * | p_instance | ) |
Function for disabling the TICK event.
This function disables the TICK event and interrupt.
| [in] | p_instance | Pointer to the driver instance structure. |
| void nrfx_rtc_tick_enable | ( | nrfx_rtc_t const * | p_instance, |
| bool | enable_irq ) |
Function for enabling the TICK event.
This function enables the tick event and optionally the interrupt.
| [in] | p_instance | Pointer to the driver instance structure. |
| [in] | enable_irq | True to enable the interrupt. False to disable the interrupt. |
| void nrfx_rtc_uninit | ( | nrfx_rtc_t * | 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.
| [in] | p_instance | Pointer to the driver instance structure. |