Golem  v0.1.1
Generic Operating system Libraries for Embedded Multitasking
 All Data Structures Files Functions Variables Pages
/home/ruud/Engineering/software/projects/golem-project-code/trunk/glm_tick.h File Reference

The operating system's clock tick on which Golem depends. More...

#include "glm_conf.h"
#include "glm_intbase.h"

Go to the source code of this file.

Data Structures

struct  tickstamp_t
 Container for storing the system tick as a timestamp. More...


void tick_inc ()
 Increments the internal tick counter. More...
void tick_current (tickstamp_t *ts)
 Returns current tick/subtick as tickstamp. More...
void tick_diff (tickstamp_t *begin, tickstamp_t *end, tickstamp_t *result)
 Calculates difference in ticks/subticks between two tickstamps. More...
float tick_time (const tickstamp_t *ts)
 Converts a tickstamp into a time in seconds. More...

Detailed Description

The operating system's clock tick on which Golem depends.

Ruud Beukema

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Definition in file glm_tick.h.

Function Documentation

void tick_current ( tickstamp_t ts)

Returns current tick/subtick as tickstamp.

tsPointer to variable to which to store the tickstamp.

Definition at line 35 of file glm_tick.c.

void tick_diff ( tickstamp_t begin,
tickstamp_t end,
tickstamp_t result 

Calculates difference in ticks/subticks between two tickstamps.

This function can only calculate a valid difference if the 'end' timestamp hasn't crossed the 'begin' value. In other words: the maximum valid difference that can be calculated is bound by the upper limit of the tick type (uint_base_t). The upper limit of the type uint_base_t is always 2^N-1, where N is equal to the bit- with of the integer-registers on your system - as selected with the CORE_*BIT-parameter in glm_conf.h.

beginPointer to variable holding an older tickstamp
endPointer to variable holding a more recent tickstamp.
resultPointer to variable to which to store the difference.

Definition at line 43 of file glm_tick.c.

void tick_inc ( )

Increments the internal tick counter.

This function must be called periodically with a frequency of CORE_TICK_FREQ_HZ in order for Golem to function as expected.

Definition at line 27 of file glm_tick.c.

float tick_time ( const tickstamp_t ts)

Converts a tickstamp into a time in seconds.

Note that this function assumes that the tick timer counts up. Therefore if CORE_SUBTICK_FUNC is defined in glm_conf.h ensure this function's return value is that of a up-counting timer. One can easily convert an down-counting timer value into an up- counting one by taking the one's complement of the down-counting timer value (known in C as inverse or ~).

tsPointer to variable holding the tickstamp
The converted time in seconds.

Definition at line 51 of file glm_tick.c.