Simple timer functions.
More...
#include "drv/wb/ticks.h"
#include "util/macro.h"
#include "kernel/err.h"
#include "errorcode.h"
#include <stdbool.h>
Go to the source code of this file.
|
static uint32_t | timeOutInit (uint32_t msec) |
| Initializes a timeout with the specified no of msecs. More...
|
|
static uint32_t | timeOutUpdate (uint32_t to, uint32_t msec) |
| Updates the original timeout with the new timeout. More...
|
|
static bool | timeOut (uint32_t to) |
| Checks whether or not the timeout has expired. More...
|
|
static bool | timeOutWaitFor (uint32_t *flags, uint32_t mask, uint32_t result, uint32_t msec) |
| Function to wait for a specific flag to be set or cleared. More...
|
|
void | timeDelay (uint32_t msec) |
| Simple busy-wait delay. More...
|
|
Simple timer functions.
Definition in file tm.h.
void timeDelay |
( |
uint32_t |
msec | ) |
|
Simple busy-wait delay.
The routine guarantees to at least wait for the specified time, but may wait longer.
Currently its avr = msec + 0.5, with a std dev. of 1 / sqrt(12).
Definition at line 18 of file tm.c.
static bool timeOut |
( |
uint32_t |
to | ) |
|
|
inlinestatic |
Checks whether or not the timeout has expired.
- Parameters
-
Timeout | value (returned from timeOutInit). |
Definition at line 77 of file tm.h.
static uint32_t timeOutInit |
( |
uint32_t |
msec | ) |
|
|
inlinestatic |
Initializes a timeout with the specified no of msecs.
Use together with timeOutCheck, e.g:
while (!hasData()) {
if (timeOutExpired(to)) return -1;
}
- Parameters
-
msec | No of msecs before timeout. |
return Time out value.
Definition at line 53 of file tm.h.
static uint32_t timeOutUpdate |
( |
uint32_t |
to, |
|
|
uint32_t |
msec |
|
) |
| |
|
inlinestatic |
Updates the original timeout with the new timeout.
Used for fixed interval timeout.
The timeout is at least guaranteed to wait for the specied time, but may expire later
- Parameters
-
Timeout | value (returned from timeOutInit). |
msec | No of msecs before timeout. |
Definition at line 67 of file tm.h.
static bool timeOutWaitFor |
( |
uint32_t * |
flags, |
|
|
uint32_t |
mask, |
|
|
uint32_t |
result, |
|
|
uint32_t |
msec |
|
) |
| |
|
inlinestatic |
Function to wait for a specific flag to be set or cleared.
- Parameters
-
flags | A pointer to a 32 bit value |
mask | The mask to apply |
result | The result to wait for |
timeout | The maximum timeout in milliseconds |
- Return values
-
true | Condition met |
false | Condition not met, error set to E_TIMEOUT. |
Definition at line 95 of file tm.h.