NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
HAL Timer

Classes

struct  hal_timer
 

Functions

int hal_timer_init (int timer_num, void *cfg)
 
int hal_timer_deinit (int timer_num)
 
int hal_timer_config (int timer_num, uint32_t freq_hz)
 
uint32_t hal_timer_get_resolution (int timer_num)
 
uint32_t hal_timer_read (int timer_num)
 
int hal_timer_delay (int timer_num, uint32_t ticks)
 
int hal_timer_set_cb (int timer_num, struct hal_timer *tmr, hal_timer_cb cb_func, void *arg)
 
int hal_timer_start (struct hal_timer *tmr, uint32_t ticks)
 
int hal_timer_start_at (struct hal_timer *tmr, uint32_t tick)
 
int hal_timer_stop (struct hal_timer *tmr)
 

Detailed Description

Function Documentation

◆ hal_timer_config()

int hal_timer_config ( int  timer_num,
uint32_t  freq_hz 
)

Config a HW timer at the given frequency and start it. If the exact frequency is not obtainable the closest obtainable frequency is set.

Parameters
timer_numThe number of the HW timer to configure
freq_hzThe frequency in Hz to configure the timer at
Returns
0 on success, non-zero error code on failure

hal timer config

Configure a timer to run at the desired frequency. This starts the timer.

Parameters
timer_num
freq_hz
Returns
int

◆ hal_timer_deinit()

int hal_timer_deinit ( int  timer_num)

Un-initialize a HW timer.

Parameters
timer_numThe number of the HW timer to un-initialize

hal timer deinit

De-initialize a HW timer.

Parameters
timer_num
Returns
int

◆ hal_timer_delay()

int hal_timer_delay ( int  timer_num,
uint32_t  ticks 
)

Perform a blocking delay for a number of ticks.

Parameters
timer_numThe timer number to use for the blocking delay
ticksThe number of ticks to delay for
Returns
0 on success, non-zero error code on failure

hal timer delay

Blocking delay for n ticks

Parameters
timer_num
ticks
Returns
int 0 on success; error code otherwise.

◆ hal_timer_get_resolution()

uint32_t hal_timer_get_resolution ( int  timer_num)

Returns the resolution of the HW timer. NOTE: the frequency may not be obtainable so the caller can use this to determine the resolution. Returns resolution in nanoseconds. A return value of 0 indicates an invalid timer was used.

Parameters
timer_numThe number of the HW timer to get resolution for
Returns
The resolution of the timer

hal timer get resolution

Get the resolution of the timer. This is the timer period, in nanoseconds

Parameters
timer_num
Returns
uint32_t The

◆ hal_timer_init()

int hal_timer_init ( int  timer_num,
void *  cfg 
)

Initialize a HW timer.

Parameters
timer_numThe number of the HW timer to initialize
cfgHardware specific timer configuration. This is passed from BSP directly to the MCU specific driver.

hal timer irq handler

Generic HAL timer irq handler.

Parameters
tmrhal timer irq handler

This is the global timer interrupt routine. hal timer init

Initialize platform specific timer items

Parameters
timer_numTimer number to initialize
cfgPointer to platform specific configuration
Returns
int 0: success; error code otherwise

◆ hal_timer_read()

uint32_t hal_timer_read ( int  timer_num)

Returns the HW timer current tick value

Parameters
timer_numThe HW timer to read the tick value from
Returns
The current tick value

hal timer read

Returns the timer counter. NOTE: if the timer is a 16-bit timer, only the lower 16 bits are valid. If the timer is a 64-bit timer, only the low 32-bits are returned.

Returns
uint32_t The timer counter register.

◆ hal_timer_set_cb()

int hal_timer_set_cb ( int  timer_num,
struct hal_timer timer,
hal_timer_cb  cb_func,
void *  arg 
)

Set the timer structure prior to use. Should not be called if the timer is running. Must be called at least once prior to using timer.

Parameters
timer_numThe number of the HW timer to configure the callback on
tmrThe timer structure to use for this timer
cb_funcThe timer callback to call when the timer fires
argAn opaque argument to provide the timer callback
Returns
0 on success, non-zero error code on failure.

Initialize the HAL timer structure with the callback and the callback argument. Also initializes the HW specific timer pointer.

Parameters
cb_func
Returns
int

◆ hal_timer_start()

int hal_timer_start ( struct hal_timer tmr,
uint32_t  ticks 
)

Start a timer that will expire in 'ticks' ticks. Ticks cannot be 0

Parameters
tmrThe timer to start
ticksThe number of ticks to expire the timer in
Returns
0 on success, non-zero error code on failure.

◆ hal_timer_start_at()

int hal_timer_start_at ( struct hal_timer tmr,
uint32_t  tick 
)

Start a timer that will expire when the timer reaches 'tick'. If tick has already passed the timer callback will be called "immediately" (at interrupt context).

Parameters
tmrThe timer to start
tickThe absolute tick value to fire the timer at
Returns
0 on success, non-zero error code on failure.

◆ hal_timer_stop()

int hal_timer_stop ( struct hal_timer timer)

Stop a currently running timer; associated callback will NOT be called

Parameters
tmrThe timer to stop

hal timer stop

Stop a timer.

Parameters
timer
Returns
int