Timer driver

nRF5 SDK v15.0.0

TIMER peripheral driver. More...

Data Structures

struct nrfx_timer_t
Timer driver instance data structure. More...
struct nrfx_timer_config_t
Timer driver instance configuration structure. More...

Macros

#define NRFX_TIMER_INSTANCE (id)
Macro for creating a timer driver instance. More...
#define NRFX_TIMER_DEFAULT_CONFIG
Timer driver instance default configuration. More...

Typedefs

typedef void(* nrfx_timer_event_handler_t )( nrf_timer_event_t event_type, void *p_context)
Timer driver event handler type. More...

Enumerations

enum { NRFX_TIMER_ENABLED_COUNT }

Functions

nrfx_err_t nrfx_timer_init ( nrfx_timer_t const *const p_instance, nrfx_timer_config_t const *p_config, nrfx_timer_event_handler_t timer_event_handler)
Function for initializing the timer. More...
void nrfx_timer_uninit ( nrfx_timer_t const *const p_instance)
Function for uninitializing the timer. More...
void nrfx_timer_enable ( nrfx_timer_t const *const p_instance)
Function for turning on the timer. More...
void nrfx_timer_disable ( nrfx_timer_t const *const p_instance)
Function for turning off the timer. More...
bool nrfx_timer_is_enabled ( nrfx_timer_t const *const p_instance)
Function for checking the timer state. More...
void nrfx_timer_pause ( nrfx_timer_t const *const p_instance)
Function for pausing the timer. More...
void nrfx_timer_resume ( nrfx_timer_t const *const p_instance)
Function for resuming the timer. More...
void nrfx_timer_clear ( nrfx_timer_t const *const p_instance)
Function for clearing the timer. More...
void nrfx_timer_increment ( nrfx_timer_t const *const p_instance)
Function for incrementing the timer. More...
__STATIC_INLINE uint32_t nrfx_timer_task_address_get ( nrfx_timer_t const *const p_instance, nrf_timer_task_t timer_task)
Function for returning the address of a specific timer task. More...
__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get ( nrfx_timer_t const *const p_instance, uint32_t channel)
Function for returning the address of a specific timer capture task. More...
__STATIC_INLINE uint32_t nrfx_timer_event_address_get ( nrfx_timer_t const *const p_instance, nrf_timer_event_t timer_event)
Function for returning the address of a specific timer event. More...
__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get ( nrfx_timer_t const *const p_instance, uint32_t channel)
Function for returning the address of a specific timer compare event. More...
uint32_t nrfx_timer_capture ( nrfx_timer_t const *const p_instance, nrf_timer_cc_channel_t cc_channel)
Function for capturing the timer value. More...
__STATIC_INLINE uint32_t nrfx_timer_capture_get ( nrfx_timer_t const *const p_instance, nrf_timer_cc_channel_t cc_channel)
Function for returning the capture value from a specific channel. More...
void nrfx_timer_compare ( nrfx_timer_t const *const p_instance, nrf_timer_cc_channel_t cc_channel, uint32_t cc_value, bool enable_int)
Function for setting the timer channel in compare mode. More...
void nrfx_timer_extended_compare ( nrfx_timer_t const *const p_instance, nrf_timer_cc_channel_t cc_channel, uint32_t cc_value, nrf_timer_short_mask_t timer_short_mask, bool enable_int)
Function for setting the timer channel in extended compare mode. More...
__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks ( nrfx_timer_t const *const p_instance, uint32_t time_us)
Function for converting time in microseconds to timer ticks. More...
__STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks ( nrfx_timer_t const *const p_instance, uint32_t time_ms)
Function for converting time in milliseconds to timer ticks. More...
void nrfx_timer_compare_int_enable ( nrfx_timer_t const *const p_instance, uint32_t channel)
Function for enabling timer compare interrupt. More...
void nrfx_timer_compare_int_disable ( nrfx_timer_t const *const p_instance, uint32_t channel)
Function for disabling timer compare interrupt. More...
void nrfx_timer_0_irq_handler (void)
void nrfx_timer_1_irq_handler (void)
void nrfx_timer_2_irq_handler (void)
void nrfx_timer_3_irq_handler (void)
void nrfx_timer_4_irq_handler (void)

Detailed Description

TIMER peripheral driver.

Macro Definition Documentation

#define NRFX_TIMER_DEFAULT_CONFIG
Value:

Timer driver instance default configuration.

#define NRFX_TIMER_INSTANCE ( id )
Value:
{ \
.p_reg = NRFX_CONCAT_2 (NRF_TIMER, id ), \
.instance_id = NRFX_CONCAT_3 (NRFX_TIMER, id , _INST_IDX), \
.cc_channel_count = NRF_TIMER_CC_CHANNEL_COUNT ( id ), \
}

Macro for creating a timer driver instance.

Typedef Documentation

typedef void(* nrfx_timer_event_handler_t)( nrf_timer_event_t event_type, void *p_context)

Timer driver event handler type.

Parameters
[in] event_type Timer event.
[in] p_context General purpose parameter set during initialization of the timer. This parameter can be used to pass additional information to the handler function, for example, the timer ID.

Function Documentation

uint32_t nrfx_timer_capture ( nrfx_timer_t const *const p_instance ,
nrf_timer_cc_channel_t cc_channel
)

Function for capturing the timer value.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] cc_channel Capture channel number.
Returns
Captured value.
__STATIC_INLINE uint32_t nrfx_timer_capture_get ( nrfx_timer_t const *const p_instance ,
nrf_timer_cc_channel_t cc_channel
)

Function for returning the capture value from a specific channel.

Use this function to read channel values when PPI is used for capturing.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] cc_channel Capture channel number.
Returns
Captured value.
__STATIC_INLINE uint32_t nrfx_timer_capture_task_address_get ( nrfx_timer_t const *const p_instance ,
uint32_t channel
)

Function for returning the address of a specific timer capture task.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] channel Capture channel number.
Returns
Task address.
void nrfx_timer_clear ( nrfx_timer_t const *const p_instance )

Function for clearing the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
void nrfx_timer_compare ( nrfx_timer_t const *const p_instance ,
nrf_timer_cc_channel_t cc_channel ,
uint32_t cc_value ,
bool enable_int
)

Function for setting the timer channel in compare mode.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] cc_channel Compare channel number.
[in] cc_value Compare value.
[in] enable_int Enable or disable the interrupt for the compare channel.
__STATIC_INLINE uint32_t nrfx_timer_compare_event_address_get ( nrfx_timer_t const *const p_instance ,
uint32_t channel
)

Function for returning the address of a specific timer compare event.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] channel Compare channel number.
Returns
Event address.
void nrfx_timer_compare_int_disable ( nrfx_timer_t const *const p_instance ,
uint32_t channel
)

Function for disabling timer compare interrupt.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] channel Compare channel.
void nrfx_timer_compare_int_enable ( nrfx_timer_t const *const p_instance ,
uint32_t channel
)

Function for enabling timer compare interrupt.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] channel Compare channel.
void nrfx_timer_disable ( nrfx_timer_t const *const p_instance )

Function for turning off the timer.

Note that the timer will allow to enter the lowest possible SYSTEM_ON state only after this function is called.

Parameters
[in] p_instance Pointer to the driver instance structure.
void nrfx_timer_enable ( nrfx_timer_t const *const p_instance )

Function for turning on the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
__STATIC_INLINE uint32_t nrfx_timer_event_address_get ( nrfx_timer_t const *const p_instance ,
nrf_timer_event_t timer_event
)

Function for returning the address of a specific timer event.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] timer_event Timer event.
Returns
Event address.
void nrfx_timer_extended_compare ( nrfx_timer_t const *const p_instance ,
nrf_timer_cc_channel_t cc_channel ,
uint32_t cc_value ,
nrf_timer_short_mask_t timer_short_mask ,
bool enable_int
)

Function for setting the timer channel in extended compare mode.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] cc_channel Compare channel number.
[in] cc_value Compare value.
[in] timer_short_mask Shortcut between the compare event on the channel and the timer task (STOP or CLEAR).
[in] enable_int Enable or disable the interrupt for the compare channel.
void nrfx_timer_increment ( nrfx_timer_t const *const p_instance )

Function for incrementing the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
nrfx_err_t nrfx_timer_init ( nrfx_timer_t const *const p_instance ,
nrfx_timer_config_t const * p_config ,
nrfx_timer_event_handler_t timer_event_handler
)

Function for initializing the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] p_config Pointer to the structure with initial configuration.
[in] timer_event_handler Event handler provided by the user. Must not be NULL.
Return values
NRFX_SUCCESS If initialization was successful.
NRFX_ERROR_INVALID_STATE If the instance is already initialized.
bool nrfx_timer_is_enabled ( nrfx_timer_t const *const p_instance )

Function for checking the timer state.

Parameters
[in] p_instance Pointer to the driver instance structure.
Returns
True if timer is enabled, false otherwise.
__STATIC_INLINE uint32_t nrfx_timer_ms_to_ticks ( nrfx_timer_t const *const p_instance ,
uint32_t time_ms
)

Function for converting time in milliseconds to timer ticks.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] time_ms Time in milliseconds.
Returns
Number of ticks.
void nrfx_timer_pause ( nrfx_timer_t const *const p_instance )

Function for pausing the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
void nrfx_timer_resume ( nrfx_timer_t const *const p_instance )

Function for resuming the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
__STATIC_INLINE uint32_t nrfx_timer_task_address_get ( nrfx_timer_t const *const p_instance ,
nrf_timer_task_t timer_task
)

Function for returning the address of a specific timer task.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] timer_task Timer task.
Returns
Task address.
void nrfx_timer_uninit ( nrfx_timer_t const *const p_instance )

Function for uninitializing the timer.

Parameters
[in] p_instance Pointer to the driver instance structure.
__STATIC_INLINE uint32_t nrfx_timer_us_to_ticks ( nrfx_timer_t const *const p_instance ,
uint32_t time_us
)

Function for converting time in microseconds to timer ticks.

Parameters
[in] p_instance Pointer to the driver instance structure.
[in] time_us Time in microseconds.
Returns
Number of ticks.