DRV_TIMER
DRV_TIMER API Status
API |
|---|
DRV_TIMER API Reference
Header File
Functions
-
int32_t drv_timer_reg_callback(uint32_t dev_index, uint32_t sub_tmr_index, pfunc_tmr_cb_t pfn_cb, void *pv_arg)
register timer interrupt callback.
注册子timer的中断处理函数
- 参数:
dev_index – [in] 设备index, 0: AON timer(32K) 1: APB timer(2M)
sub_tmr_index – [in] 子timer index, from 0 and less than TMR_SUB_TIMER_NUM
pfn_cb – [in] timer中断发生时需要调用的callback
pv_arg – [in] callback带的参数
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_timer_start(uint32_t dev_index, uint32_t sub_tmr_index, drv_tmr_count_e e_count_dir, uint32_t expire_tick_count)
start or restart a timer.
启动一个timer,如果timer已经启动,则会表现为使用新的参数重新配置timer 如果timer的超时时间太短,建议先进行中断函数的配置
- 参数:
dev_index – [in] 设备index, 0: AON timer(32K) 1: APB timer(2M)
sub_tmr_index – [in] 子timer index, from 0 and less than TMR_SUB_TIMER_NUM
e_count_dir – [in] 设置计数反向,see drv_tmr_count_e
expire_tick_count – [in] 超时的tick,应该需要使用 DRV_TMR_GET_CLK_FREQ() 来计算设置的值
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_timer_enable_interrupt(uint32_t dev_index, uint32_t sub_tmr_index, bool enable)
enable or disable interrupt.
收到开关对应timer的中断,注册中断的时候会自动打开中断
- 参数:
dev_index – [in] 设备index, 0: AON timer(32K) 1: APB timer(2M)
sub_tmr_index – [in] 子timer index, from 0 and less than TMR_SUB_TIMER_NUM
enable – [in] true: enable false: disable
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
int32_t drv_timer_stop(uint32_t dev_index, uint32_t sub_tmr_index)
stop a timer.
停止一个timer,不使用timer的时候调用
- 参数:
dev_index – [in] 设备index, 0: AON timer(32K) 1: APB timer(2M)
sub_tmr_index – [in] 子timer index, from 0 and less than TMR_SUB_TIMER_NUM
- 返回值:
0 – success [BK_RET_OK]
other – fail
- 返回:
result
-
uint32_t drv_timer_get_curr_tick(uint32_t dev_index, uint32_t sub_tmr_index)
get the current tick of the select timer.
获取timer的当前的计数值
- 参数:
dev_index – [in] 设备index, 0: AON timer(32K) 1: APB timer(2M)
sub_tmr_index – [in] 子timer index, from 0 and less than TMR_SUB_TIMER_NUM
- 返回:
the current tick
-
void drv_timer_delay_us(uint32_t us)
delay us.
使用apb timer用来做us的delay
- 参数:
us – [in] delay的us数值, <= 50
- 返回:
N/A
Macros
-
TMR_DEVICE_NUM
-
TMR_INDEX_AON_TIMER
-
TMR_INDEX_APB_TIMER
-
TMR_SUB_TIMER_NUM
-
SUB_TIMER_INDEX_freerun
-
DRV_TMR_GET_CLK_FREQ(dev_index)
Type Definitions
-
typedef enum _drv_tmr_count_e drv_tmr_count_e
-
typedef void (*pfunc_tmr_cb_t)(uint32_t dev_index, uint32_t sub_tmr_index, void *pv_arg)