timer

概述

通用定时器,用于定时,当时间到达我们所设置的定时时间会产生定时中断,可以用来完成定时任务。

注解

timer更多资料请参考 BL602参考手册

应用实例

串口实例: customer_app/peripheral/demo_timer

API参考

Header File

  • components/platform/hosal/include/hosal_timer.h

Functions

int hosal_timer_init(hosal_timer_dev_t *tim)

init a hardware timer

Return
  • 0 : success
  • other :error
Parameters
  • tim: timer device

int hosal_timer_start(hosal_timer_dev_t *tim)

start a hardware timer

Return
  • 0 : success
  • other : error
Parameters
  • tim: timer device

void hosal_timer_stop(hosal_timer_dev_t *tim)

stop a hardware timer

Return
none
Parameters
  • tim: timer device

int hosal_timer_finalize(hosal_timer_dev_t *tim)

De-initialises an TIMER interface, Turns off an TIMER hardware interface

Return
  • 0 : success
  • other : error
Parameters
  • tim: timer device

Structures

struct hosal_timer_config_t

Define timer config args

Public Members

uint32_t period

timer period, us

uint8_t reload_mode

auto reload or not

hosal_timer_cb_t cb

timer handle when expired

void *arg

timer handle args

struct hosal_timer_dev_t

Define timer dev handle

Public Members

int8_t port

timer port

hosal_timer_config_t config

timer config

void *priv

priv data

Macros

TIMER_RELOAD_PERIODIC

timer reload automatic

TIMER_RELOAD_ONCE

timer reload once and need to reload manually

Type Definitions

typedef void (*hosal_timer_cb_t)(void *arg)

Define timer handle function type