nRF51 SDK - S110 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Multi-instance timer driver. More...

Data Structures

struct  nrf_drv_timer_t
 Struct for TIMER instance. More...
 
struct  nrf_drv_timer_config_t
 Struct for TIMER instance configuration. More...
 

Macros

#define NRF_DRV_TIMER_INSTANCE(id)
 
#define TIMER_CONFIG_FREQUENCY(id)   TIMER##id##_CONFIG_FREQUENCY
 
#define TIMER_CONFIG_MODE(id)   TIMER##id##_CONFIG_MODE
 
#define TIMER_CONFIG_BIT_WIDTH(id)   TIMER##id##_CONFIG_BIT_WIDTH
 
#define TIMER_CONFIG_IRQ_PRIORITY(id)   TIMER##id##_CONFIG_IRQ_PRIORITY
 
#define NRF_DRV_TIMER_DEFAULT_CONFIG(id)
 TIMER instance default configuration. More...
 

Typedefs

typedef void(* nrf_timer_event_handler_t )(nrf_timer_events_t event_type)
 

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 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...
 
uint32_t nrf_drv_timer_task_address_get (nrf_drv_timer_t const *const p_instance, nrf_timer_tasks_t timer_task)
 Function for returning the address of a specific timer task. More...
 
uint32_t nrf_drv_timer_event_address_get (nrf_drv_timer_t const *const p_instance, nrf_timer_events_t timer_event)
 Function for returning the address of a specific timer 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...
 
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)
 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_shorts_mask_t timer_short_mask, bool enable)
 Function for setting the timer channel in extended compare mode. More...
 
uint32_t nrf_drv_timer_us_to_ticks (nrf_drv_timer_t const *const p_instance, uint32_t timer_us)
 Function for converting microseconds to ticks. More...
 
uint32_t nrf_drv_timer_ms_to_ticks (nrf_drv_timer_t const *const p_instance, uint32_t timer_ms)
 Function for converting milliseconds to ticks. More...
 

Detailed Description

Multi-instance timer driver.

Macro Definition Documentation

#define NRF_DRV_TIMER_DEFAULT_CONFIG (   id)
Value:
{ \
.frequency = TIMER_CONFIG_FREQUENCY(id), \
.mode = (nrf_timer_mode_t)TIMER_CONFIG_MODE(id), \
.bit_width = (nrf_timer_bit_width_t)TIMER_CONFIG_BIT_WIDTH(id), \
.interrupt_priority = TIMER_CONFIG_IRQ_PRIORITY(id), \
}

TIMER instance default configuration.

#define NRF_DRV_TIMER_INSTANCE (   id)
Value:
{ \
.p_reg = NRF_TIMER##id, \
.irq = TIMER##id##_IRQn, \
.instance_id = TIMER##id##_INSTANCE_INDEX, \
}

Function Documentation

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.

Parameters
[in]p_instanceTimer.
[in]cc_channelChannel.
Return values
Capturedvalue.
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.

Note
Function for reading channel value when PPI is used for capturing.
Parameters
[in]p_instanceTimer.
[in]cc_channelChannel.
Return values
Capturedvalue.
void nrf_drv_timer_clear ( nrf_drv_timer_t const *const  p_instance)

Function for clearing the timer.

Parameters
[in]p_instanceTimer.
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 
)

Function for setting the timer channel in compare mode.

Parameters
[in]p_instanceTimer.
[in]cc_channelChannel.
[in]cc_valueCompare value.
[in]enableEnable or disable the interrupt for the compare channel.
void nrf_drv_timer_disable ( nrf_drv_timer_t const *const  p_instance)

Function for turning off the timer.

Note
Timer will allow to enter lowest possible SYSTEM_ON state only after this function is called.
Parameters
[in]p_instanceTimer.
void nrf_drv_timer_enable ( nrf_drv_timer_t const *const  p_instance)

Function for turning on timer.

Parameters
[in]p_instanceTimer
uint32_t nrf_drv_timer_event_address_get ( nrf_drv_timer_t const *const  p_instance,
nrf_timer_events_t  timer_event 
)

Function for returning the address of a specific timer event.

Parameters
[in]p_instanceTimer.
[in]timer_eventTimer event.
Return values
Eventaddress.
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_shorts_mask_t  timer_short_mask,
bool  enable 
)

Function for setting the timer channel in extended compare mode.

Parameters
[in]p_instanceTimer.
[in]cc_channelChannel.
[in]cc_valueCompare value.
[in]timer_short_maskShortcut between the compare event on the channel and the timer task (STOP or CLEAR).
[in]enableEnable 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.

Parameters
[in]p_instanceTimer.
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.

Parameters
[in]p_instanceTimer.
[in]p_configInitial configuration. Default configuration used if NULL.
[in]timer_event_handlerEvent handler provided by the user.
Return values
NRF_SUCCESSIf initialization was successful.
NRF_ERROR_INVALID_PARAMIf invalid parameters were supplied.
uint32_t nrf_drv_timer_ms_to_ticks ( nrf_drv_timer_t const *const  p_instance,
uint32_t  timer_ms 
)

Function for converting milliseconds to ticks.

Parameters
[in]p_instanceTimer.
[in]timer_msTime in milliseconds.
Return values
Numberof ticks.
void nrf_drv_timer_pause ( nrf_drv_timer_t const *const  p_instance)

Function for pausing the timer.

Parameters
[in]p_instanceTimer
void nrf_drv_timer_resume ( nrf_drv_timer_t const *const  p_instance)

Function for resuming the timer.

Parameters
[in]p_instanceTimer.
uint32_t nrf_drv_timer_task_address_get ( nrf_drv_timer_t const *const  p_instance,
nrf_timer_tasks_t  timer_task 
)

Function for returning the address of a specific timer task.

Parameters
[in]p_instanceTimer.
[in]timer_taskTimer task.
Return values
Taskaddress.
void nrf_drv_timer_uninit ( nrf_drv_timer_t const *const  p_instance)

Function for uninitializing the timer.

Parameters
[in]p_instanceTimer.
uint32_t nrf_drv_timer_us_to_ticks ( nrf_drv_timer_t const *const  p_instance,
uint32_t  timer_us 
)

Function for converting microseconds to ticks.

Parameters
[in]p_instanceTimer.
[in]timer_usTime in microseconds.
Return values
Numberof ticks.