IntrOS
Loading...
Searching...
No Matches
Timer

timers (one-shot, periodic) More...

Macros

#define OS_TMR(tmr, proc)
 define and initialize a timer object
#define static_TMR(tmr, proc)
 static alias of OS_TMR()
#define OS_TMR_DEF(tmr)
 define and initialize complete timer object
#define static_TMR_DEF(tmr)
 static alias of OS_TMR_DEF()
#define OS_TMR_START(tmr, delay, period)
 define, initialize and start complete timer object
#define static_TMR_START(tmr, delay, period)
 static alias of OS_TMR_START()
#define OS_TMR_UNTIL(tmr, time)
 define, initialize and start complete timer object
#define static_TMR_UNTIL(tmr, time)
 static alias of OS_TMR_UNTIL()
#define TMR_INIT(proc)
 create and initialize a timer object
#define TMR_CREATE(proc)
 create and initialize a timer object
#define TMR_NEW   TMR_CREATE
 alias of TMR_CREATE()

Functions

tmr_t * tmr_this (void)
 return current timer object
void tmr_init (tmr_t *tmr, fun_t *proc)
 initialize a timer object
void tmr_reset (tmr_t *tmr)
 reset the timer object and wake up all waiting tasks with 'E_STOPPED' event value
void tmr_kill (tmr_t *tmr)
 alias of tmr_reset()
void tmr_start (tmr_t *tmr, cnt_t delay, cnt_t period)
 start/restart periodic timer for given duration of time
void tmr_startFor (tmr_t *tmr, cnt_t delay)
 start/restart one-shot timer for given duration of time
void tmr_startPeriodic (tmr_t *tmr, cnt_t period)
 start/restart periodic timer for given duration of time
void tmr_startFrom (tmr_t *tmr, cnt_t delay, cnt_t period, fun_t *proc)
 start/restart periodic timer for given duration of time
void tmr_startNext (tmr_t *tmr, cnt_t delay)
 restart the timer for given duration of time from the end of the previous countdown
void tmr_startUntil (tmr_t *tmr, cnt_t time)
 start/restart one-shot timer until given timepoint
void tmr_stop (tmr_t *tmr)
 stop timer
int tmr_take (tmr_t *tmr)
 check if the timer finishes countdown
int tmr_expired (tmr_t *tmr)
 alias of tmr_take()
int tmr_tryWait (tmr_t *tmr)
 alias of tmr_take()
int tmr_waitFor (tmr_t *tmr, cnt_t delay)
 wait for given duration of time until the timer finishes countdown
int tmr_waitNext (tmr_t *tmr, cnt_t delay)
 wait for given duration of time from the end of the previous countdown
int tmr_waitUntil (tmr_t *tmr, cnt_t time)
 wait until given timepoint until the timer finishes countdown
int tmr_wait (tmr_t *tmr)
 wait indefinitely until the timer finishes countdown
void tmr_flip (fun_t *proc)
 change callback procedure for current periodic timer (available in next period)
void tmr_delay (cnt_t delay)
 change delay time for current timer

Detailed Description

timers (one-shot, periodic)

Macro Definition Documentation

◆ OS_TMR

#define OS_TMR ( tmr,
proc )
Value:
tmr_t tmr[] = { _TMR_INIT( proc ) }

define and initialize a timer object

Parameters
tmrname of a pointer to timer object
proccallback procedure
  • NULL: no callback

◆ static_TMR

#define static_TMR ( tmr,
proc )
Value:
static tmr_t tmr[] = { _TMR_INIT( proc ) }

static alias of OS_TMR()

◆ OS_TMR_DEF

#define OS_TMR_DEF ( tmr)
Value:
static void tmr##__fun( void ); \
OS_TMR( tmr, tmr##__fun ); \
static void tmr##__fun( void )

define and initialize complete timer object

     timer callback procedure (function body) must be defined immediately below
Parameters
tmrname of a pointer to timer object

◆ static_TMR_DEF

#define static_TMR_DEF ( tmr)
Value:
static void tmr##__fun( void ); \
static_TMR( tmr, tmr##__fun ); \
static void tmr##__fun( void )

static alias of OS_TMR_DEF()

◆ OS_TMR_START

#define OS_TMR_START ( tmr,
delay,
period )
Value:
static void tmr##__fun( void ); \
OS_TMR( tmr, tmr##__fun ); \
__CONSTRUCTOR static void tmr##__run( void ) { tmr_start(tmr, delay, period); } \
static void tmr##__fun( void )
void tmr_start(tmr_t *tmr, cnt_t delay, cnt_t period)
start/restart periodic timer for given duration of time

define, initialize and start complete timer object

     timer callback procedure (function body) must be defined immediately below
Parameters
tmrname of a pointer to timer object
delayduration of time (maximum number of ticks to countdown) for first expiration
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely
periodduration of time (maximum number of ticks to countdown) for all next expirations
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely
Note
only available for compilers supporting the "constructor" function attribute or its equivalent

◆ static_TMR_START

#define static_TMR_START ( tmr,
delay,
period )
Value:
static void tmr##__fun( void ); \
static_TMR( tmr, tmr##__fun ); \
__CONSTRUCTOR static void tmr##__run( void ) { tmr_start(tmr, delay, period); } \
static void tmr##__fun( void )

static alias of OS_TMR_START()

◆ OS_TMR_UNTIL

#define OS_TMR_UNTIL ( tmr,
time )
Value:
static void tmr##__fun( void ); \
OS_TMR( tmr, tmr##__fun ); \
__CONSTRUCTOR static void tmr##__run( void ) { tmr_startUntil(tmr, time); } \
static void tmr##__fun( void )
void tmr_startUntil(tmr_t *tmr, cnt_t time)
start/restart one-shot timer until given timepoint

define, initialize and start complete timer object

     timer callback procedure (function body) must be defined immediately below
Parameters
tmrname of a pointer to timer object
timetimepoint value
Note
only available for compilers supporting the "constructor" function attribute or its equivalent

◆ static_TMR_UNTIL

#define static_TMR_UNTIL ( tmr,
time )
Value:
static void tmr##__fun( void ); \
static_TMR( tmr, tmr##__fun ); \
__CONSTRUCTOR static void tmr##__run( void ) { tmr_startUntil(tmr, time); } \
static void tmr##__fun( void )

static alias of OS_TMR_UNTIL()

◆ TMR_INIT

#define TMR_INIT ( proc)
Value:
_TMR_INIT( proc )

create and initialize a timer object

Parameters
proccallback procedure
  • NULL: no callback
Returns
timer object
Note
use only in 'C' code

◆ TMR_CREATE

#define TMR_CREATE ( proc)
Value:
{ TMR_INIT ( proc ) }
#define TMR_INIT(proc)
create and initialize a timer object
Definition ostimer.h:187

create and initialize a timer object

Parameters
proccallback procedure
  • NULL: no callback
Returns
timer object as array (id)
Note
use only in 'C' code

Function Documentation

◆ tmr_this()

tmr_t * tmr_this ( void )
inline

return current timer object

Returns
current timer object
Note
use only in timer's callback procedure

◆ tmr_init()

void tmr_init ( tmr_t * tmr,
fun_t * proc )

initialize a timer object

Parameters
tmrpointer to timer object
proccallback procedure
  • NULL: no callback

◆ tmr_reset()

void tmr_reset ( tmr_t * tmr)

reset the timer object and wake up all waiting tasks with 'E_STOPPED' event value

Parameters
tmrpointer to timer object
Note
use only in thread mode

◆ tmr_start()

void tmr_start ( tmr_t * tmr,
cnt_t delay,
cnt_t period )

start/restart periodic timer for given duration of time

     when the timer has finished the countdown, the callback procedure is launched

     do this periodically if period > 0
Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to countdown) for first expiration
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely
periodduration of time (maximum number of ticks to countdown) for all next expirations
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely

◆ tmr_startFor()

void tmr_startFor ( tmr_t * tmr,
cnt_t delay )
inline

start/restart one-shot timer for given duration of time

     when the timer has finished the countdown, the callback procedure is launched
Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to countdown)
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely

◆ tmr_startPeriodic()

void tmr_startPeriodic ( tmr_t * tmr,
cnt_t period )
inline

start/restart periodic timer for given duration of time

     when the timer has finished the countdown, the callback procedure is launched

     do this periodically
Parameters
tmrpointer to timer object
periodduration of time (maximum number of ticks to countdown)
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely

◆ tmr_startFrom()

void tmr_startFrom ( tmr_t * tmr,
cnt_t delay,
cnt_t period,
fun_t * proc )

start/restart periodic timer for given duration of time

     when the timer has finished the countdown, the callback procedure is launched

     do this periodically if period > 0
Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to countdown) for first expiration
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely
periodduration of time (maximum number of ticks to countdown) for all next expirations
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely
proccallback procedure
  • NULL: no callback

◆ tmr_startNext()

void tmr_startNext ( tmr_t * tmr,
cnt_t delay )

restart the timer for given duration of time from the end of the previous countdown

     when the timer has finished the countdown, the callback procedure is launched
Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to countdown)
  • IMMEDIATE: don't countdown
  • INFINITE: countdown indefinitely

◆ tmr_startUntil()

void tmr_startUntil ( tmr_t * tmr,
cnt_t time )

start/restart one-shot timer until given timepoint

     when the timer has finished the countdown, the callback procedure is launched
Parameters
tmrpointer to timer object
timetimepoint value

◆ tmr_stop()

void tmr_stop ( tmr_t * tmr)
inline

stop timer

Parameters
tmrpointer to timer object

◆ tmr_take()

int tmr_take ( tmr_t * tmr)

check if the timer finishes countdown

Parameters
tmrpointer to timer object
Return values
E_SUCCESStimer object successfully finished countdown
E_FAILUREtimer has not yet been started
E_TIMEOUTtimer object has not yet completed counting, try again

◆ tmr_waitFor()

int tmr_waitFor ( tmr_t * tmr,
cnt_t delay )

wait for given duration of time until the timer finishes countdown

Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to wait for the timer finishes countdown)
  • IMMEDIATE: don't wait for the timer finishes countdown
  • INFINITE: wait indefinitely until the timer finishes countdown
Return values
E_SUCCESStimer object successfully finished countdown
E_FAILUREtimer has not yet been started
E_STOPPEDtimer object was reseted before the specified timeout expired
E_TIMEOUTtimer object has not finished countdown before the specified timeout expired

◆ tmr_waitNext()

int tmr_waitNext ( tmr_t * tmr,
cnt_t delay )

wait for given duration of time from the end of the previous countdown

     until the timer finishes countdown
Parameters
tmrpointer to timer object
delayduration of time (maximum number of ticks to wait for the timer finishes countdown)
  • IMMEDIATE: don't wait for the timer finishes countdown
  • INFINITE: wait indefinitely until the timer finishes countdown
Return values
E_SUCCESStimer object successfully finished countdown
E_FAILUREtimer has not yet been started
E_STOPPEDtimer object was reseted before the specified timeout expired
E_TIMEOUTtimer object has not finished countdown before the specified timeout expired
Note
use only in thread mode

◆ tmr_waitUntil()

int tmr_waitUntil ( tmr_t * tmr,
cnt_t time )

wait until given timepoint until the timer finishes countdown

Parameters
tmrpointer to timer object
timetimepoint value
Return values
E_SUCCESStimer object successfully finished countdown
E_FAILUREtimer has not yet been started
E_STOPPEDtimer object was reseted before the specified timeout expired
E_TIMEOUTtimer object has not finished countdown before the specified timeout expired
Note
use only in thread mode

◆ tmr_wait()

int tmr_wait ( tmr_t * tmr)
inline

wait indefinitely until the timer finishes countdown

Parameters
tmrpointer to timer object
Return values
E_SUCCESStimer object successfully finished countdown
E_FAILUREtimer has not yet been started
E_STOPPEDtimer object was reseted before the countdown ended

◆ tmr_flip()

void tmr_flip ( fun_t * proc)
inline

change callback procedure for current periodic timer (available in next period)

Parameters
procnew callback procedure
  • NULL: no callback
Note
use only in timer's callback procedure

◆ tmr_delay()

void tmr_delay ( cnt_t delay)
inline

change delay time for current timer

Parameters
delayduration of time (maximum number of ticks to countdown)
  • 0: current timer is stopped even if it was periodic
  • otherwise: current timer is restarted even if it was one-shot
Note
use only in timer's callback procedure