Timers


Detailed Description

In addition to time control over tasks the uSmartX kernel provides another way of time control via software timers. Each system tick software timers are evaluated. If one or more timers expires the tiemr associated call-back function is executed. the uSmartX kernel places timers in a so called relative time queue, where each timer expiration is relative to the preceeding timer. Timers that will expire at the same time have 0 relative ticks. In this way each system tick only one timer is evaluated. This increase performances drasticaly. Please note that the call-back function will be executed from uSMARTX_Tick() function context.

The call back function must be of type:
 STATUS my_callback_func(uint8, void*, void*)


Defines

#define TMR_CREATE(name)
 Create a software timer.
#define WAIT_FOREVER   0xFFFF
 Timeout period.
#define NO_WAIT   0
 Timeout period.
#define TMR_PERIODIC   1
 Software timer mode.
#define TMR_ONE_SHOT   2
 Software timer mode.

Functions

void TMR_Start (HANDLE *ph, uint16 tout, STATUS(*pfxn)(uint8, void *, void *), uint8 evt, void *parg1, void *parg2, uint8 mode)
 Timer start function.
void TMR_ReStart (HANDLE *ph)
 Timer re-start function.
void TMR_Stop (HANDLE *ph)
 Timer stop function.
uint32 TMR_GetTicks (void)
 Return system ticks.


Define Documentation

#define NO_WAIT   0
 

Timeout period.

When a system call timeout parameter has this value the system call won't wait the resource but will return immediately even if the resource isn't avaible.

#define TMR_CREATE name   ) 
 

Create a software timer.

This macro creates a timer

Examples:
timers.c.

#define TMR_ONE_SHOT   2
 

Software timer mode.

The started SW timer will run in one shot mode. Once the timeout will expire and the call-back function will be executed. The timer won't be restarted automaticaly.

Examples:
timers.c.

#define TMR_PERIODIC   1
 

Software timer mode.

The started SW timer will run in periodic mode. Once the timeout will expire and the call-back function will be executed the task will be re-started again automaticaly.

#define WAIT_FOREVER   0xFFFF
 

Timeout period.

When a system call's timeout parameter has this value the system call won't return until the resource will be avaible.


Function Documentation

uint32 TMR_GetTicks void   ) 
 

Return system ticks.

This function returns elapsed system ticks since system startup.

Return values:
elapsed system ticks
Examples:
timers.c.

void TMR_ReStart HANDLE *  ph  ) 
 

Timer re-start function.

This function re-starts a software timer. Be careful to apply this system call only on an already started timer. Its functionality is very similar to TMR_Start() function but it is faster.

Parameters:
ph handle to timer

void TMR_Start HANDLE *  ph,
uint16  tout,
STATUS(*)(uint8, void *, void *)  pfxn,
uint8  evt,
void *  parg1,
void *  parg2,
uint8  mode
 

Timer start function.

This function starts a software timer. A valid call back function must be passed to the function. The timer is re-started if it was already started. Timers can be one shot or periodic.

Parameters:
ph handle to timer
tout timeout value
pfxn address of the callback function
evt event to be passed to the call-back function
parg1 argument 1 to be passed to the call-back function
parg2 argument 2 to be passed to the call-back function
mode one-shot or periodic mode
Attention:
The callback function will be executed from the context where uSMARTX_Tick function was called.
Examples:
timers.c.

void TMR_Stop HANDLE *  ph  ) 
 

Timer stop function.

This function stops a software timer without executin its call-back function.

Parameters:
ph handle to timer


Generated on Sun Oct 16 22:23:55 2005 for uSmartX by  doxygen 1.4.3