nRF5 SDK v15.3.0
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Timer driver

TIMER peripheral driver. More...

Modules

 TIMER periperal driver configuration
 

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_typeTimer event.
[in]p_contextGeneral 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_instancePointer to the driver instance structure.
[in]cc_channelCapture 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_instancePointer to the driver instance structure.
[in]cc_channelCapture 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_instancePointer to the driver instance structure.
[in]channelCapture channel number.
Returns
Task address.
void nrfx_timer_clear ( nrfx_timer_t const *const  p_instance)

Function for clearing the timer.

Parameters
[in]p_instancePointer 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_instancePointer to the driver instance structure.
[in]cc_channelCompare channel number.
[in]cc_valueCompare value.
[in]enable_intEnable 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_instancePointer to the driver instance structure.
[in]channelCompare 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_instancePointer to the driver instance structure.
[in]channelCompare 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_instancePointer to the driver instance structure.
[in]channelCompare 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_instancePointer 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_instancePointer 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_instancePointer to the driver instance structure.
[in]timer_eventTimer 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_instancePointer to the driver instance structure.
[in]cc_channelCompare channel number.
[in]cc_valueCompare value.
[in]timer_short_maskShortcut between the compare event on the channel and the timer task (STOP or CLEAR).
[in]enable_intEnable 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_instancePointer 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_instancePointer to the driver instance structure.
[in]p_configPointer to the structure with initial configuration.
[in]timer_event_handlerEvent handler provided by the user. Must not be NULL.
Return values
NRFX_SUCCESSIf initialization was successful.
NRFX_ERROR_INVALID_STATEIf 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_instancePointer 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_instancePointer to the driver instance structure.
[in]time_msTime 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_instancePointer to the driver instance structure.
void nrfx_timer_resume ( nrfx_timer_t const *const  p_instance)

Function for resuming the timer.

Parameters
[in]p_instancePointer 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_instancePointer to the driver instance structure.
[in]timer_taskTimer task.
Returns
Task address.
void nrfx_timer_uninit ( nrfx_timer_t const *const  p_instance)

Function for uninitializing the timer.

Parameters
[in]p_instancePointer 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_instancePointer to the driver instance structure.
[in]time_usTime in microseconds.
Returns
Number of ticks.

Documentation feedback | Developer Zone | Subscribe | Updated