Defines | |
| #define | HZ (timerticks per second) |
| #define | POS_TIMEAFTER(x, y) ((((SJIF_t)(x)) - ((SJIF_t)(y))) >= 0) |
Functions | |
| POSEXTERN POSTIMER_t POSCALL | posTimerCreate (void) |
| POSEXTERN VAR_t POSCALL | posTimerSet (POSTIMER_t tmr, POSSEMA_t sema, UINT_t waitticks, UINT_t periodticks) |
| POSEXTERN VAR_t POSCALL | posTimerStart (POSTIMER_t tmr) |
| POSEXTERN VAR_t POSCALL | posTimerStop (POSTIMER_t tmr) |
| POSEXTERN void POSCALL | posTimerDestroy (POSTIMER_t tmr) |
| POSEXTERN VAR_t POSCALL | posTimerFired (POSTIMER_t tmr) |
Variables | |
| POSEXTERN volatile JIF_t | jiffies |
| Global timer variable. The jiffies counter variable is incremented HZ times per second. | |
| #define HZ (timerticks per second) |
Hertz, timer ticks per second. HZ is a define that is set to the number of ticks the timer interrupt does in a second. For example, the jiffies variable is incremented HZ times per second. Also, much OS functions take timeout parameters measured in timer ticks; thus the HZ define can be taken as time base: HZ = 1 second, 10*HZ = 10s, HZ/10 = 100ms, etc.
This macro is used to test if a specified time has expired. It handles timer variable wrap arounds correctly. The macro is used in conjunction with the jiffies variable, the current jiffies should be passed as first parameter to the macro. Example:
exptime = jiffies + HZ/2;
if (POS_TIMEAFTER(jiffies, exptime)) printf("500ms expired!\n");
| POSEXTERN POSTIMER_t POSCALL posTimerCreate | ( | void | ) |
Timer function. Allocates a timer object. After a timer is allocated with this function, it must be set up with posTimerSet and than started with posTimerStart.
| POSEXTERN void POSCALL posTimerDestroy | ( | POSTIMER_t | tmr | ) |
Timer function. Deletes a timer object and free its resources.
| tmr | handle to the timer object. |
| POSEXTERN VAR_t POSCALL posTimerFired | ( | POSTIMER_t | tmr | ) |
Timer function. The function is used to test if a timer has fired.
| tmr | handle to the timer object. |
| POSEXTERN VAR_t POSCALL posTimerSet | ( | POSTIMER_t | tmr, | |
| POSSEMA_t | sema, | |||
| UINT_t | waitticks, | |||
| UINT_t | periodticks | |||
| ) |
Timer function. Sets up a timer object.
| tmr | handle to the timer object. | |
| sema | seaphore object that shall be signaled when timer fires. | |
| waitticks | number of initial wait ticks. The timer fires the first time when this ticks has been expired. | |
| periodticks | After the timer has fired, it is reloaded with this value, and will fire again when this count of ticks has been expired (auto reload mode). If this value is set to zero, the timer won't be restarted (= one shot mode). |
| POSEXTERN VAR_t POSCALL posTimerStart | ( | POSTIMER_t | tmr | ) |
Timer function. Starts a timer. The timer will fire first time when the waitticks counter has been reached zero. If the periodticks were set, the timer will be reloaded with this value.
| tmr | handle to the timer object. |
| POSEXTERN VAR_t POSCALL posTimerStop | ( | POSTIMER_t | tmr | ) |
Timer function. Stops a timer. The timer will no more fire. The timer can be reenabled with posTimerStart.
| tmr | handle to the timer object. |
Global timer variable. The jiffies counter variable is incremented HZ times per second.
The maximum count the jiffie counter can reach until it wraps around is system dependent.
1.5.4