InPlay API
timer driver

HAL_TIM. More...

Enumerations

enum  tmr_id
 Timer Id.
 
enum  cap_id
 Timer Signal Capture Id.
 
enum  emit_id
 Timer Emit Id.
 
enum  tmr_err
 (Aon) Timer error code
 

Functions

int hal_timer_busy (void)
 Check if any timer is active. More...
 
int hal_timer_set_tmo_callback (int tmr_id, int prio, void *arg, void(*tmr_cb)(void *))
 rigster Timer timeout callback function More...
 
int hal_timer_start (int tmr_id, int reload, int manual, uint32_t tick)
 Run Timer periodic function. More...
 
int hal_timer_stop (int tim_id)
 Stop Timer periodic function. More...
 
int hal_timer_start_tick (int tim_id)
 start timer profile function More...
 
uint32_t hal_timer_get_tick (int tim_id)
 timer get current tick function. More...
 
int hal_timer_end_tick (int tim_id)
 timer tick stop function. More...
 
int hal_timer_delay_us (int tim_id, uint32_t usec)
 timer delaye function More...
 
uint32_t hal_timer_get_systick (void)
 Return the OS tick. More...
 
int hal_timer_capture_signal_add (int tmr_id, int idx, uint8_t sig_id, int rise, int fall)
 Add HW signal to the timer's capture list. More...
 
int hal_timer_capture_signal_rem (int tmr_id, int idx)
 Remove HW signal from the timer's capture list. More...
 
int hal_timer_emit_set_callback (int tmr_id, int prio, void *arg, void(*callback)(void *parg, int emit_idx))
 Set emit IRQ handler callback for the timer's emit. More...
 
int hal_timer_emit_add (int tmr_id, int idx, uint32_t tick, tmr_emit_option_t *option)
 Add HW trigger to the timer's trigger list. More...
 
int hal_timer_emit_rem (int tmr_id, int idx)
 Remove HW trigger from the timer's trigger list. More...
 
int hal_timer_smem_emit_add (int tmr_id, uint32_t *ticks, uint32_t size, uint16_t empty_threshold, tmr_emit_option_t *option)
 Add HW trigger to the timer's trigger list. More...
 
int hal_aon_timer_open (int id, int wup_en, int reload, int prio, void *arg, void(*isr_cb)(void *arg))
 Open sleep timer. More...
 
int hal_aon_timer_close (int id)
 Close sleep timer. More...
 
int hal_aon_timer_start (int id, uint64_t time_us)
 Start sleep timer. More...
 
int hal_aon_timer_stop (int id)
 Stop sleep timer. More...
 
uint64_t hal_aon_timer_get_tick (int id)
 Get the current sleep timer tick. More...
 
uint64_t hal_aon_timer_get_time (int id)
 Get the current sleep timer time in microsecond. More...
 
int hal_aon_timer_emit_add (int emit_id, int auto_clr, int touch_clr, uint32_t time_us, int prio, void *arg, void(*callback)(void *))
 Add HW trigger to the AON timer2's trigger list. More...
 
int hal_aon_timer_emit_rem (int emit_id)
 Remove HW trigger from the AON timer2's trigger list. More...
 
int hal_aon_timer_capture_add (int cap_id, uint8_t sig_id, int rise, int fall, int prio, void *arg, void(*callback)(void *, int, uint32_t))
 Add HW trigger to the AON timer2's trigger list. More...
 
int hal_aon_timer_capture_rem (int cap_id)
 Remove HW trigger from the AON timer2's trigger list. More...
 

Detailed Description

HAL_TIM.

Function Documentation

◆ hal_aon_timer_capture_add()

int hal_aon_timer_capture_add ( int  cap_id,
uint8_t  sig_id,
int  rise,
int  fall,
int  prio,
void *  arg,
void(*)(void *, int, uint32_t)  callback 
)

Add HW trigger to the AON timer2's trigger list.

Parameters
[in]emit_id
See also
enum aon_emit_id
Parameters
[in]auto_clrClear the emit signal automatically
[in]touch_clrClear the emit signal by write to touch register
[in]time_usTrigger happens on AON timer2's value (tick)
[in]argUser provided argument for the emit callback
[in]callbackPointer to user's provided call back function.
Returns
See also
enum tim_err

◆ hal_aon_timer_capture_rem()

int hal_aon_timer_capture_rem ( int  cap_id)

Remove HW trigger from the AON timer2's trigger list.

Parameters
[in]emit_id
See also
enum aon_emit_id
Returns
See also
enum tim_err

◆ hal_aon_timer_close()

int hal_aon_timer_close ( int  id)

Close sleep timer.

Parameters
[in]idAON timer Id,
See also
enum aon_tmr_id
Returns
See also
enum tim_err

◆ hal_aon_timer_emit_add()

int hal_aon_timer_emit_add ( int  emit_id,
int  auto_clr,
int  touch_clr,
uint32_t  time_us,
int  prio,
void *  arg,
void(*)(void *)  callback 
)

Add HW trigger to the AON timer2's trigger list.

Parameters
[in]emit_id
See also
enum aon_emit_id
Parameters
[in]auto_clrClear the emit signal automatically
[in]touch_clrClear the emit signal by write to touch register
[in]time_usTrigger happens on AON timer2's value (tick)
[in]argUser provided argument for the emit callback
[in]callbackPointer to user's provided call back function.
Returns
See also
enum tim_err

◆ hal_aon_timer_emit_rem()

int hal_aon_timer_emit_rem ( int  emit_id)

Remove HW trigger from the AON timer2's trigger list.

Parameters
[in]emit_id
See also
enum aon_emit_id
Returns
See also
enum tim_err

◆ hal_aon_timer_get_tick()

uint64_t hal_aon_timer_get_tick ( int  id)

Get the current sleep timer tick.

Parameters
[in]idAON timer Id,
See also
enum aon_timer_id
Returns
current sleep timer tcik

◆ hal_aon_timer_get_time()

uint64_t hal_aon_timer_get_time ( int  id)

Get the current sleep timer time in microsecond.

Parameters
[in]idAON timer Id,
See also
enum aon_timer_id
Returns
current sleep timer tcik

◆ hal_aon_timer_open()

int hal_aon_timer_open ( int  id,
int  wup_en,
int  reload,
int  prio,
void *  arg,
void(*)(void *arg)  isr_cb 
)

Open sleep timer.

Parameters
[in]idAON timer Id,
See also
enum aon_tmr_id
Parameters
[in]wup_en1: AON timer can wake up system; 0: Otherwise
[in]reload1: AON timer can reload initial value; 0: Otherwise
[in]prioInterrupt priority
[in]argCall back function argument
[in]isr_cbTimes up call back (Note: from interrupt context)
Returns
See also
enum tim_err

◆ hal_aon_timer_start()

int hal_aon_timer_start ( int  id,
uint64_t  time_us 
)

Start sleep timer.

Parameters
[in]idAON timer Id,
See also
enum aon_tmr_id
Parameters
[in]time_usSleep time in micro second unit: a. Timer 0,1,and2 is oxffffffff (32 bits)
b. Timer 3 is 0xffffffffffffff (64 bits)
Returns
See also
enum tim_err

◆ hal_aon_timer_stop()

int hal_aon_timer_stop ( int  id)

Stop sleep timer.

Parameters
[in]idAON timer Id,
See also
enum aon_tmr_id
Returns
See also
enum tim_err

◆ hal_timer_busy()

int hal_timer_busy ( void  )

Check if any timer is active.

Returns
1: timer is active; 0: otherwise.

◆ hal_timer_capture_signal_add()

int hal_timer_capture_signal_add ( int  tmr_id,
int  idx,
uint8_t  sig_id,
int  rise,
int  fall 
)

Add HW signal to the timer's capture list.

Note
Only timer 0 and 1 can support capture
Each timer can capture at most 4 HW signal
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]idxThe index for the current capture, possible values are 0, 1, 2, 3
[in]sig_idThe HW signal ID,
See also
in_trig_defs.h
Parameters
[in]riseCapture on the HW signal's rising edge
[in]fallCaptuer on the HW signal's falling edge
[in]prioInterrupt priority
[in]argUser provided argument for the capture callback
[in]callbackPointer to user's provided call back function.
Returns
See also
enum tim_err

◆ hal_timer_capture_signal_rem()

int hal_timer_capture_signal_rem ( int  tmr_id,
int  idx 
)

Remove HW signal from the timer's capture list.

Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]idxThe index for the current capture, possible values are 0, 1, 2, 3
Returns
See also
enum tim_err

◆ hal_timer_delay_us()

int hal_timer_delay_us ( int  tim_id,
uint32_t  usec 
)

timer delaye function

Note
This function is not context safe. Use it with care.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]usecDelay time in Microsecond.
Returns
See also
enum tim_err

◆ hal_timer_emit_add()

int hal_timer_emit_add ( int  tmr_id,
int  idx,
uint32_t  tick,
tmr_emit_option_t *  option 
)

Add HW trigger to the timer's trigger list.

Note
Only timer 0 and 1 can support emit
Each timer can capture at most 8 HW signal
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]idxThe index for the current emit, possible values are 0, 1, 2, 3, 4, 5, 6, 7
[in]tickTrigger happens on this timer's tick(in timer clk tick unit)
[in]optionOption of emit. Use default config if it is NULL
Returns
See also
enum tim_err

◆ hal_timer_emit_rem()

int hal_timer_emit_rem ( int  tmr_id,
int  idx 
)

Remove HW trigger from the timer's trigger list.

Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]idxThe index for the current emit, possible values are 0, 1, 2, 3, 4, 5, 6, 7
Returns
See also
enum tim_err

◆ hal_timer_emit_set_callback()

int hal_timer_emit_set_callback ( int  tmr_id,
int  prio,
void *  arg,
void(*)(void *parg, int emit_idx)  callback 
)

Set emit IRQ handler callback for the timer's emit.

Note
Only timer 0,1 and 6 can support emit
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]prioInterrupt priority
[in]argUser provided argument for the emit callback
[in]callbackPointer to user's provided call back function.
Returns
See also
enum tim_err

◆ hal_timer_end_tick()

int hal_timer_end_tick ( int  tim_id)

timer tick stop function.

Note
This function is not context safe. Use it with care.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Returns
See also
enum tim_err

◆ hal_timer_get_systick()

uint32_t hal_timer_get_systick ( void  )

Return the OS tick.

Returns
Current OS tick

◆ hal_timer_get_tick()

uint32_t hal_timer_get_tick ( int  tim_id)

timer get current tick function.

Note
This function is not context safe. Use it with care.
The timer start from 0xFFFFFFFF and counting down.
The "hal_timer_get_tick_us" return the lapse time in microsecond.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Returns
Current timer ticks.

◆ hal_timer_set_tmo_callback()

int hal_timer_set_tmo_callback ( int  tmr_id,
int  prio,
void *  arg,
void(*)(void *)  tmr_cb 
)

rigster Timer timeout callback function

Note
This function is not context safe. Call it before start. The call back function will be called in the interrupt context.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]priInterrupt priority.
[in]argPointer to user's own context to be passed back to user.
[in]tmr_cbPointer to user's provided call back function.
Returns
See also
enum tim_err

◆ hal_timer_smem_emit_add()

int hal_timer_smem_emit_add ( int  tmr_id,
uint32_t *  ticks,
uint32_t  size,
uint16_t  empty_threshold,
tmr_emit_option_t *  option 
)

Add HW trigger to the timer's trigger list.

Note
Only emit 0 of timer 0 and 6 can support smem emit
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]ticksTrigger happens on one of timer's ticks(in timer clk tick unit). the ticks are stored in share memory. They're in order of precedence.
[in]sizeNumber of ticks
[in]empty_thresholdWhen the number of entries is smaller than this number, an interrupt will be generated.
[in]optionOption of emit. Use default config if it is NULL
Returns
See also
enum tim_err

◆ hal_timer_start()

int hal_timer_start ( int  tmr_id,
int  reload,
int  manual,
uint32_t  tick 
)

Run Timer periodic function.

Note
This function is not context safe. Use it with care.
This function will set the timer to run user's specified time periodically. User will be informed thru the provided call back function after each period. The call back function will be called in the interrupt context.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Parameters
[in]reloadreload the initial value after time out
[in]manualtimers manual mode enable. 1 enable, 0 disable
[in]tickInitial value of timer clock ticks
Returns
See also
enum tim_err

◆ hal_timer_start_tick()

int hal_timer_start_tick ( int  tim_id)

start timer profile function

Note
This function is not context safe. Use it with care.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Returns
See also
enum tim_err

◆ hal_timer_stop()

int hal_timer_stop ( int  tim_id)

Stop Timer periodic function.

Note
This function is not context safe. Use it with care.
Parameters
[in]tim_idTimer Id,
See also
enum tim_id
Returns
See also
enum tim_err