nrfx 2.10
Macros | Enumerations | Functions
TIMER HAL

Hardware access layer for managing the TIMER peripheral. More...

Macros

#define NRF_TIMER_INST_GET(idx)   NRFX_CONCAT_2(NRF_TIMER, idx)
 Macro getting pointer to the structure of registers of the TIMER peripheral. More...
 
#define NRF_TIMER_HAS_CC4   1
 Symbol indicating whether timer has capture/compare channel 4.
 
#define NRF_TIMER_HAS_CC5   1
 Symbol indicating whether timer has capture/compare channel 5.
 
#define NRF_TIMER_HAS_CC6   1
 Symbol indicating whether timer has capture/compare channel 6.
 
#define NRF_TIMER_HAS_CC7   1
 Symbol indicating whether timer has capture/compare channel 7.
 
#define NRF_TIMER_HAS_LOW_POWER_MODE   1
 Symbol indicating whether timer supports low power mode.
 
#define NRF_TIMER_HAS_ONE_SHOT   1
 Symbol indicating whether timer supports one-shot operation.
 
#define NRF_TIMER_BASE_FREQUENCY_16MHZ   (16000000UL)
 Base frequency value 16 MHz for timer.
 
#define NRF_TIMER_PRESCALER_MAX   9
 Maximum value of PRESCALER register.
 
#define TIMER_MAX_SIZE(id)   NRFX_CONCAT_3(TIMER, id, _MAX_SIZE)
 Macro for getting the maximum bit resolution of the specified timer instance. More...
 
#define TIMER_BIT_WIDTH_MAX(id, bit_width)
 Macro for validating the correctness of the bit width resolution setting. More...
 
#define NRF_TIMER_IS_BIT_WIDTH_VALID(p_reg, bit_width)
 Macro for checking correctness of bit width configuration for the specified timer. More...
 
#define NRF_TIMER_BASE_FREQUENCY_GET(p_reg)   NRF_TIMER_BASE_FREQUENCY_16MHZ
 Macro for getting base frequency value in Hz for the specified timer. More...
 
#define NRF_TIMER_PRESCALER_CALCULATE(base_freq, frequency)    NRF_CTZ((uint32_t)(base_freq) / (uint32_t)(frequency))
 Macro for computing prescaler value for given base frequency and desired frequency. More...
 
#define NRF_TIMER_CC_CHANNEL_COUNT(id)   NRFX_CONCAT_3(TIMER, id, _CC_NUM)
 Macro for getting the number of capture/compare channels available in a given timer instance. More...
 
#define NRF_TIMER_CC_COUNT_MAX   NRFX_ARRAY_SIZE(((NRF_TIMER_Type*)0)->EVENTS_COMPARE)
 Symbol specifying maximum number of available compare channels.
 
#define NRF_TIMER_ALL_CHANNELS_INT_MASK    ((uint32_t)((1 << NRF_TIMER_CC_COUNT_MAX) - 1) << TIMER_INTENSET_COMPARE0_Pos)
 Symbol for creating the interrupt bitmask for all compare channels.
 

Enumerations

enum  nrf_timer_task_t {
  NRF_TIMER_TASK_START = offsetof(NRF_TIMER_Type, TASKS_START) ,
  NRF_TIMER_TASK_STOP = offsetof(NRF_TIMER_Type, TASKS_STOP) ,
  NRF_TIMER_TASK_COUNT = offsetof(NRF_TIMER_Type, TASKS_COUNT) ,
  NRF_TIMER_TASK_CLEAR = offsetof(NRF_TIMER_Type, TASKS_CLEAR) ,
  NRF_TIMER_TASK_SHUTDOWN = offsetof(NRF_TIMER_Type, TASKS_SHUTDOWN) ,
  NRF_TIMER_TASK_CAPTURE0 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[0]) ,
  NRF_TIMER_TASK_CAPTURE1 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[1]) ,
  NRF_TIMER_TASK_CAPTURE2 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[2]) ,
  NRF_TIMER_TASK_CAPTURE3 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[3]) ,
  NRF_TIMER_TASK_CAPTURE4 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[4]) ,
  NRF_TIMER_TASK_CAPTURE5 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[5]) ,
  NRF_TIMER_TASK_CAPTURE6 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[6]) ,
  NRF_TIMER_TASK_CAPTURE7 = offsetof(NRF_TIMER_Type, TASKS_CAPTURE[7])
}
 Timer tasks. More...
 
enum  nrf_timer_event_t {
  NRF_TIMER_EVENT_COMPARE0 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[0]) ,
  NRF_TIMER_EVENT_COMPARE1 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[1]) ,
  NRF_TIMER_EVENT_COMPARE2 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[2]) ,
  NRF_TIMER_EVENT_COMPARE3 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[3]) ,
  NRF_TIMER_EVENT_COMPARE4 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[4]) ,
  NRF_TIMER_EVENT_COMPARE5 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[5]) ,
  NRF_TIMER_EVENT_COMPARE6 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[6]) ,
  NRF_TIMER_EVENT_COMPARE7 = offsetof(NRF_TIMER_Type, EVENTS_COMPARE[7])
}
 Timer events. More...
 
enum  nrf_timer_short_mask_t {
  NRF_TIMER_SHORT_COMPARE0_STOP_MASK = TIMER_SHORTS_COMPARE0_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE1_STOP_MASK = TIMER_SHORTS_COMPARE1_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE2_STOP_MASK = TIMER_SHORTS_COMPARE2_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE3_STOP_MASK = TIMER_SHORTS_COMPARE3_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE4_STOP_MASK = TIMER_SHORTS_COMPARE4_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE5_STOP_MASK = TIMER_SHORTS_COMPARE5_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE6_STOP_MASK = TIMER_SHORTS_COMPARE6_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE7_STOP_MASK = TIMER_SHORTS_COMPARE7_STOP_Msk ,
  NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK = TIMER_SHORTS_COMPARE0_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK = TIMER_SHORTS_COMPARE1_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE2_CLEAR_MASK = TIMER_SHORTS_COMPARE2_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK = TIMER_SHORTS_COMPARE3_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE4_CLEAR_MASK = TIMER_SHORTS_COMPARE4_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE5_CLEAR_MASK = TIMER_SHORTS_COMPARE5_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE6_CLEAR_MASK = TIMER_SHORTS_COMPARE6_CLEAR_Msk ,
  NRF_TIMER_SHORT_COMPARE7_CLEAR_MASK = TIMER_SHORTS_COMPARE7_CLEAR_Msk
}
 Types of timer shortcuts. More...
 
enum  nrf_timer_mode_t {
  NRF_TIMER_MODE_TIMER = TIMER_MODE_MODE_Timer ,
  NRF_TIMER_MODE_COUNTER = TIMER_MODE_MODE_Counter ,
  NRF_TIMER_MODE_LOW_POWER_COUNTER = TIMER_MODE_MODE_LowPowerCounter
}
 Timer modes. More...
 
enum  nrf_timer_bit_width_t {
  NRF_TIMER_BIT_WIDTH_8 = TIMER_BITMODE_BITMODE_08Bit ,
  NRF_TIMER_BIT_WIDTH_16 = TIMER_BITMODE_BITMODE_16Bit ,
  NRF_TIMER_BIT_WIDTH_24 = TIMER_BITMODE_BITMODE_24Bit ,
  NRF_TIMER_BIT_WIDTH_32 = TIMER_BITMODE_BITMODE_32Bit
}
 Timer bit width. More...
 
enum  nrf_timer_frequency_t {
  NRF_TIMER_FREQ_16MHz = 0 ,
  NRF_TIMER_FREQ_8MHz ,
  NRF_TIMER_FREQ_4MHz ,
  NRF_TIMER_FREQ_2MHz ,
  NRF_TIMER_FREQ_1MHz ,
  NRF_TIMER_FREQ_500kHz ,
  NRF_TIMER_FREQ_250kHz ,
  NRF_TIMER_FREQ_125kHz ,
  NRF_TIMER_FREQ_62500Hz ,
  NRF_TIMER_FREQ_31250Hz
}
 Timer prescalers. More...
 
enum  nrf_timer_cc_channel_t {
  NRF_TIMER_CC_CHANNEL0 = 0 ,
  NRF_TIMER_CC_CHANNEL1 ,
  NRF_TIMER_CC_CHANNEL2 ,
  NRF_TIMER_CC_CHANNEL3 ,
  NRF_TIMER_CC_CHANNEL4 ,
  NRF_TIMER_CC_CHANNEL5 ,
  NRF_TIMER_CC_CHANNEL6 ,
  NRF_TIMER_CC_CHANNEL7
}
 Timer capture/compare channels. More...
 
enum  nrf_timer_int_mask_t {
  NRF_TIMER_INT_COMPARE0_MASK = TIMER_INTENSET_COMPARE0_Msk ,
  NRF_TIMER_INT_COMPARE1_MASK = TIMER_INTENSET_COMPARE1_Msk ,
  NRF_TIMER_INT_COMPARE2_MASK = TIMER_INTENSET_COMPARE2_Msk ,
  NRF_TIMER_INT_COMPARE3_MASK = TIMER_INTENSET_COMPARE3_Msk ,
  NRF_TIMER_INT_COMPARE4_MASK = TIMER_INTENSET_COMPARE4_Msk ,
  NRF_TIMER_INT_COMPARE5_MASK = TIMER_INTENSET_COMPARE5_Msk ,
  NRF_TIMER_INT_COMPARE6_MASK = TIMER_INTENSET_COMPARE6_Msk ,
  NRF_TIMER_INT_COMPARE7_MASK = TIMER_INTENSET_COMPARE7_Msk
}
 Timer interrupts. More...
 

Functions

NRF_STATIC_INLINE void nrf_timer_prescaler_set (NRF_TIMER_Type *p_reg, uint32_t prescaler_factor)
 Function for setting the prescaler factor. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_prescaler_get (NRF_TIMER_Type const *p_reg)
 Function for retrieving the prescaler factor. More...
 
NRF_STATIC_INLINE void nrf_timer_task_trigger (NRF_TIMER_Type *p_reg, nrf_timer_task_t task)
 Function for activating the specified timer task. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_task_address_get (NRF_TIMER_Type const *p_reg, nrf_timer_task_t task)
 Function for getting the address of the specified timer task register. More...
 
NRF_STATIC_INLINE void nrf_timer_event_clear (NRF_TIMER_Type *p_reg, nrf_timer_event_t event)
 Function for clearing the specified timer event. More...
 
NRF_STATIC_INLINE bool nrf_timer_event_check (NRF_TIMER_Type const *p_reg, nrf_timer_event_t event)
 Function for retrieving the state of the TIMER event. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_event_address_get (NRF_TIMER_Type const *p_reg, nrf_timer_event_t event)
 Function for getting the address of the specified timer event register. More...
 
NRF_STATIC_INLINE void nrf_timer_shorts_enable (NRF_TIMER_Type *p_reg, uint32_t mask)
 Function for enabling the specified shortcuts. More...
 
NRF_STATIC_INLINE void nrf_timer_shorts_disable (NRF_TIMER_Type *p_reg, uint32_t mask)
 Function for disabling the specified shortcuts. More...
 
NRF_STATIC_INLINE void nrf_timer_shorts_set (NRF_TIMER_Type *p_reg, uint32_t mask)
 Function for setting the specified shortcuts. More...
 
NRF_STATIC_INLINE nrf_timer_short_mask_t nrf_timer_short_compare_clear_get (uint8_t channel)
 Function for getting COMPARE_CLEAR short mask for the specified channel. More...
 
NRF_STATIC_INLINE nrf_timer_short_mask_t nrf_timer_short_compare_stop_get (uint8_t channel)
 Function for getting COMPARE_STOP short mask for the specified channel. More...
 
NRF_STATIC_INLINE void nrf_timer_int_enable (NRF_TIMER_Type *p_reg, uint32_t mask)
 Function for enabling the specified interrupts. More...
 
NRF_STATIC_INLINE void nrf_timer_int_disable (NRF_TIMER_Type *p_reg, uint32_t mask)
 Function for disabling the specified interrupts. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check (NRF_TIMER_Type const *p_reg, uint32_t mask)
 Function for checking if the specified interrupts are enabled. More...
 
NRF_STATIC_INLINE void nrf_timer_subscribe_set (NRF_TIMER_Type *p_reg, nrf_timer_task_t task, uint8_t channel)
 Function for setting the subscribe configuration for a given TIMER task. More...
 
NRF_STATIC_INLINE void nrf_timer_subscribe_clear (NRF_TIMER_Type *p_reg, nrf_timer_task_t task)
 Function for clearing the subscribe configuration for a given TIMER task. More...
 
NRF_STATIC_INLINE void nrf_timer_publish_set (NRF_TIMER_Type *p_reg, nrf_timer_event_t event, uint8_t channel)
 Function for setting the publish configuration for a given TIMER event. More...
 
NRF_STATIC_INLINE void nrf_timer_publish_clear (NRF_TIMER_Type *p_reg, nrf_timer_event_t event)
 Function for clearing the publish configuration for a given TIMER event. More...
 
NRF_STATIC_INLINE void nrf_timer_mode_set (NRF_TIMER_Type *p_reg, nrf_timer_mode_t mode)
 Function for setting the timer mode. More...
 
NRF_STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get (NRF_TIMER_Type const *p_reg)
 Function for retrieving the timer mode. More...
 
NRF_STATIC_INLINE void nrf_timer_bit_width_set (NRF_TIMER_Type *p_reg, nrf_timer_bit_width_t bit_width)
 Function for setting the timer bit width. More...
 
NRF_STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get (NRF_TIMER_Type const *p_reg)
 Function for retrieving the timer bit width. More...
 
NRF_STATIC_INLINE void nrf_timer_frequency_set (NRF_TIMER_Type *p_reg, nrf_timer_frequency_t frequency)
 Function for setting the timer frequency. More...
 
NRF_STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get (NRF_TIMER_Type const *p_reg)
 Function for retrieving the timer frequency. More...
 
NRF_STATIC_INLINE void nrf_timer_cc_set (NRF_TIMER_Type *p_reg, nrf_timer_cc_channel_t cc_channel, uint32_t cc_value)
 Function for setting the capture/compare register for the specified channel. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_cc_get (NRF_TIMER_Type const *p_reg, nrf_timer_cc_channel_t cc_channel)
 Function for retrieving the capture/compare value for a specified channel. More...
 
NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get (uint32_t channel)
 Function for getting the specified timer capture task. More...
 
NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get (uint32_t channel)
 Function for getting the specified timer compare event. More...
 
NRF_STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get (uint32_t channel)
 Function for getting the specified timer compare interrupt. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_us_to_ticks (uint32_t time_us, nrf_timer_frequency_t frequency)
 Function for calculating the number of timer ticks for a given time (in microseconds) and timer frequency. More...
 
NRF_STATIC_INLINE uint32_t nrf_timer_ms_to_ticks (uint32_t time_ms, nrf_timer_frequency_t frequency)
 Function for calculating the number of timer ticks for a given time (in milliseconds) and timer frequency. More...
 
NRF_STATIC_INLINE void nrf_timer_one_shot_enable (NRF_TIMER_Type *p_reg, nrf_timer_cc_channel_t cc_channel)
 Function for enabling one-shot operation for the specified capture/compare channel. More...
 
NRF_STATIC_INLINE void nrf_timer_one_shot_disable (NRF_TIMER_Type *p_reg, nrf_timer_cc_channel_t cc_channel)
 Function for disabling one-shot operation for the specified capture/compare channel. More...
 

Detailed Description

Hardware access layer for managing the TIMER peripheral.

Macro Definition Documentation

◆ NRF_TIMER_BASE_FREQUENCY_GET

#define NRF_TIMER_BASE_FREQUENCY_GET (   p_reg)    NRF_TIMER_BASE_FREQUENCY_16MHZ

Macro for getting base frequency value in Hz for the specified timer.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.

◆ NRF_TIMER_CC_CHANNEL_COUNT

#define NRF_TIMER_CC_CHANNEL_COUNT (   id)    NRFX_CONCAT_3(TIMER, id, _CC_NUM)

Macro for getting the number of capture/compare channels available in a given timer instance.

Parameters
[in]idIndex of the specified timer instance.

◆ NRF_TIMER_INST_GET

#define NRF_TIMER_INST_GET (   idx)    NRFX_CONCAT_2(NRF_TIMER, idx)

Macro getting pointer to the structure of registers of the TIMER peripheral.

Parameters
[in]idxTIMER instance index.
Returns
Pointer to the structure of registers of the TIMER peripheral.

◆ NRF_TIMER_IS_BIT_WIDTH_VALID

#define NRF_TIMER_IS_BIT_WIDTH_VALID (   p_reg,
  bit_width 
)
Value:
( \
((p_reg == NRF_TIMER0) && TIMER_BIT_WIDTH_MAX(0, bit_width)) \
|| ((p_reg == NRF_TIMER1) && TIMER_BIT_WIDTH_MAX(1, bit_width)) \
|| ((p_reg == NRF_TIMER2) && TIMER_BIT_WIDTH_MAX(2, bit_width)))
#define TIMER_BIT_WIDTH_MAX(id, bit_width)
Macro for validating the correctness of the bit width resolution setting.
Definition: nrf_timer.h:94

Macro for checking correctness of bit width configuration for the specified timer.

Parameters
[in]p_regTimer instance register.
[in]bit_widthBit width resolution value to be checked.
Return values
trueTimer instance supports the specified bit width resolution value.
falseTimer instance does not support the specified bit width resolution value.

◆ NRF_TIMER_PRESCALER_CALCULATE

#define NRF_TIMER_PRESCALER_CALCULATE (   base_freq,
  frequency 
)     NRF_CTZ((uint32_t)(base_freq) / (uint32_t)(frequency))

Macro for computing prescaler value for given base frequency and desired frequency.

Warning
Not every combination of base frequency and desired frequency is supported.
Parameters
[in]base_freqBase clock frequency for timer in Hz.
[in]frequencyDesired frequency value in Hz.

◆ TIMER_BIT_WIDTH_MAX

#define TIMER_BIT_WIDTH_MAX (   id,
  bit_width 
)
Value:
(TIMER_MAX_SIZE(id) == 8 ? (bit_width == NRF_TIMER_BIT_WIDTH_8) : \
(TIMER_MAX_SIZE(id) == 16 ? (bit_width == NRF_TIMER_BIT_WIDTH_8) || \
(bit_width == NRF_TIMER_BIT_WIDTH_16) : \
(TIMER_MAX_SIZE(id) == 24 ? (bit_width == NRF_TIMER_BIT_WIDTH_8) || \
(bit_width == NRF_TIMER_BIT_WIDTH_16) || \
(bit_width == NRF_TIMER_BIT_WIDTH_24) : \
(TIMER_MAX_SIZE(id) == 32 ? (bit_width == NRF_TIMER_BIT_WIDTH_8) || \
(bit_width == NRF_TIMER_BIT_WIDTH_16) || \
(bit_width == NRF_TIMER_BIT_WIDTH_24) || \
(bit_width == NRF_TIMER_BIT_WIDTH_32) : \
false))))
#define TIMER_MAX_SIZE(id)
Macro for getting the maximum bit resolution of the specified timer instance.
Definition: nrf_timer.h:83
@ NRF_TIMER_BIT_WIDTH_16
Timer bit width 16 bit.
Definition: nrf_timer.h:269
@ NRF_TIMER_BIT_WIDTH_24
Timer bit width 24 bit.
Definition: nrf_timer.h:270
@ NRF_TIMER_BIT_WIDTH_8
Timer bit width 8 bit.
Definition: nrf_timer.h:268
@ NRF_TIMER_BIT_WIDTH_32
Timer bit width 32 bit.
Definition: nrf_timer.h:271

Macro for validating the correctness of the bit width resolution setting.

Parameters
[in]idIndex of the specified timer instance.
[in]bit_widthBit width resolution value to be checked.
Return values
trueTimer instance supports the specified bit width resolution value.
falseTimer instance does not support the specified bit width resolution value.

◆ TIMER_MAX_SIZE

#define TIMER_MAX_SIZE (   id)    NRFX_CONCAT_3(TIMER, id, _MAX_SIZE)

Macro for getting the maximum bit resolution of the specified timer instance.

Parameters
[in]idIndex of the specified timer instance.
Return values
Maximumbit resolution of the specified timer instance.

Enumeration Type Documentation

◆ nrf_timer_bit_width_t

Timer bit width.

Enumerator
NRF_TIMER_BIT_WIDTH_8 

Timer bit width 8 bit.

NRF_TIMER_BIT_WIDTH_16 

Timer bit width 16 bit.

NRF_TIMER_BIT_WIDTH_24 

Timer bit width 24 bit.

NRF_TIMER_BIT_WIDTH_32 

Timer bit width 32 bit.

◆ nrf_timer_cc_channel_t

Timer capture/compare channels.

Enumerator
NRF_TIMER_CC_CHANNEL0 

Timer capture/compare channel 0.

NRF_TIMER_CC_CHANNEL1 

Timer capture/compare channel 1.

NRF_TIMER_CC_CHANNEL2 

Timer capture/compare channel 2.

NRF_TIMER_CC_CHANNEL3 

Timer capture/compare channel 3.

NRF_TIMER_CC_CHANNEL4 

Timer capture/compare channel 4.

NRF_TIMER_CC_CHANNEL5 

Timer capture/compare channel 5.

NRF_TIMER_CC_CHANNEL6 

Timer capture/compare channel 6.

NRF_TIMER_CC_CHANNEL7 

Timer capture/compare channel 7.

◆ nrf_timer_event_t

Timer events.

Enumerator
NRF_TIMER_EVENT_COMPARE0 

Event from compare channel 0.

NRF_TIMER_EVENT_COMPARE1 

Event from compare channel 1.

NRF_TIMER_EVENT_COMPARE2 

Event from compare channel 2.

NRF_TIMER_EVENT_COMPARE3 

Event from compare channel 3.

NRF_TIMER_EVENT_COMPARE4 

Event from compare channel 4.

NRF_TIMER_EVENT_COMPARE5 

Event from compare channel 5.

NRF_TIMER_EVENT_COMPARE6 

Event from compare channel 6.

NRF_TIMER_EVENT_COMPARE7 

Event from compare channel 7.

◆ nrf_timer_frequency_t

Timer prescalers.

Enumerator
NRF_TIMER_FREQ_16MHz 

Timer frequency 16 MHz.

NRF_TIMER_FREQ_8MHz 

Timer frequency 8 MHz.

NRF_TIMER_FREQ_4MHz 

Timer frequency 4 MHz.

NRF_TIMER_FREQ_2MHz 

Timer frequency 2 MHz.

NRF_TIMER_FREQ_1MHz 

Timer frequency 1 MHz.

NRF_TIMER_FREQ_500kHz 

Timer frequency 500 kHz.

NRF_TIMER_FREQ_250kHz 

Timer frequency 250 kHz.

NRF_TIMER_FREQ_125kHz 

Timer frequency 125 kHz.

NRF_TIMER_FREQ_62500Hz 

Timer frequency 62500 Hz.

NRF_TIMER_FREQ_31250Hz 

Timer frequency 31250 Hz.

◆ nrf_timer_int_mask_t

Timer interrupts.

Enumerator
NRF_TIMER_INT_COMPARE0_MASK 

Timer interrupt from compare event on channel 0.

NRF_TIMER_INT_COMPARE1_MASK 

Timer interrupt from compare event on channel 1.

NRF_TIMER_INT_COMPARE2_MASK 

Timer interrupt from compare event on channel 2.

NRF_TIMER_INT_COMPARE3_MASK 

Timer interrupt from compare event on channel 3.

NRF_TIMER_INT_COMPARE4_MASK 

Timer interrupt from compare event on channel 4.

NRF_TIMER_INT_COMPARE5_MASK 

Timer interrupt from compare event on channel 5.

NRF_TIMER_INT_COMPARE6_MASK 

Timer interrupt from compare event on channel 6.

NRF_TIMER_INT_COMPARE7_MASK 

Timer interrupt from compare event on channel 7.

◆ nrf_timer_mode_t

Timer modes.

Enumerator
NRF_TIMER_MODE_TIMER 

Timer mode: timer.

NRF_TIMER_MODE_COUNTER 

Timer mode: counter.

NRF_TIMER_MODE_LOW_POWER_COUNTER 

Timer mode: low-power counter.

◆ nrf_timer_short_mask_t

Types of timer shortcuts.

Enumerator
NRF_TIMER_SHORT_COMPARE0_STOP_MASK 

Shortcut for stopping the timer based on compare 0.

NRF_TIMER_SHORT_COMPARE1_STOP_MASK 

Shortcut for stopping the timer based on compare 1.

NRF_TIMER_SHORT_COMPARE2_STOP_MASK 

Shortcut for stopping the timer based on compare 2.

NRF_TIMER_SHORT_COMPARE3_STOP_MASK 

Shortcut for stopping the timer based on compare 3.

NRF_TIMER_SHORT_COMPARE4_STOP_MASK 

Shortcut for stopping the timer based on compare 4.

NRF_TIMER_SHORT_COMPARE5_STOP_MASK 

Shortcut for stopping the timer based on compare 5.

NRF_TIMER_SHORT_COMPARE6_STOP_MASK 

Shortcut for stopping the timer based on compare 6.

NRF_TIMER_SHORT_COMPARE7_STOP_MASK 

Shortcut for stopping the timer based on compare 7.

NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK 

Shortcut for clearing the timer based on compare 0.

NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK 

Shortcut for clearing the timer based on compare 1.

NRF_TIMER_SHORT_COMPARE2_CLEAR_MASK 

Shortcut for clearing the timer based on compare 2.

NRF_TIMER_SHORT_COMPARE3_CLEAR_MASK 

Shortcut for clearing the timer based on compare 3.

NRF_TIMER_SHORT_COMPARE4_CLEAR_MASK 

Shortcut for clearing the timer based on compare 4.

NRF_TIMER_SHORT_COMPARE5_CLEAR_MASK 

Shortcut for clearing the timer based on compare 5.

NRF_TIMER_SHORT_COMPARE6_CLEAR_MASK 

Shortcut for clearing the timer based on compare 6.

NRF_TIMER_SHORT_COMPARE7_CLEAR_MASK 

Shortcut for clearing the timer based on compare 7.

◆ nrf_timer_task_t

Timer tasks.

Enumerator
NRF_TIMER_TASK_START 

Task for starting the timer.

NRF_TIMER_TASK_STOP 

Task for stopping the timer.

NRF_TIMER_TASK_COUNT 

Task for incrementing the timer (in counter mode).

NRF_TIMER_TASK_CLEAR 

Task for resetting the timer value.

NRF_TIMER_TASK_SHUTDOWN 

Task for powering off the timer.

NRF_TIMER_TASK_CAPTURE0 

Task for capturing the timer value on channel 0.

NRF_TIMER_TASK_CAPTURE1 

Task for capturing the timer value on channel 1.

NRF_TIMER_TASK_CAPTURE2 

Task for capturing the timer value on channel 2.

NRF_TIMER_TASK_CAPTURE3 

Task for capturing the timer value on channel 3.

NRF_TIMER_TASK_CAPTURE4 

Task for capturing the timer value on channel 4.

NRF_TIMER_TASK_CAPTURE5 

Task for capturing the timer value on channel 5.

NRF_TIMER_TASK_CAPTURE6 

Task for capturing the timer value on channel 6.

NRF_TIMER_TASK_CAPTURE7 

Task for capturing the timer value on channel 7.

Function Documentation

◆ nrf_timer_bit_width_get()

NRF_STATIC_INLINE nrf_timer_bit_width_t nrf_timer_bit_width_get ( NRF_TIMER_Type const *  p_reg)

Function for retrieving the timer bit width.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Timer bit width.

◆ nrf_timer_bit_width_set()

NRF_STATIC_INLINE void nrf_timer_bit_width_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_bit_width_t  bit_width 
)

Function for setting the timer bit width.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]bit_widthTimer bit width.

◆ nrf_timer_capture_task_get()

NRF_STATIC_INLINE nrf_timer_task_t nrf_timer_capture_task_get ( uint32_t  channel)

Function for getting the specified timer capture task.

Parameters
[in]channelCapture channel.
Returns
Capture task.

◆ nrf_timer_cc_get()

NRF_STATIC_INLINE uint32_t nrf_timer_cc_get ( NRF_TIMER_Type const *  p_reg,
nrf_timer_cc_channel_t  cc_channel 
)

Function for retrieving the capture/compare value for a specified channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]cc_channelThe specified capture/compare channel.
Returns
Value from the specified capture/compare register.

◆ nrf_timer_cc_set()

NRF_STATIC_INLINE void nrf_timer_cc_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_cc_channel_t  cc_channel,
uint32_t  cc_value 
)

Function for setting the capture/compare register for the specified channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]cc_channelThe specified capture/compare channel.
[in]cc_valueValue to write to the capture/compare register.

◆ nrf_timer_compare_event_get()

NRF_STATIC_INLINE nrf_timer_event_t nrf_timer_compare_event_get ( uint32_t  channel)

Function for getting the specified timer compare event.

Parameters
[in]channelCompare channel.
Returns
Compare event.

◆ nrf_timer_compare_int_get()

NRF_STATIC_INLINE nrf_timer_int_mask_t nrf_timer_compare_int_get ( uint32_t  channel)

Function for getting the specified timer compare interrupt.

Parameters
[in]channelCompare channel.
Returns
Compare interrupt.

◆ nrf_timer_event_address_get()

NRF_STATIC_INLINE uint32_t nrf_timer_event_address_get ( NRF_TIMER_Type const *  p_reg,
nrf_timer_event_t  event 
)

Function for getting the address of the specified timer event register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventThe specified event.
Returns
Address of the specified event register.

◆ nrf_timer_event_check()

NRF_STATIC_INLINE bool nrf_timer_event_check ( NRF_TIMER_Type const *  p_reg,
nrf_timer_event_t  event 
)

Function for retrieving the state of the TIMER event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to be checked.
Return values
trueThe event has been generated.
falseThe event has not been generated.

◆ nrf_timer_event_clear()

NRF_STATIC_INLINE void nrf_timer_event_clear ( NRF_TIMER_Type *  p_reg,
nrf_timer_event_t  event 
)

Function for clearing the specified timer event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent to clear.

◆ nrf_timer_frequency_get()

NRF_STATIC_INLINE nrf_timer_frequency_t nrf_timer_frequency_get ( NRF_TIMER_Type const *  p_reg)

Function for retrieving the timer frequency.

Note
This function is deprecated. Use nrf_timer_prescaler_get instead.
Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Timer frequency.

◆ nrf_timer_frequency_set()

NRF_STATIC_INLINE void nrf_timer_frequency_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_frequency_t  frequency 
)

Function for setting the timer frequency.

Note
This function is deprecated. Use nrf_timer_prescaler_set instead.
Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]frequencyTimer frequency.

◆ nrf_timer_int_disable()

NRF_STATIC_INLINE void nrf_timer_int_disable ( NRF_TIMER_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be disabled.

◆ nrf_timer_int_enable()

NRF_STATIC_INLINE void nrf_timer_int_enable ( NRF_TIMER_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified interrupts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be enabled.

◆ nrf_timer_int_enable_check()

NRF_STATIC_INLINE uint32_t nrf_timer_int_enable_check ( NRF_TIMER_Type const *  p_reg,
uint32_t  mask 
)

Function for checking if the specified interrupts are enabled.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskMask of interrupts to be checked.
Returns
Mask of enabled interrupts.

◆ nrf_timer_mode_get()

NRF_STATIC_INLINE nrf_timer_mode_t nrf_timer_mode_get ( NRF_TIMER_Type const *  p_reg)

Function for retrieving the timer mode.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Timer mode.

◆ nrf_timer_mode_set()

NRF_STATIC_INLINE void nrf_timer_mode_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_mode_t  mode 
)

Function for setting the timer mode.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]modeTimer mode.

◆ nrf_timer_ms_to_ticks()

NRF_STATIC_INLINE uint32_t nrf_timer_ms_to_ticks ( uint32_t  time_ms,
nrf_timer_frequency_t  frequency 
)

Function for calculating the number of timer ticks for a given time (in milliseconds) and timer frequency.

Parameters
[in]time_msTime in milliseconds.
[in]frequencyTimer frequency.
Returns
Number of timer ticks.

◆ nrf_timer_one_shot_disable()

NRF_STATIC_INLINE void nrf_timer_one_shot_disable ( NRF_TIMER_Type *  p_reg,
nrf_timer_cc_channel_t  cc_channel 
)

Function for disabling one-shot operation for the specified capture/compare channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]cc_channelCapture/compare channel.

◆ nrf_timer_one_shot_enable()

NRF_STATIC_INLINE void nrf_timer_one_shot_enable ( NRF_TIMER_Type *  p_reg,
nrf_timer_cc_channel_t  cc_channel 
)

Function for enabling one-shot operation for the specified capture/compare channel.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]cc_channelCapture/compare channel.

◆ nrf_timer_prescaler_get()

NRF_STATIC_INLINE uint32_t nrf_timer_prescaler_get ( NRF_TIMER_Type const *  p_reg)

Function for retrieving the prescaler factor.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
Returns
Prescaler factor.

◆ nrf_timer_prescaler_set()

NRF_STATIC_INLINE void nrf_timer_prescaler_set ( NRF_TIMER_Type *  p_reg,
uint32_t  prescaler_factor 
)

Function for setting the prescaler factor.

Note
Prescaler value is expressed as \( 2^{prescaler\_factor} \).
Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]prescaler_factorPrescaler factor.

◆ nrf_timer_publish_clear()

NRF_STATIC_INLINE void nrf_timer_publish_clear ( NRF_TIMER_Type *  p_reg,
nrf_timer_event_t  event 
)

Function for clearing the publish configuration for a given TIMER event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to clear the configuration.

◆ nrf_timer_publish_set()

NRF_STATIC_INLINE void nrf_timer_publish_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_event_t  event,
uint8_t  channel 
)

Function for setting the publish configuration for a given TIMER event.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]eventEvent for which to set the configuration.
[in]channelChannel through which to publish the event.

◆ nrf_timer_short_compare_clear_get()

NRF_STATIC_INLINE nrf_timer_short_mask_t nrf_timer_short_compare_clear_get ( uint8_t  channel)

Function for getting COMPARE_CLEAR short mask for the specified channel.

Parameters
[in]channelChannel.
Returns
Short mask.

◆ nrf_timer_short_compare_stop_get()

NRF_STATIC_INLINE nrf_timer_short_mask_t nrf_timer_short_compare_stop_get ( uint8_t  channel)

Function for getting COMPARE_STOP short mask for the specified channel.

Parameters
[in]channelChannel.
Returns
Short mask.

◆ nrf_timer_shorts_disable()

NRF_STATIC_INLINE void nrf_timer_shorts_disable ( NRF_TIMER_Type *  p_reg,
uint32_t  mask 
)

Function for disabling the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskShortcuts to be disabled.

◆ nrf_timer_shorts_enable()

NRF_STATIC_INLINE void nrf_timer_shorts_enable ( NRF_TIMER_Type *  p_reg,
uint32_t  mask 
)

Function for enabling the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskShortcuts to be enabled.

◆ nrf_timer_shorts_set()

NRF_STATIC_INLINE void nrf_timer_shorts_set ( NRF_TIMER_Type *  p_reg,
uint32_t  mask 
)

Function for setting the specified shortcuts.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]maskShortcuts to be set.

◆ nrf_timer_subscribe_clear()

NRF_STATIC_INLINE void nrf_timer_subscribe_clear ( NRF_TIMER_Type *  p_reg,
nrf_timer_task_t  task 
)

Function for clearing the subscribe configuration for a given TIMER task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to clear the configuration.

◆ nrf_timer_subscribe_set()

NRF_STATIC_INLINE void nrf_timer_subscribe_set ( NRF_TIMER_Type *  p_reg,
nrf_timer_task_t  task,
uint8_t  channel 
)

Function for setting the subscribe configuration for a given TIMER task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask for which to set the configuration.
[in]channelChannel through which to subscribe events.

◆ nrf_timer_task_address_get()

NRF_STATIC_INLINE uint32_t nrf_timer_task_address_get ( NRF_TIMER_Type const *  p_reg,
nrf_timer_task_t  task 
)

Function for getting the address of the specified timer task register.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskThe specified task.
Returns
Address of the specified task register.

◆ nrf_timer_task_trigger()

NRF_STATIC_INLINE void nrf_timer_task_trigger ( NRF_TIMER_Type *  p_reg,
nrf_timer_task_t  task 
)

Function for activating the specified timer task.

Parameters
[in]p_regPointer to the structure of registers of the peripheral.
[in]taskTask to be activated.

◆ nrf_timer_us_to_ticks()

NRF_STATIC_INLINE uint32_t nrf_timer_us_to_ticks ( uint32_t  time_us,
nrf_timer_frequency_t  frequency 
)

Function for calculating the number of timer ticks for a given time (in microseconds) and timer frequency.

Parameters
[in]time_usTime in microseconds.
[in]frequencyTimer frequency.
Returns
Number of timer ticks.

Documentation feedback | Developer Zone | Subscribe | Updated