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... | |
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.
| enum eTimeGet |
clusters select values for reading parts of the current time
| Enumerator | |
|---|---|
| kTimeGetTicks | constant (0): ticks (0.25 ms) |
| kTimeGetMinutes | constant (1): minutes |
| kTimeGetSeconds | constant (2): seconds |
| kTimeGetHundredths | constant (3): hundredths of a second |
| void mdelay | ( | uint16_t | mseconds | ) |
Waits for the given time in milliseconds.
| mseconds | 16-bit unsigned integer If mseconds is 56, then the CPU will wait for 56 milliseconds. |
| void time_clear | ( | void | ) |
| 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().
| function | function of type "void fct(void)" Function with no parameters and no return value. To wrap the function call a pointer is used internally. |
| interval | 8-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. |
| void time_cycleClear | ( | uint8_t | id | ) |
Removes a function from the cyclic called functions.
| id | 8-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. |
| 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().
| select | value of the selected time - see also eTimeGet |
| select | range |
| kTimeGetTicks | full 32-bit |
| kTimeGetMinutes | 0..59 |
| kTimeGetSeconds | 0..59 |
| kTimeGetHundredths | 0..99 |
| void udelay | ( | uint16_t | useconds | ) |
Waits for 10 times the given time in microseconds.
| useconds | 16-bit unsigned integer If useconds is 42, then the CPU will wait for 420 microseconds. |
1.8.17