nrfx 3.3
Data Structures | Typedefs | Enumerations | Functions
GRTC driver

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...
 

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

nrfx_err_t nrfx_grtc_channel_alloc (uint8_t *p_channel)
 Function for allocating the GRTC capture/compare channel.
 
nrfx_err_t 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.
 
nrfx_err_t nrfx_grtc_init (uint8_t interrupt_priority)
 Function for initializing the GRTC.
 
nrfx_err_t 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.
 
nrfx_err_t 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 SYSCOUNTER valid interrupt.
 
void nrfx_grtc_syscountervalid_int_disable (void)
 Function for disabling the SYSCOUNTERVALID interrupt.
 
nrfx_err_t nrfx_grtc_syscounter_start (bool busy_wait, uint8_t *p_main_cc_channel)
 Function for starting the 1 MHz SYSCOUNTER.
 
nrfx_err_t 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.
 
nrfx_err_t nrfx_grtc_syscounter_cc_disable (uint8_t channel)
 Function for disabling the SYSCOUNTER CC channel.
 
nrfx_err_t 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.
 
nrfx_err_t 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.
 
nrfx_err_t nrfx_grtc_syscounter_cc_int_disable (uint8_t channel)
 Function for disabling the SYSCOUNTER compare interrupt.
 
nrfx_err_t 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.
 
nrfx_err_t nrfx_grtc_syscounter_capture (uint8_t channel)
 Function for triggering the SYSCOUNTER capture task.
 
nrfx_err_t 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.
 
void nrfx_grtc_active_request_set (bool active)
 Function for requesting the SYSCOUNTER state.
 
nrfx_err_t nrfx_grtc_syscounter_get (uint64_t *p_counter)
 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 uint64_t nrfx_grtc_rtcounter_get (void)
 Function for reading the GRTC RTCOUNTER value.
 

Detailed Description

Global Real Timer Counter (GRTC) peripheral driver.

Typedef Documentation

◆ nrfx_grtc_cc_handler_t

typedef void(* nrfx_grtc_cc_handler_t) (int32_t id, uint64_t cc_value, void *p_context)

GRTC driver instance compare handler type.

Parameters
[in]idChannel ID.
[in]cc_valueCompare value.
[in]p_contextUser context.

◆ nrfx_grtc_rtcomparesync_handler_t

typedef void(* nrfx_grtc_rtcomparesync_handler_t) (void *p_context)

GRTC driver instance RTCOMPARESYNC handler type.

Parameters
[in]p_contextUser context.

◆ nrfx_grtc_syscountervalid_handler_t

typedef void(* nrfx_grtc_syscountervalid_handler_t) (void *p_context)

GRTC driver instance SYSCOUNTER valid handler type.

Parameters
[in]p_contextUser context.

Enumeration Type Documentation

◆ nrfx_grtc_action_t

GRTC action types.

Enumerator
NRFX_GRTC_ACTION_START 

Start the GRTC.

NRFX_GRTC_ACTION_STOP 

Stop the GRTC.

NRFX_GRTC_ACTION_CLEAR 

Clear the GRTC.

◆ nrfx_grtc_cc_relative_reference_t

GRTC compare event relative references.

Enumerator
NRFX_GRTC_CC_RELATIVE_SYSCOUNTER 

The SYSCOUNTER content will be used as the reference.

NRFX_GRTC_CC_RELATIVE_COMPARE 

The corresponding compare register content will be used as the reference.

Function Documentation

◆ nrfx_grtc_action_perform()

nrfx_err_t nrfx_grtc_action_perform ( nrfx_grtc_action_t  action)

Function for performing an action for the GRTC.

Parameters
[in]actionAction to be performed.
Return values
NRFX_SUCCESSStarting was successful.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is running and the operation is not allowed.

◆ nrfx_grtc_active_request_set()

void nrfx_grtc_active_request_set ( bool  active)

Function for requesting the SYSCOUNTER state.

Note
By using this function any domain can prevent SYSCOUNTER from going to sleep state.
Parameters
[in]activeTrue if SYSCOUNTER is to be always kept active, false otherwise.

◆ nrfx_grtc_capture_task_address_get()

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.

Parameters
[in]channelCapture channel number.
Returns
Task address.

◆ nrfx_grtc_channel_alloc()

nrfx_err_t nrfx_grtc_channel_alloc ( uint8_t *  p_channel)

Function for allocating the GRTC capture/compare channel.

Note
Function is thread safe as it uses nrfx_flag32_alloc.
Routines that allocate and free the GRTC channels are independent from the rest of the driver. In particular, the driver does not need to be initialized when this function is called.
Parameters
[out]p_channelPointer to the capture/compare channel.
Return values
NRFX_SUCCESSAllocation was successful.
NRFX_ERROR_NO_MEMNo resource available.

◆ nrfx_grtc_channel_free()

nrfx_err_t nrfx_grtc_channel_free ( uint8_t  channel)

Function for freeing the GRTC capture/compare channel.

Note
Function is thread safe as it uses nrfx_flag32_free.
Routines that allocate and free the GRTC channels are independent from the rest of the driver. In particular, the driver does not need to be initialized when this function is called.
This function also mark specified channel as unused by the driver.
Parameters
[in]channelAllocated channel to be freed.
Return values
NRFX_SUCCESSAllocation was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMChannel is not allocated.

◆ nrfx_grtc_event_address_get()

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.

Parameters
[in]eventGRTC event.
Returns
Event address.

◆ nrfx_grtc_event_compare_address_get()

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.

Parameters
[in]channelCompare channel number.
Returns
Event address.

◆ nrfx_grtc_init()

nrfx_err_t nrfx_grtc_init ( uint8_t  interrupt_priority)

Function for initializing the GRTC.

Parameters
[in]interrupt_priorityInterrupt priority.
Return values
NRFX_SUCCESSInitialization was successful.
NRFX_ERROR_ALREADYThe driver is already initialized.
NRFX_ERROR_INVALID_STATEThe driver is already initialized. Deprecated - use NRFX_ERROR_ALREADY instead.
NRFX_ERROR_INTERNALNo valid channel configuration provided.

◆ nrfx_grtc_init_check()

bool nrfx_grtc_init_check ( void  )

Function for checking if the GRTC driver is initialized.

Return values
trueDriver is already initialized.
falseDriver is not initialized.

◆ nrfx_grtc_is_channel_used()

bool nrfx_grtc_is_channel_used ( uint8_t  channel)

Function for checking whether the specified channel is used by the driver.

Note
Channels marked as used cannot be utilized by external API.
Parameters
[in]channelChannel to be checked.
Return values
trueChannel is used by the driver.
falseChannel is not used by the driver.

◆ nrfx_grtc_rtcomparesync_int_enable()

void nrfx_grtc_rtcomparesync_int_enable ( nrfx_grtc_rtcomparesync_handler_t  handler,
void *  p_context 
)

Function for enabling the RTCOMPARESYNC interrupt.

Parameters
[in]handlerHandler provided by the user. May be NULL.
[in]p_contextUser context.

◆ nrfx_grtc_rtcounter_cc_absolute_set()

nrfx_err_t 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.

Parameters
[in]handler_dataPointer to the handler data instance structure.
[in]valAbsolute value to be set in the compare register.
[in]enable_irqTrue if interrupt is to be enabled, false otherwise.
[in]syncTrue if the internal synchronization mechanism shall be used, false otherwise.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is running and the operation is not allowed.

◆ nrfx_grtc_rtcounter_cc_disable()

nrfx_err_t nrfx_grtc_rtcounter_cc_disable ( void  )

Function for disabling the RTCOUNTER CC channel.

Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is running and the operation is not allowed.
NRFX_ERROR_TIMEOUTRTCOUNTER compare interrupt is pending.

◆ nrfx_grtc_rtcounter_cc_int_enable()

void nrfx_grtc_rtcounter_cc_int_enable ( bool  sync)

Function for enabling the RTCOUNTER compare interrupt.

Parameters
[in]syncTrue if the internal synchronization mechanism shall be used, false otherwise.

◆ nrfx_grtc_rtcounter_get()

NRFX_STATIC_INLINE uint64_t nrfx_grtc_rtcounter_get ( void  )

Function for reading the GRTC RTCOUNTER value.

Returns
RTCOUNTER (32 kHz) value.

◆ nrfx_grtc_sys_counter_cc_enable_check()

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.

Parameters
[in]channelChannel to be checked.
Return values
trueChannel is enabled.
falseChannel is disabled.

◆ nrfx_grtc_syscounter_capture()

nrfx_err_t nrfx_grtc_syscounter_capture ( uint8_t  channel)

Function for triggering the SYSCOUNTER capture task.

Note
This function marks the specified channel as used.
Parameters
[in]channelCapture channel number.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMChannel is not allocated.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_cc_absolute_set()

nrfx_err_t 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.

Note
This function marks the specified channel as used.
Parameters
[in]p_chan_dataPointer to the channel data instance structure.
[in]valAbsolute value to be set in the compare register.
[in]enable_irqTrue if interrupt is to be enabled, false otherwise.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMChannel is not allocated.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_cc_disable()

nrfx_err_t nrfx_grtc_syscounter_cc_disable ( uint8_t  channel)

Function for disabling the SYSCOUNTER CC channel.

Note
This function marks the specified channel as unused.
Parameters
[in]channelChannel to be disabled.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMThe specified channel is either not allocated or marked as unused.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.
NRFX_ERROR_TIMEOUTSYSCOUNTER compare interrupt is pending on the requested channel.

◆ nrfx_grtc_syscounter_cc_int_disable()

nrfx_err_t nrfx_grtc_syscounter_cc_int_disable ( uint8_t  channel)

Function for disabling the SYSCOUNTER compare interrupt.

Parameters
[in]channelCompare channel number.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMThe specified channel is either not allocated or marked as unused.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_cc_int_enable()

nrfx_err_t nrfx_grtc_syscounter_cc_int_enable ( uint8_t  channel)

Function for enabling the SYSCOUNTER compare interrupt.

Note
This function marks the specified channel as used.
Parameters
[in]channelCompare channel number.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMChannel is not allocated.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_cc_int_enable_check()

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.

Parameters
[in]channelCompare channel number.
Return values
trueThe interrupt is enabled for the specified channel.
falseThe interrupt is disabled for the specified channel.

◆ nrfx_grtc_syscounter_cc_relative_set()

nrfx_err_t 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.

Note
This function marks the specified channel as used.
Parameters
[in]p_chan_dataPointer to the channel data instance structure.
[in]valRelative value to be set in the compare register.
[in]enable_irqTrue if interrupt is to be enabled, false otherwise.
[in]referenceReference type to be used.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMChannel is not allocated.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_cc_value_read()

nrfx_err_t 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.

Parameters
[in]channelCapture channel number.
[out]p_valPointer to the variable where the result is to be stored.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_FORBIDDENThe domain is not allowed to use specified channel.
NRFX_ERROR_INVALID_PARAMThe specified channel is either not allocated or marked as unused.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_get()

nrfx_err_t nrfx_grtc_syscounter_get ( uint64_t *  p_counter)

Function for reading the GRTC SYSCOUNTER value.

Parameters
[out]p_counterp_counter Pointer to the variable to be filled with the SYSCOUNTER value.
Return values
NRFX_SUCCESSThe procedure was successful.
NRFX_ERROR_INTERNALThe SYSCOUNTER (1 MHz) is not running.

◆ nrfx_grtc_syscounter_start()

nrfx_err_t nrfx_grtc_syscounter_start ( bool  busy_wait,
uint8_t *  p_main_cc_channel 
)

Function for starting the 1 MHz SYSCOUNTER.

Note
This function automatically allocates and marks as used the special-purpose main capture/compare channel. It is available only for GRTC manager.
Use auxiliary structure of type nrfx_grtc_channel_t when working with SYSCOUNTER.
Parameters
[in]busy_waitTrue if wait for synchronization operation is to be performed, false otherwise.
[out]p_main_cc_channelPointer to the main capture/compare channel.
Return values
NRFX_SUCCESSStarting was successful.
NRFX_ERROR_NO_MEMNo resource available to allocate main channel.
NRFX_ERROR_ALREADYThe GRTC is already running.

◆ nrfx_grtc_syscountervalid_int_enable()

void nrfx_grtc_syscountervalid_int_enable ( nrfx_grtc_syscountervalid_handler_t  handler,
void *  p_context 
)

Function for enabling the SYSCOUNTER valid interrupt.

Parameters
[in]handlerHandler provided by the user. May be NULL.
[in]p_contextUser context.

◆ nrfx_grtc_task_address_get()

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.

Parameters
[in]taskGRTC task.
Returns
Task address.

◆ nrfx_grtc_uninit()

void nrfx_grtc_uninit ( void  )

Function for uninitializing the GRTC.

Note
This function automatically frees all channels used by the driver. It also marks these channels as unused

Documentation feedback | Developer Zone | Subscribe | Updated