![]() |
nrfx 4.5.0
|
Global Real Timer Counter (GRTC) peripheral driver. More...
Data Structures | |
| struct | nrfx_grtc_channel_t |
| GRTC capture/compare channel description structure. More... | |
| struct | nrfx_grtc_rtcounter_handler_data_t |
| GRTC RTCOUNTER handler data structure. More... | |
| struct | nrfx_grtc_sleep_config_t |
| GRTC SYSCOUNTER sleep configuration structure. More... | |
Macros | |
| #define | NRFX_GRTC_SLEEP_DEFAULT_CONFIG |
| GRTC sleep default configuration. | |
Typedefs | |
| typedef void(* | nrfx_grtc_cc_handler_t) (int32_t id, uint64_t cc_value, void *p_context) |
| GRTC driver instance compare handler type. | |
| typedef void(* | nrfx_grtc_syscountervalid_handler_t) (void *p_context) |
| GRTC driver instance SYSCOUNTER valid handler type. | |
| typedef void(* | nrfx_grtc_rtcomparesync_handler_t) (void *p_context) |
| GRTC driver instance RTCOMPARESYNC handler type. | |
Enumerations | |
| enum | nrfx_grtc_action_t { NRFX_GRTC_ACTION_START = NRF_GRTC_TASK_START , NRFX_GRTC_ACTION_STOP = NRF_GRTC_TASK_STOP , NRFX_GRTC_ACTION_CLEAR = NRF_GRTC_TASK_CLEAR } |
| GRTC action types. More... | |
| enum | nrfx_grtc_cc_relative_reference_t { NRFX_GRTC_CC_RELATIVE_SYSCOUNTER = NRF_GRTC_CC_ADD_REFERENCE_SYSCOUNTER , NRFX_GRTC_CC_RELATIVE_COMPARE = NRF_GRTC_CC_ADD_REFERENCE_CC } |
| GRTC compare event relative references. More... | |
Functions | |
| void | nrfx_grtc_sleep_configure (nrfx_grtc_sleep_config_t const *p_sleep_cfg) |
| Function for configuring the SYSCOUNTER sleep feature. | |
| void | nrfx_grtc_sleep_configuration_get (nrfx_grtc_sleep_config_t *p_sleep_cfg) |
| Function for getting the SYSCOUNTER sleep configuration. | |
| int | nrfx_grtc_channel_alloc (uint8_t *p_channel) |
| Function for allocating the GRTC capture/compare channel. | |
| int | nrfx_grtc_extended_channel_alloc (uint8_t *p_channel) |
| Function for allocating the extended GRTC capture/compare channel. | |
| void | nrfx_grtc_channel_callback_set (uint8_t channel, nrfx_grtc_cc_handler_t handler, void *p_context) |
| Function for setting a callback to a channel. | |
| int | nrfx_grtc_channel_free (uint8_t channel) |
| Function for freeing the GRTC capture/compare channel. | |
| bool | nrfx_grtc_is_channel_used (uint8_t channel) |
| Function for checking whether the specified channel is used by the driver. | |
| int | nrfx_grtc_init (uint8_t interrupt_priority) |
| Function for initializing the GRTC. | |
| int | nrfx_grtc_rtcounter_cc_disable (void) |
| Function for disabling the RTCOUNTER CC channel. | |
| void | nrfx_grtc_rtcomparesync_int_enable (nrfx_grtc_rtcomparesync_handler_t handler, void *p_context) |
| Function for enabling the RTCOMPARESYNC interrupt. | |
| void | nrfx_grtc_rtcomparesync_int_disable (void) |
| Function for disabling the RTCOMPARESYNC interrupt. | |
| int | nrfx_grtc_rtcounter_cc_absolute_set (nrfx_grtc_rtcounter_handler_data_t *handler_data, uint64_t val, bool enable_irq, bool sync) |
| Function for setting the absolute compare value for the RTCOUNTER. | |
| void | nrfx_grtc_rtcounter_cc_int_enable (bool sync) |
| Function for enabling the RTCOUNTER compare interrupt. | |
| void | nrfx_grtc_rtcounter_cc_int_disable (void) |
| Function for disabling the RTCOUNTER compare interrupt. | |
| void | nrfx_grtc_syscountervalid_int_enable (nrfx_grtc_syscountervalid_handler_t handler, void *p_context) |
| Function for enabling the SYSCOUNTERVALID interrupt. | |
| void | nrfx_grtc_syscountervalid_int_disable (void) |
| Function for disabling the SYSCOUNTERVALID interrupt. | |
| int | nrfx_grtc_syscounter_start (bool busy_wait, uint8_t *p_main_cc_channel) |
| Function for starting the 1 MHz SYSCOUNTER. | |
| int | nrfx_grtc_action_perform (nrfx_grtc_action_t action) |
| Function for performing an action for the GRTC. | |
| void | nrfx_grtc_uninit (void) |
| Function for uninitializing the GRTC. | |
| bool | nrfx_grtc_init_check (void) |
| Function for checking if the GRTC driver is initialized. | |
| int | nrfx_grtc_syscounter_cc_disable (uint8_t channel) |
| Function for disabling the SYSCOUNTER CC channel. | |
| int | nrfx_grtc_syscounter_cc_absolute_set (nrfx_grtc_channel_t *p_chan_data, uint64_t val, bool enable_irq) |
| Function for setting the absolute compare value for the SYSCOUNTER. | |
| void | nrfx_grtc_syscounter_cc_interval_set (uint8_t channel, uint32_t start_val, uint32_t val) |
| Function for setting the interval compare value for the SYSCOUNTER. | |
| void | nrfx_grtc_syscounter_cc_interval_reset (uint8_t channel) |
| Function for resetting the interval compare value for the SYSCOUNTER. | |
| void | nrfx_grtc_syscounter_cc_abs_set (uint8_t channel, uint64_t val, bool safe_setting) |
| Function for setting the absolute compare value for the SYSCOUNTER in an optimized way. | |
| int | nrfx_grtc_syscounter_cc_relative_set (nrfx_grtc_channel_t *p_chan_data, uint32_t val, bool enable_irq, nrfx_grtc_cc_relative_reference_t reference) |
| Function for setting the relative compare value for the SYSCOUNTER. | |
| void | nrfx_grtc_syscounter_cc_rel_set (uint8_t channel, uint32_t val, nrfx_grtc_cc_relative_reference_t reference) |
| Function for setting the relative compare value in an optimized way. | |
| int | nrfx_grtc_syscounter_cc_int_disable (uint8_t channel) |
| Function for disabling the SYSCOUNTER compare interrupt. | |
| int | nrfx_grtc_syscounter_cc_int_enable (uint8_t channel) |
| Function for enabling the SYSCOUNTER compare interrupt. | |
| bool | nrfx_grtc_syscounter_cc_int_enable_check (uint8_t channel) |
| Function for checking whether the SYSCOUNTER compare interrupt is enabled for the specified channel. | |
| int | nrfx_grtc_syscounter_capture (uint8_t channel) |
| Function for triggering the SYSCOUNTER capture task. | |
| int | nrfx_grtc_syscounter_cc_value_read (uint8_t channel, uint64_t *p_val) |
Function for reading the GRTC capture/compare register for the specified channel. | |
| bool | nrfx_grtc_ready_check (void) |
| Function for checking whether the SYSCOUNTER is in ready state. | |
| bool | nrfx_grtc_active_request_check (void) |
| Function for checking the current request for the SYSCOUNTER state. | |
| void | nrfx_grtc_active_request_set (bool active) |
| Function for requesting the SYSCOUNTER state. | |
| uint64_t | nrfx_grtc_syscounter_get (void) |
| Function for reading the GRTC SYSCOUNTER value. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_grtc_task_address_get (nrf_grtc_task_t task) |
| Function for retrieving the address of the specified GRTC task. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_grtc_event_address_get (nrf_grtc_event_t event) |
| Function for retrieving the address of the specified GRTC event. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_grtc_capture_task_address_get (uint8_t channel) |
| Function for retrieving the address of the capture task for the specified channel. | |
| NRFX_STATIC_INLINE uint32_t | nrfx_grtc_event_compare_address_get (uint8_t channel) |
| Function for retrieving the address of the capture task for the specified channel. | |
| NRFX_STATIC_INLINE bool | nrfx_grtc_sys_counter_cc_enable_check (uint8_t channel) |
| Function for checking whether the specified capture/compare channel is enabled. | |
| NRFX_STATIC_INLINE bool | nrfx_grtc_syscounter_compare_event_check (uint8_t channel) |
| Function for retrieving the state of the compare GRTC event. | |
| NRFX_STATIC_INLINE uint64_t | nrfx_grtc_sys_counter_cc_get (uint8_t channel) |
| Function for retrieving CC value. | |
| NRFX_STATIC_INLINE uint64_t | nrfx_grtc_rtcounter_get (void) |
| Function for reading the GRTC RTCOUNTER value. | |
| NRFX_STATIC_INLINE void | nrfx_grtc_clock_source_set (nrf_grtc_clksel_t clk_src) |
| Function for setting the clock source for the GRTC low-frequency clock. | |
Global Real Timer Counter (GRTC) peripheral driver.
| #define NRFX_GRTC_SLEEP_DEFAULT_CONFIG |
GRTC sleep default configuration.
This configuration sets up GRTC with the following options:
| typedef void(* nrfx_grtc_cc_handler_t) (int32_t id, uint64_t cc_value, void *p_context) |
GRTC driver instance compare handler type.
| [in] | id | Channel ID. |
| [in] | cc_value | Compare value. |
| [in] | p_context | User context. |
| typedef void(* nrfx_grtc_rtcomparesync_handler_t) (void *p_context) |
GRTC driver instance RTCOMPARESYNC handler type.
| [in] | p_context | User context. |
| typedef void(* nrfx_grtc_syscountervalid_handler_t) (void *p_context) |
GRTC driver instance SYSCOUNTER valid handler type.
| [in] | p_context | User context. |
| enum nrfx_grtc_action_t |
| int nrfx_grtc_action_perform | ( | nrfx_grtc_action_t | action | ) |
Function for performing an action for the GRTC.
| [in] | action | Action to be performed. |
| 0 | Starting was successful. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is running and the operation is not allowed. |
| bool nrfx_grtc_active_request_check | ( | void | ) |
Function for checking the current request for the SYSCOUNTER state.
| true | The SYSCOUNTER is requested to be enabled. |
| false | The SYSCOUNTER is requested to be disabled. |
| void nrfx_grtc_active_request_set | ( | bool | active | ) |
Function for requesting the SYSCOUNTER state.
| [in] | active | True if SYSCOUNTER is to be always kept active, false otherwise. |
| NRFX_STATIC_INLINE uint32_t nrfx_grtc_capture_task_address_get | ( | uint8_t | channel | ) |
Function for retrieving the address of the capture task for the specified channel.
| [in] | channel | Capture channel number. |
| int nrfx_grtc_channel_alloc | ( | uint8_t * | p_channel | ) |
Function for allocating the GRTC capture/compare channel.
| [out] | p_channel | Pointer to the capture/compare channel. |
| 0 | Allocation was successful. |
| -ENOMEM | No resource available. |
| void nrfx_grtc_channel_callback_set | ( | uint8_t | channel, |
| nrfx_grtc_cc_handler_t | handler, | ||
| void * | p_context ) |
Function for setting a callback to a channel.
Function enables the interrupt for that channel.
| [in] | channel | Channel. |
| [in] | handler | User handler called when channel expires. |
| [in] | p_context | Context passed to the callback. |
| int nrfx_grtc_channel_free | ( | uint8_t | channel | ) |
Function for freeing the GRTC capture/compare channel.
| [in] | channel | Allocated channel to be freed. |
| 0 | Allocation was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | Channel is not allocated. |
| NRFX_STATIC_INLINE void nrfx_grtc_clock_source_set | ( | nrf_grtc_clksel_t | clk_src | ) |
Function for setting the clock source for the GRTC low-frequency clock.
| [in] | clk_src | Selected clock source. |
| NRFX_STATIC_INLINE uint32_t nrfx_grtc_event_address_get | ( | nrf_grtc_event_t | event | ) |
Function for retrieving the address of the specified GRTC event.
| [in] | event | GRTC event. |
| NRFX_STATIC_INLINE uint32_t nrfx_grtc_event_compare_address_get | ( | uint8_t | channel | ) |
Function for retrieving the address of the capture task for the specified channel.
| [in] | channel | Compare channel number. |
| int nrfx_grtc_extended_channel_alloc | ( | uint8_t * | p_channel | ) |
Function for allocating the extended GRTC capture/compare channel.
| [out] | p_channel | Pointer to the capture/compare channel. |
| 0 | Allocation was successful. |
| -ENOMEM | No resource available. |
| int nrfx_grtc_init | ( | uint8_t | interrupt_priority | ) |
Function for initializing the GRTC.
| [in] | interrupt_priority | Interrupt priority. |
| 0 | Initialization was successful. |
| -EALREADY | The driver is already initialized. |
| -ECANCELED | No valid channel configuration provided. |
| bool nrfx_grtc_init_check | ( | void | ) |
Function for checking if the GRTC driver is initialized.
| true | Driver is already initialized. |
| false | Driver is not initialized. |
| bool nrfx_grtc_is_channel_used | ( | uint8_t | channel | ) |
Function for checking whether the specified channel is used by the driver.
| [in] | channel | Channel to be checked. |
| true | Channel is used by the driver. |
| false | Channel is not used by the driver. |
| bool nrfx_grtc_ready_check | ( | void | ) |
Function for checking whether the SYSCOUNTER is in ready state.
| true | The SYSCOUNTER is in ready state. |
| false | The SYSCOUNTER is not in ready state. |
| void nrfx_grtc_rtcomparesync_int_enable | ( | nrfx_grtc_rtcomparesync_handler_t | handler, |
| void * | p_context ) |
Function for enabling the RTCOMPARESYNC interrupt.
| [in] | handler | Handler provided by the user. May be NULL. |
| [in] | p_context | User context. |
| int nrfx_grtc_rtcounter_cc_absolute_set | ( | nrfx_grtc_rtcounter_handler_data_t * | handler_data, |
| uint64_t | val, | ||
| bool | enable_irq, | ||
| bool | sync ) |
Function for setting the absolute compare value for the RTCOUNTER.
| [in] | handler_data | Pointer to the handler data instance structure. |
| [in] | val | Absolute value to be set in the compare register. |
| [in] | enable_irq | True if interrupt is to be enabled, false otherwise. |
| [in] | sync | True if the internal synchronization mechanism shall be used, false otherwise. |
| 0 | The procedure was successful. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is running and the operation is not allowed. |
| int nrfx_grtc_rtcounter_cc_disable | ( | void | ) |
Function for disabling the RTCOUNTER CC channel.
| 0 | The procedure was successful. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is running and the operation is not allowed. |
| -ETIMEDOUT | RTCOUNTER compare interrupt is pending. |
| void nrfx_grtc_rtcounter_cc_int_enable | ( | bool | sync | ) |
Function for enabling the RTCOUNTER compare interrupt.
| [in] | sync | True if the internal synchronization mechanism shall be used, false otherwise. |
| NRFX_STATIC_INLINE uint64_t nrfx_grtc_rtcounter_get | ( | void | ) |
Function for reading the GRTC RTCOUNTER value.
| void nrfx_grtc_sleep_configuration_get | ( | nrfx_grtc_sleep_config_t * | p_sleep_cfg | ) |
Function for getting the SYSCOUNTER sleep configuration.
| [out] | p_sleep_cfg | Pointer to the structure to be filled with sleep configuration. |
| void nrfx_grtc_sleep_configure | ( | nrfx_grtc_sleep_config_t const * | p_sleep_cfg | ) |
Function for configuring the SYSCOUNTER sleep feature.
| [in] | p_sleep_cfg | Pointer to the configuration sleep structure. |
| NRFX_STATIC_INLINE bool nrfx_grtc_sys_counter_cc_enable_check | ( | uint8_t | channel | ) |
Function for checking whether the specified capture/compare channel is enabled.
| [in] | channel | Channel to be checked. |
| true | Channel is enabled. |
| false | Channel is disabled. |
| NRFX_STATIC_INLINE uint64_t nrfx_grtc_sys_counter_cc_get | ( | uint8_t | channel | ) |
Function for retrieving CC value.
| [in] | channel | Compare channel. |
| int nrfx_grtc_syscounter_capture | ( | uint8_t | channel | ) |
Function for triggering the SYSCOUNTER capture task.
channel as used.| [in] | channel | Capture channel number. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | Channel is not allocated. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| void nrfx_grtc_syscounter_cc_abs_set | ( | uint8_t | channel, |
| uint64_t | val, | ||
| bool | safe_setting ) |
Function for setting the absolute compare value for the SYSCOUNTER in an optimized way.
Function must be called with interrupts locked. If safe_setting is true then it means that previous CC for that channel did not yet expire and it was set to a value earlier than val so there is a chance that it will expire during setting the new value. In that case compare event may be misinterpreted. Slower but safe procedure is used in that case which ensures that there will be no unexpected user callback triggered. If safe_setting is false then function just sets new CC value.
| [in] | channel | Channel. |
| [in] | val | Absolute value to be set in the compare register. |
| [in] | safe_setting | True if safe procedure is to be used, false otherwise. |
| int nrfx_grtc_syscounter_cc_absolute_set | ( | nrfx_grtc_channel_t * | p_chan_data, |
| uint64_t | val, | ||
| bool | enable_irq ) |
Function for setting the absolute compare value for the SYSCOUNTER.
channel as used.| [in] | p_chan_data | Pointer to the channel data instance structure. |
| [in] | val | Absolute value to be set in the compare register. |
| [in] | enable_irq | True if interrupt is to be enabled, false otherwise. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | Channel is not allocated. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| int nrfx_grtc_syscounter_cc_disable | ( | uint8_t | channel | ) |
Function for disabling the SYSCOUNTER CC channel.
channel as unused.| [in] | channel | Channel to be disabled. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | The specified channel is either not allocated or marked as unused. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| -ETIMEDOUT | SYSCOUNTER compare interrupt is pending on the requested channel. |
| int nrfx_grtc_syscounter_cc_int_disable | ( | uint8_t | channel | ) |
Function for disabling the SYSCOUNTER compare interrupt.
| [in] | channel | Compare channel number. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | The specified channel is either not allocated or marked as unused. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| int nrfx_grtc_syscounter_cc_int_enable | ( | uint8_t | channel | ) |
Function for enabling the SYSCOUNTER compare interrupt.
channel as used.| [in] | channel | Compare channel number. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | Channel is not allocated. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| bool nrfx_grtc_syscounter_cc_int_enable_check | ( | uint8_t | channel | ) |
Function for checking whether the SYSCOUNTER compare interrupt is enabled for the specified channel.
| [in] | channel | Compare channel number. |
| true | The interrupt is enabled for the specified channel. |
| false | The interrupt is disabled for the specified channel. |
| void nrfx_grtc_syscounter_cc_interval_reset | ( | uint8_t | channel | ) |
Function for resetting the interval compare value for the SYSCOUNTER.
| [in] | channel | Channel. |
| void nrfx_grtc_syscounter_cc_interval_set | ( | uint8_t | channel, |
| uint32_t | start_val, | ||
| uint32_t | val ) |
Function for setting the interval compare value for the SYSCOUNTER.
start_val. | [in] | channel | Channel. |
| [in] | start_val | Relative compare value (in SYSCOUNTER ticks) value after which the first interval event is generated. |
| [in] | val | Relative interval value (in SYSCOUNTER ticks), that defines the period between consecutive compare events. |
| void nrfx_grtc_syscounter_cc_rel_set | ( | uint8_t | channel, |
| uint32_t | val, | ||
| nrfx_grtc_cc_relative_reference_t | reference ) |
Function for setting the relative compare value in an optimized way.
Function just sets CCADD value and does not attempt to enable or disable the interrupt. It assumes that expected channel configuration is done prior to that call. Function assumes that previously used CC value has already expired so new value can be safely set without a risk of spurious CC expiration.
| [in] | channel | Channel. |
| [in] | val | Relative value to be set in the CCADD register. |
| [in] | reference | Reference. Current counter value or current CC value. |
| int nrfx_grtc_syscounter_cc_relative_set | ( | nrfx_grtc_channel_t * | p_chan_data, |
| uint32_t | val, | ||
| bool | enable_irq, | ||
| nrfx_grtc_cc_relative_reference_t | reference ) |
Function for setting the relative compare value for the SYSCOUNTER.
Function has no assumptions on the current channel state so channel event is cleared and interrupt can optionally be enabled for that channel.
channel as used.| [in] | p_chan_data | Pointer to the channel data instance structure. |
| [in] | val | Relative value to be set in the compare register. |
| [in] | enable_irq | True if interrupt is to be enabled, false otherwise. |
| [in] | reference | Reference type to be used. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | Channel is not allocated. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| int nrfx_grtc_syscounter_cc_value_read | ( | uint8_t | channel, |
| uint64_t * | p_val ) |
Function for reading the GRTC capture/compare register for the specified channel.
| [in] | channel | Capture channel number. |
| [out] | p_val | Pointer to the variable where the result is to be stored. |
| 0 | The procedure was successful. |
| -EPERM | The domain is not allowed to use specified channel. |
| -EINVAL | The specified channel is either not allocated or marked as unused. |
| -ECANCELED | The SYSCOUNTER (1 MHz) is not running. |
| NRFX_STATIC_INLINE bool nrfx_grtc_syscounter_compare_event_check | ( | uint8_t | channel | ) |
Function for retrieving the state of the compare GRTC event.
| [in] | channel | Compare channel of the corresponding event to be checked. |
| true | The event has been generated. |
| false | The event has not been generated. |
| uint64_t nrfx_grtc_syscounter_get | ( | void | ) |
Function for reading the GRTC SYSCOUNTER value.
| int nrfx_grtc_syscounter_start | ( | bool | busy_wait, |
| uint8_t * | p_main_cc_channel ) |
Function for starting the 1 MHz SYSCOUNTER.
| [in] | busy_wait | True if wait for synchronization operation is to be performed, false otherwise. |
| [out] | p_main_cc_channel | Pointer to the main capture/compare channel. |
| 0 | Starting was successful. |
| -ENOMEM | No resource available to allocate main channel. |
| -EALREADY | The GRTC is already running. |
| -ETIMEDOUT | The SYSCOUNTER failed to start due to a timeout. |
| void nrfx_grtc_syscountervalid_int_enable | ( | nrfx_grtc_syscountervalid_handler_t | handler, |
| void * | p_context ) |
Function for enabling the SYSCOUNTERVALID interrupt.
| [in] | handler | Handler provided by the user. May be NULL. |
| [in] | p_context | User context. |
| NRFX_STATIC_INLINE uint32_t nrfx_grtc_task_address_get | ( | nrf_grtc_task_t | task | ) |
Function for retrieving the address of the specified GRTC task.
| [in] | task | GRTC task. |
| void nrfx_grtc_uninit | ( | void | ) |
Function for uninitializing the GRTC.