AM263Px MCU+ SDK: Timer and events utility functions

| AM263Px MCU+ SDK 26.00.00 |

Files | Functions | Typedefs | Enumerations | Macros
Timer and events utility functions
APIs for combase Binding

## Introduction

## Files
file | cb_tmevent.h
| Timer and events utility functions.

## Functions
static int | cb_nanosleep64 (int64_t ts64, int64_t *rts64)
| nano second unit sleep More...
cb_timer_object_t * | cb_timer_create (char *tname)
| creates timer. More...
void | cb_timer_close (cb_timer_object_t *mtmo)
| close the timer More...
int | cb_timer_start_interval (cb_timer_object_t *mtmo, uint32_t value_ms, uint32_t interval_ms)
| start timer interval. More...
int | cb_timer_stop (cb_timer_object_t *mtmo)
| timer stop. More...
bool | cb_timer_expired (cb_timer_object_t *mtmo, cb_timer_clear_t clear)
| timer expired More...

## Typedefs
typedef struct cb_timer_object | cb_timer_object_t
| handler for cb_timer_object More...

## Enumerations
enum | cb_timer_clear_t { CB_TIMER_NO_CLEAR, CB_TIMER_DECREMENT, CB_TIMER_ALL_CLEAR }
| enumeration used for timer to clear, decrement or no clear. This enumeration has following members: More...

## Macros
#define | CB_USLEEP(x) usleep(x)
| micro second unit sleep More...
#define | CB_SLEEP(x) sleep(x)
| second unit sleep More...
#define | CB_MKTIME(x) mktime(x)
| seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC) More...

## Macro Definition Documentation

## ◆ CB_USLEEP

#define CB_USLEEP | ( |  | x | ) | usleep(x)

micro second unit sleep

## ◆ CB_SLEEP

#define CB_SLEEP | ( |  | x | ) | sleep(x)

second unit sleep

## ◆ CB_MKTIME

#define CB_MKTIME | ( |  | x | ) | mktime(x)

seconds since the Epoch, 1970-01-01 00:00:00 +0000 (UTC)

## Typedef Documentation

## ◆ cb_timer_object_t

typedef struct cb_timer_object cb_timer_object_t

handler for cb_timer_object

Note
  cb_timer is signal event based timer, no thread, no callback happens with this. users need to call 'cb_timer_expired' to check the configured timer

## Enumeration Type Documentation

## ◆ cb_timer_clear_t

enum cb_timer_clear_t

enumeration used for timer to clear, decrement or no clear. This enumeration has following members:

1. CB_TIMER_NO_CLEAR -> no action on timer value
2. CB_TIMER_DECREMENT -> timer value decrement
3. CB_TIMER_ALL_CLEAR -> set timer value to 0.

Enumerator
CB_TIMER_NO_CLEAR |
CB_TIMER_DECREMENT |
CB_TIMER_ALL_CLEAR |

## Function Documentation

## ◆ cb_nanosleep64()

static int cb_nanosleep64 | ( | int64_t | ts64,
|  | int64_t * | rts64
| ) |  |
| inlinestatic

nano second unit sleep

## ◆ cb_timer_create()

cb_timer_object_t* cb_timer_create | ( | char * | tname | ) |

creates timer.

Parameters

  tname | timer name

Returns
  hanler of cb_timer_object_t

## ◆ cb_timer_close()

void cb_timer_close | ( | cb_timer_object_t * | mtmo | ) |

close the timer

Parameters

  mtmo | reference to cb_timer_object_t, returned by cb_timer_create().

## ◆ cb_timer_start_interval()

int cb_timer_start_interval | ( | cb_timer_object_t * | mtmo,
|  | uint32_t | value_ms,
|  | uint32_t | interval_ms
| ) |  |

start timer interval.

Parameters

  mtmo | reference to cb_timer_object_t, created and returned by cb_timer_create().
  value_ms | initial value in msec.
  interval_ms | time interval in msec.

Returns
  0 on success, -1 on error

Note
  both value_ms and interval_ms is used by timer_settime.

## ◆ cb_timer_stop()

int cb_timer_stop | ( | cb_timer_object_t * | mtmo | ) |

timer stop.

Parameters

  mtmo | reference to cb_timer_object_t, which is created and returned by cb_timer_create().

Returns
  0 on success, -1 on error.

## ◆ cb_timer_expired()

bool cb_timer_expired | ( | cb_timer_object_t * | mtmo,
|  | cb_timer_clear_t | clear
| ) |  |

timer expired

Parameters

  mtmo | reference to cb_timer_object_t, which is created and returned by cb_timer_create().
  clear | action by the definition of cb_timer_clear_t

Returns
  true if timer not expired, false if timer expired.