KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tm.h File Reference

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.

Functions

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...
 

Detailed Description

Simple timer functions.

Definition in file tm.h.

Function Documentation

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
Timeoutvalue (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:

uint32_t to = timeOutInit(3000); // 3 second timeout.
while (!hasData()) {
if (timeOutExpired(to)) return -1;
}
Parameters
msecNo 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
Timeoutvalue (returned from timeOutInit).
msecNo 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
flagsA pointer to a 32 bit value
maskThe mask to apply
resultThe result to wait for
timeoutThe maximum timeout in milliseconds
Return values
trueCondition met
falseCondition not met, error set to E_TIMEOUT.

Definition at line 95 of file tm.h.