Modules | Macros | Enumerations

Functions which handle the time. More...

Modules

 Advanced informations
 

Macros

#define kTimeMaxCycleCount
 constant (5): Maximum number of cyclic called functions
 

Enumerations

enum  eTimeGet
 clusters select values for reading parts of the current time More...
 

Clock Funktions

uint32_t time_get (eTimeGet select)
 Returns the selected time value. More...
 
void time_clear (void)
 Clears the internal time value. More...
 

Delay Funktions

void mdelay (uint16_t mseconds)
 Waits for the given time in milliseconds. More...
 
void udelay (uint16_t useconds)
 Waits for 10 times the given time in microseconds. More...
 

Cyclic Funktions

uint8_t time_cycleAdd (void *function, uint8_t interval)
 Adds a function to the cyclic called functions. More...
 
void time_cycleClear (uint8_t id)
 Removes a function from the cyclic called functions. More...
 

Detailed Description

Functions which handle the time.

The robot uses two timers for internal timing:

The systick is used to create the servo signal, for time measurement and for triggering user events. User events (function pointers) can be set by calling the function time_cycleAdd(). A more detailed description can be found here.

The fasttick is used to check the TSOP sensors for an incoming ir-signal and for adc measurements of the Sharp distance sensors.

Enumeration Type Documentation

◆ eTimeGet

enum eTimeGet

clusters select values for reading parts of the current time

See also
line_get() and line_set()
Enumerator
kTimeGetTicks 

constant (0): ticks (0.25 ms)

kTimeGetMinutes 

constant (1): minutes

kTimeGetSeconds 

constant (2): seconds

kTimeGetHundredths 

constant (3): hundredths of a second

Function Documentation

◆ mdelay()

void mdelay ( uint16_t  mseconds)

Waits for the given time in milliseconds.

Note
If the controller is busy handling interrupts the duration will increase.
Parameters
mseconds16-bit unsigned integer
If mseconds is 56, then the CPU will wait for 56 milliseconds.
See also
udelay()
Examples
battery.c, beeper.c, button.c, cyclic.c, driveAdjust.pupil.c, driveAngle.pupil.c, driveArc.pupil.c, driveDist.pupil.c, encoderComplex.c, encoderSimple.c, imu.c, lausTracker.c, led.c, lineComplex.c, lineSimple.c, mode.c, motorComplex.c, motorSimple.c, packedCom.c, remoteControl.c, servo.c, sharp.c, tsop.c, twi.c, and uart.c.

◆ time_clear()

void time_clear ( void  )

Clears the internal time value.

The clearing will be done immediately.

See also
time_get()

◆ time_cycleAdd()

uint8_t time_cycleAdd ( void *  function,
uint8_t  interval 
)

Adds a function to the cyclic called functions.

There can be at maximum kTimeMaxCycleCount cyclic functions.

To turn the cyclic operation off use time_cycleClear().

Parameters
functionfunction of type "void fct(void)"
Function with no parameters and no return value.
To wrap the function call a pointer is used internally.
interval8-bit unsigned integer
The parameter is an integer representing the cycle time in hundredths of a second.
E.g. 12 will call the function every 120ms. If 0 or 1 is used the function will be called every 10ms.
Returns
8-bit unsigned integer (0, 1..kTimeMaxCycleCount)
The return value represents the id of this cyclic function.
If the returned id is 0 the function was not added.
See also
time_cycleClear()
Examples
cyclic.c.

◆ time_cycleClear()

void time_cycleClear ( uint8_t  id)

Removes a function from the cyclic called functions.

Parameters
id8-bit unsigned integer (1..5, 0xFF)
The id parameter is the id of the cyclic called function.
If id is set to 0xFF all cyclic functions are stopped.
See also
time_cycleAdd()
Examples
cyclic.c.

◆ time_get()

uint32_t time_get ( eTimeGet  select)

Returns the selected time value.

The internal time variable is always up to date - no request is needed.

The time is cleared at system start and by the function time_clear().

Parameters
selectvalue of the selected time - see also eTimeGet
Returns
32-bit unsigned integer
select range
kTimeGetTicks full 32-bit
kTimeGetMinutes 0..59
kTimeGetSeconds 0..59
kTimeGetHundredths 0..99
See also
time_clear()

◆ udelay()

void udelay ( uint16_t  useconds)

Waits for 10 times the given time in microseconds.

Note
If the controller is busy handling interrupts the duration will increase.
Parameters
useconds16-bit unsigned integer
If useconds is 42, then the CPU will wait for 420 microseconds.
See also
mdelay()