RTC HAL
- group nrf_rtc_hal
Hardware access layer for managing the Real Time Counter (RTC) peripheral.
Defines
-
NRF_RTC_INST_GET(idx)
Macro getting pointer to the structure of registers of the RTC peripheral.
- Parameters:
idx – [in] RTC instance index.
- Returns:
Pointer to the structure of registers of the RTC peripheral.
-
NRF_RTC_CC_CHANNEL_COUNT(id)
Macro for getting the number of compare channels available in a given RTC instance.
-
NRF_RTC_CC_COUNT_MAX
Symbol specifying maximum number of available compare channels.
-
NRF_RTC_COUNTER_MAX
Maximum value of the RTC counter.
-
NRF_RTC_INPUT_FREQ
Input frequency of the RTC instance.
-
NRF_RTC_FREQ_TO_PRESCALER(FREQ)
Macro for converting expected frequency to prescaler setting.
-
NRF_RTC_WRAP(val)
Macro for trimming values to the RTC bit width.
-
NRF_RTC_CHANNEL_INT_MASK(ch)
Macro for creating the interrupt bitmask for the specified compare channel.
-
NRF_RTC_ALL_CHANNELS_INT_MASK
Macro for creating the interrupt bitmask for all compare channels.
-
NRF_RTC_CHANNEL_EVENT_ADDR(ch)
Macro for obtaining the compare event for the specified channel.
Enums
-
enum nrf_rtc_task_t
RTC tasks.
Values:
-
enumerator NRF_RTC_TASK_START
Start.
-
enumerator NRF_RTC_TASK_STOP
Stop.
-
enumerator NRF_RTC_TASK_CLEAR
Clear.
-
enumerator NRF_RTC_TASK_TRIGGER_OVERFLOW
Trigger overflow.
-
enumerator NRF_RTC_TASK_CAPTURE_0
Capture the counter value on channel 0.
-
enumerator NRF_RTC_TASK_CAPTURE_1
Capture the counter value on channel 1.
-
enumerator NRF_RTC_TASK_CAPTURE_2
Capture the counter value on channel 2.
-
enumerator NRF_RTC_TASK_CAPTURE_3
Capture the counter value on channel 3.
-
enumerator NRF_RTC_TASK_START
-
enum nrf_rtc_event_t
RTC events.
Values:
-
enumerator NRF_RTC_EVENT_TICK
Tick event.
-
enumerator NRF_RTC_EVENT_OVERFLOW
Overflow event.
-
enumerator NRF_RTC_EVENT_COMPARE_0
Compare 0 event.
-
enumerator NRF_RTC_EVENT_COMPARE_1
Compare 1 event.
-
enumerator NRF_RTC_EVENT_COMPARE_2
Compare 2 event.
-
enumerator NRF_RTC_EVENT_COMPARE_3
Compare 3 event.
-
enumerator NRF_RTC_EVENT_TICK
-
enum nrf_rtc_int_t
RTC interrupts.
Values:
-
enumerator NRF_RTC_INT_TICK_MASK
RTC interrupt from tick event.
-
enumerator NRF_RTC_INT_OVERFLOW_MASK
RTC interrupt from overflow event.
-
enumerator NRF_RTC_INT_COMPARE0_MASK
RTC interrupt from compare event on channel 0.
-
enumerator NRF_RTC_INT_COMPARE1_MASK
RTC interrupt from compare event on channel 1.
-
enumerator NRF_RTC_INT_COMPARE2_MASK
RTC interrupt from compare event on channel 2.
-
enumerator NRF_RTC_INT_COMPARE3_MASK
RTC interrupt from compare event on channel 3.
-
enumerator NRF_RTC_INT_TICK_MASK
Functions
-
NRF_STATIC_INLINE void nrf_rtc_cc_set(NRF_RTC_Type *p_reg, uint32_t ch, uint32_t cc_val)
Function for setting a compare value for a channel.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
ch – [in] Channel.
cc_val – [in] Compare value to be set.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_cc_get(NRF_RTC_Type const *p_reg, uint32_t ch)
Function for returning the compare value for a channel.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
ch – [in] Channel.
- Returns:
COMPARE[ch] value.
-
NRF_STATIC_INLINE void nrf_rtc_int_enable(NRF_RTC_Type *p_reg, uint32_t mask)
Function for enabling interrupts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Interrupt mask to be enabled.
-
NRF_STATIC_INLINE void nrf_rtc_int_disable(NRF_RTC_Type *p_reg, uint32_t mask)
Function for disabling interrupts.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Interrupt mask to be disabled.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_int_enable_check(NRF_RTC_Type const *p_reg, uint32_t mask)
Function for checking if the specified interrupts are enabled.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of interrupts to be checked.
- Returns:
Mask of enabled interrupts.
-
NRF_STATIC_INLINE void nrf_rtc_subscribe_set(NRF_RTC_Type *p_reg, nrf_rtc_task_t task, uint8_t channel)
Function for setting the subscribe configuration for a given RTC task.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task for which to set the configuration.
channel – [in] Channel through which to subscribe events.
-
NRF_STATIC_INLINE void nrf_rtc_subscribe_clear(NRF_RTC_Type *p_reg, nrf_rtc_task_t task)
Function for clearing the subscribe configuration for a given RTC task.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Task for which to clear the configuration.
-
NRF_STATIC_INLINE void nrf_rtc_publish_set(NRF_RTC_Type *p_reg, nrf_rtc_event_t event, uint8_t channel)
Function for setting the publish configuration for a given RTC event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event for which to set the configuration.
channel – [in] Channel through which to publish the event.
-
NRF_STATIC_INLINE void nrf_rtc_publish_clear(NRF_RTC_Type *p_reg, nrf_rtc_event_t event)
Function for clearing the publish configuration for a given RTC event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event for which to clear the configuration.
-
NRF_STATIC_INLINE bool nrf_rtc_event_check(NRF_RTC_Type const *p_reg, nrf_rtc_event_t event)
Function for retrieving the state of the RTC event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event to be checked.
- Return values:
true – The event has been generated.
false – The event has not been generated.
-
NRF_STATIC_INLINE void nrf_rtc_event_clear(NRF_RTC_Type *p_reg, nrf_rtc_event_t event)
Function for clearing an event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Event to be cleared.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_counter_get(NRF_RTC_Type const *p_reg)
Function for returning a counter value.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Returns:
Counter value.
-
NRF_STATIC_INLINE void nrf_rtc_prescaler_set(NRF_RTC_Type *p_reg, uint32_t val)
Function for setting a prescaler value.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
val – [in] Value to set the prescaler to.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_prescaler_get(NRF_RTC_Type const *p_reg)
Function for getting a prescaler value.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
- Returns:
Prescaler value.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_event_address_get(NRF_RTC_Type const *p_reg, nrf_rtc_event_t event)
Function for returning the address of an event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
event – [in] Requested event.
- Returns:
Address of the requested event register.
-
NRF_STATIC_INLINE uint32_t nrf_rtc_task_address_get(NRF_RTC_Type const *p_reg, nrf_rtc_task_t task)
Function for returning the address of a task.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Requested task.
- Returns:
Address of the requested task register.
-
NRF_STATIC_INLINE nrf_rtc_task_t nrf_rtc_capture_task_get(uint8_t index)
Function for getting the CAPTURE task associated with the specified capture channel.
- Parameters:
index – [in] Capture channel index.
- Returns:
Requested CAPTURE task.
-
NRF_STATIC_INLINE void nrf_rtc_task_trigger(NRF_RTC_Type *p_reg, nrf_rtc_task_t task)
Function for starting a task.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
task – [in] Requested task.
-
NRF_STATIC_INLINE void nrf_rtc_event_enable(NRF_RTC_Type *p_reg, uint32_t mask)
Function for enabling events.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of event flags to be enabled.
-
NRF_STATIC_INLINE void nrf_rtc_event_disable(NRF_RTC_Type *p_reg, uint32_t mask)
Function for disabling an event.
- Parameters:
p_reg – [in] Pointer to the structure of registers of the peripheral.
mask – [in] Mask of event flags to be disabled.
-
NRF_STATIC_INLINE nrf_rtc_event_t nrf_rtc_compare_event_get(uint8_t index)
Function for getting the COMPARE event associated with the specified compare channel.
- Parameters:
index – [in] Compare channel index.
- Returns:
Requested COMPARE event.
-
NRF_RTC_INST_GET(idx)