AM64x MCU+ SDK  10.00.00
xTimer utility functions

Introduction

Files

file  cb_xtimer.h
 xTimer utility functions
 

Functions

cb_xtimer_man_tcb_xtimer_man_create (void)
 Create a timer manager. More...
 
void cb_xtimer_man_delete (cb_xtimer_man_t *xtimer_man)
 Delete a timer manager. More...
 
int cb_xtimer_man_schedule (cb_xtimer_man_t *xtimer_man)
 The timer manager consumes expired timers and schedule for next timer to be expired. More...
 
int cb_xtimer_man_nearest_timeout (cb_xtimer_man_t *xtimer_man)
 Get a timeout of nearest timer. More...
 
cb_xtimer_tcb_xtimer_create (cb_xtimer_man_t *xtimer_man, xtimer_expirecb_t expirecb, void *exparg)
 Create a timer. More...
 
void cb_xtimer_delete (cb_xtimer_t *xtimer)
 Delete a timer. More...
 
void cb_xtimer_set_periodic (cb_xtimer_t *xtimer)
 Set a periodic timer flag. More...
 
void cb_xtimer_clear_periodic (cb_xtimer_t *xtimer)
 Clear periodic timer flag. More...
 
bool cb_xtimer_is_periodic (cb_xtimer_t *xtimer)
 Check if a timer is periodic. More...
 
int cb_xtimer_remain_timeout (cb_xtimer_t *xtimer)
 Get remaining timeout of a running timer. More...
 
int cb_xtimer_start (cb_xtimer_t *xtimer, uint32_t timeout_us)
 Start a timer. More...
 
void cb_xtimer_stop (cb_xtimer_t *xtimer)
 Stop a running timer, the periodic flag is cleared as well. More...
 
bool cb_xtimer_is_running (cb_xtimer_t *xtimer)
 Check if a timer is running. More...
 

Typedefs

typedef struct cb_xtimer_man cb_xtimer_man_t
 Data handle of a timer manager, inside of it is private. More...
 
typedef struct cb_xtimer cb_xtimer_t
 Data handle of a timer, inside of it is private. More...
 
typedef struct cb_xtimer_ndata cb_xtimer_ndata_t
 Data handle of a timer data, inside of it is private. More...
 
typedef void(* xtimer_expirecb_t) (cb_xtimer_t *timer, void *exparg)
 A callback is called when a timer expired. More...
 

Typedef Documentation

◆ cb_xtimer_man_t

typedef struct cb_xtimer_man cb_xtimer_man_t

Data handle of a timer manager, inside of it is private.

◆ cb_xtimer_t

typedef struct cb_xtimer cb_xtimer_t

Data handle of a timer, inside of it is private.

◆ cb_xtimer_ndata_t

typedef struct cb_xtimer_ndata cb_xtimer_ndata_t

Data handle of a timer data, inside of it is private.

◆ xtimer_expirecb_t

typedef void(* xtimer_expirecb_t) (cb_xtimer_t *timer, void *exparg)

A callback is called when a timer expired.

Function Documentation

◆ cb_xtimer_man_create()

cb_xtimer_man_t* cb_xtimer_man_create ( void  )

Create a timer manager.

The xtimer is non-thread safe function. Each thread is expected to own a timer manager and all timers are processed in this thread.

Returns
a timer manager: success; NULL: error

◆ cb_xtimer_man_delete()

void cb_xtimer_man_delete ( cb_xtimer_man_t xtimer_man)

Delete a timer manager.

Parameters
xtimer_mantimer manager data

◆ cb_xtimer_man_schedule()

int cb_xtimer_man_schedule ( cb_xtimer_man_t xtimer_man)

The timer manager consumes expired timers and schedule for next timer to be expired.

The function is expected to run in a thread loop. It returns nearest timeout that expects for next timer to be expired. The thread loop should use this timeout as its wait time for event.

Parameters
xtimer_mantimer manager data
Returns
>= 0: nearest timeout; -1: error; -2: no running timer

◆ cb_xtimer_man_nearest_timeout()

int cb_xtimer_man_nearest_timeout ( cb_xtimer_man_t xtimer_man)

Get a timeout of nearest timer.

Parameters
xtimer_mantimer manager data
Returns
>= 0: nearest timeout ; -1: error; -2: no running timer

◆ cb_xtimer_create()

cb_xtimer_t* cb_xtimer_create ( cb_xtimer_man_t xtimer_man,
xtimer_expirecb_t  expirecb,
void *  exparg 
)

Create a timer.

Parameters
xtimer_mantimer manager data
expirecbexpire callback
expargexpired callback argument
Returns
a timer: success; NULL: error

◆ cb_xtimer_delete()

void cb_xtimer_delete ( cb_xtimer_t xtimer)

Delete a timer.

Parameters
xtimera timer data

◆ cb_xtimer_set_periodic()

void cb_xtimer_set_periodic ( cb_xtimer_t xtimer)

Set a periodic timer flag.

If this flag is set, the timer will be restarted when it expired.

Parameters
xtimera timer data

◆ cb_xtimer_clear_periodic()

void cb_xtimer_clear_periodic ( cb_xtimer_t xtimer)

Clear periodic timer flag.

Parameters
xtimera timer data

◆ cb_xtimer_is_periodic()

bool cb_xtimer_is_periodic ( cb_xtimer_t xtimer)

Check if a timer is periodic.

Parameters
xtimera timer data
Returns
true: periodic; false: not periodic or error

◆ cb_xtimer_remain_timeout()

int cb_xtimer_remain_timeout ( cb_xtimer_t xtimer)

Get remaining timeout of a running timer.

Parameters
xtimera timer data
Returns
>= 0: remaining timeout; -1: error

◆ cb_xtimer_start()

int cb_xtimer_start ( cb_xtimer_t xtimer,
uint32_t  timeout_us 
)

Start a timer.

Parameters
xtimera timer data
timeout_ustimeout value in microsec
Returns
0: success; -1: error; -2: timer is running

◆ cb_xtimer_stop()

void cb_xtimer_stop ( cb_xtimer_t xtimer)

Stop a running timer, the periodic flag is cleared as well.

Parameters
xtimera timer data

◆ cb_xtimer_is_running()

bool cb_xtimer_is_running ( cb_xtimer_t xtimer)

Check if a timer is running.

Parameters
xtimera timer data
Returns
true: running; false: stopped or error