Multi-instance timer driver. More...
Modules | |
TIMER periperal driver configuration | |
Data Structures | |
struct | nrf_drv_timer_t |
Timer driver instance data structure. More... | |
struct | nrf_drv_timer_config_t |
Timer driver instance configuration structure. More... | |
Macros | |
#define | ENABLED_TIMER_COUNT (TIMER0_ENABLED+TIMER1_ENABLED+TIMER2_ENABLED+TIMER3_ENABLED+TIMER4_ENABLED) |
#define | TIMER0_INSTANCE_INDEX 0 |
#define | TIMER1_INSTANCE_INDEX TIMER0_INSTANCE_INDEX+TIMER0_ENABLED |
#define | TIMER2_INSTANCE_INDEX TIMER1_INSTANCE_INDEX+TIMER1_ENABLED |
#define | TIMER3_INSTANCE_INDEX TIMER2_INSTANCE_INDEX+TIMER2_ENABLED |
#define | TIMER4_INSTANCE_INDEX TIMER3_INSTANCE_INDEX+TIMER3_ENABLED |
#define | NRF_DRV_TIMER_INSTANCE(id) |
Macro for creating a timer driver instance. More... | |
#define | NRF_DRV_TIMER_DEFAULT_CONFIG |
Timer driver instance default configuration. More... | |
Typedefs | |
typedef void(* | nrf_timer_event_handler_t )(nrf_timer_event_t event_type, void *p_context) |
Timer driver event handler type. More... | |
Functions | |
ret_code_t | nrf_drv_timer_init (nrf_drv_timer_t const *const p_instance, nrf_drv_timer_config_t const *p_config, nrf_timer_event_handler_t timer_event_handler) |
Function for initializing the timer. More... | |
void | nrf_drv_timer_uninit (nrf_drv_timer_t const *const p_instance) |
Function for uninitializing the timer. More... | |
void | nrf_drv_timer_enable (nrf_drv_timer_t const *const p_instance) |
Function for turning on the timer. More... | |
void | nrf_drv_timer_disable (nrf_drv_timer_t const *const p_instance) |
Function for turning off the timer. More... | |
void | nrf_drv_timer_pause (nrf_drv_timer_t const *const p_instance) |
Function for pausing the timer. More... | |
void | nrf_drv_timer_resume (nrf_drv_timer_t const *const p_instance) |
Function for resuming the timer. More... | |
void | nrf_drv_timer_clear (nrf_drv_timer_t const *const p_instance) |
Function for clearing the timer. More... | |
void | nrf_drv_timer_increment (nrf_drv_timer_t const *const p_instance) |
Function for incrementing the timer. More... | |
__STATIC_INLINE uint32_t | nrf_drv_timer_task_address_get (nrf_drv_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 | nrf_drv_timer_capture_task_address_get (nrf_drv_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 | nrf_drv_timer_event_address_get (nrf_drv_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 | nrf_drv_timer_compare_event_address_get (nrf_drv_timer_t const *const p_instance, uint32_t channel) |
Function for returning the address of a specific timer compare event. More... | |
uint32_t | nrf_drv_timer_capture (nrf_drv_timer_t const *const p_instance, nrf_timer_cc_channel_t cc_channel) |
Function for capturing the timer value. More... | |
__STATIC_INLINE uint32_t | nrf_drv_timer_capture_get (nrf_drv_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 | nrf_drv_timer_compare (nrf_drv_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 | nrf_drv_timer_extended_compare (nrf_drv_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 | nrf_drv_timer_us_to_ticks (nrf_drv_timer_t const *const p_instance, uint32_t time_us) |
Function for converting time in microseconds to timer ticks. More... | |
__STATIC_INLINE uint32_t | nrf_drv_timer_ms_to_ticks (nrf_drv_timer_t const *const p_instance, uint32_t time_ms) |
Function for converting time in milliseconds to timer ticks. More... | |
void | nrf_drv_timer_compare_int_enable (nrf_drv_timer_t const *const p_instance, uint32_t channel) |
Function for enabling timer compare interrupt. More... | |
void | nrf_drv_timer_compare_int_disable (nrf_drv_timer_t const *const p_instance, uint32_t channel) |
Function for disabling timer compare interrupt. More... | |
Multi-instance timer driver.
#define NRF_DRV_TIMER_DEFAULT_CONFIG |
Timer driver instance default configuration.
#define NRF_DRV_TIMER_INSTANCE | ( | id | ) |
Macro for creating a timer driver instance.
typedef void(* nrf_timer_event_handler_t)(nrf_timer_event_t event_type, void *p_context) |
Timer driver event handler type.
[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. |
uint32_t nrf_drv_timer_capture | ( | nrf_drv_timer_t const *const | p_instance, |
nrf_timer_cc_channel_t | cc_channel | ||
) |
Function for capturing the timer value.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc_channel | Capture channel number. |
__STATIC_INLINE uint32_t nrf_drv_timer_capture_get | ( | nrf_drv_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.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | cc_channel | Capture channel number. |
__STATIC_INLINE uint32_t nrf_drv_timer_capture_task_address_get | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | channel | ||
) |
Function for returning the address of a specific timer capture task.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | channel | Capture channel number. |
void nrf_drv_timer_clear | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for clearing the timer.
[in] | p_instance | Pointer to the driver instance structure. |
void nrf_drv_timer_compare | ( | nrf_drv_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.
[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 nrf_drv_timer_compare_event_address_get | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | channel | ||
) |
Function for returning the address of a specific timer compare event.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | channel | Compare channel number. |
void nrf_drv_timer_compare_int_disable | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | channel | ||
) |
Function for disabling timer compare interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | channel | Compare channel. |
void nrf_drv_timer_compare_int_enable | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | channel | ||
) |
Function for enabling timer compare interrupt.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | channel | Compare channel. |
void nrf_drv_timer_disable | ( | nrf_drv_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.
[in] | p_instance | Pointer to the driver instance structure. |
void nrf_drv_timer_enable | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for turning on the timer.
[in] | p_instance | Pointer to the driver instance structure. |
__STATIC_INLINE uint32_t nrf_drv_timer_event_address_get | ( | nrf_drv_timer_t const *const | p_instance, |
nrf_timer_event_t | timer_event | ||
) |
Function for returning the address of a specific timer event.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | timer_event | Timer event. |
void nrf_drv_timer_extended_compare | ( | nrf_drv_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.
[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 nrf_drv_timer_increment | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for incrementing the timer.
[in] | p_instance | Pointer to the driver instance structure. |
ret_code_t nrf_drv_timer_init | ( | nrf_drv_timer_t const *const | p_instance, |
nrf_drv_timer_config_t const * | p_config, | ||
nrf_timer_event_handler_t | timer_event_handler | ||
) |
Function for initializing the timer.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | p_config | Initial configuration. Must not be NULL. |
[in] | timer_event_handler | Event handler provided by the user. Must not be NULL. |
NRF_SUCCESS | If initialization was successful. |
NRF_ERROR_INVALID_STATE | If the instance is already initialized. |
NRF_ERROR_INVALID_PARAM | If no handler was provided. |
__STATIC_INLINE uint32_t nrf_drv_timer_ms_to_ticks | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | time_ms | ||
) |
Function for converting time in milliseconds to timer ticks.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | time_ms | Time in milliseconds. |
void nrf_drv_timer_pause | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for pausing the timer.
[in] | p_instance | Pointer to the driver instance structure. |
void nrf_drv_timer_resume | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for resuming the timer.
[in] | p_instance | Pointer to the driver instance structure. |
__STATIC_INLINE uint32_t nrf_drv_timer_task_address_get | ( | nrf_drv_timer_t const *const | p_instance, |
nrf_timer_task_t | timer_task | ||
) |
Function for returning the address of a specific timer task.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | timer_task | Timer task. |
void nrf_drv_timer_uninit | ( | nrf_drv_timer_t const *const | p_instance | ) |
Function for uninitializing the timer.
[in] | p_instance | Pointer to the driver instance structure. |
__STATIC_INLINE uint32_t nrf_drv_timer_us_to_ticks | ( | nrf_drv_timer_t const *const | p_instance, |
uint32_t | time_us | ||
) |
Function for converting time in microseconds to timer ticks.
[in] | p_instance | Pointer to the driver instance structure. |
[in] | time_us | Time in microseconds. |