|
Contiki 3.x
|
Files | |
| file | clock.c |
| This file contains AVR-specific code to implement the Contiki core clock functions. | |
Functions | |
| void | clock_init (void) |
| Start the clock by enabling the timer comparison interrupts. More... | |
| clock_time_t | clock_time (void) |
| Return the tick counter. More... | |
| unsigned long | clock_seconds (void) |
| Return seconds, default is time since startup. More... | |
| void | clock_set_seconds (unsigned long sec) |
| Set seconds, e.g. More... | |
| void | clock_wait (clock_time_t t) |
| Wait for a given number of ticks. More... | |
| void | clock_delay_usec (uint16_t dt) |
| Delay a given number of microseconds. More... | |
| void | clock_delay_msec (uint16_t howlong) |
| Delay up to 65535 milliseconds. More... | |
| void | clock_adjust_ticks (clock_time_t howmany) |
| Adjust the system current clock time. More... | |
| void | AVR_OUTPUT_COMPARE_INT (void) |
| ISR for the TIMER0 or TIMER2 interrupt as defined in clock-avr.h for the particular MCU. | |
Variables | |
| static volatile clock_time_t | count |
| These routines define the AVR-specific calls declared in /core/sys/clock.h CLOCK_SECOND is the number of ticks per second. More... | |
| void clock_adjust_ticks | ( | clock_time_t | howmany | ) |
Adjust the system current clock time.
| howmany | How many ticks to add |
Typically used to add ticks after an MCU sleep clock_seconds will increment if necessary to reflect the tick addition. Leap ticks or seconds can (rarely) be introduced if the ISR is not blocked.
| void clock_delay_msec | ( | uint16_t | howlong | ) |
| void clock_delay_usec | ( | uint16_t | dt | ) |
| void clock_init | ( | void | ) |
| unsigned long clock_seconds | ( | void | ) |
| void clock_set_seconds | ( | unsigned long | sec | ) |
| clock_time_t clock_time | ( | void | ) |
| void clock_wait | ( | clock_time_t | t | ) |
Wait for a given number of ticks.
| t | How many ticks. |
Definition at line 166 of file clock.c.
References clock_time().
|
static |
These routines define the AVR-specific calls declared in /core/sys/clock.h CLOCK_SECOND is the number of ticks per second.
It is defined through CONF_CLOCK_SECOND in the contiki-conf.h for each platform. The usual AVR defaults are 128 or 125 ticks per second, counting a prescaled CPU clock using the 8 bit timer0.
clock_time_t is usually declared by the platform as an unsigned 16 bit data type, thus intervals up to 512 or 524 seconds can be measured with ~8 millisecond precision. For longer intervals the 32 bit clock_seconds() is available.
Since a carry to a higer byte can occur during an interrupt, declaring them non-static for direct examination can cause occasional time reversals!
clock-avr.h contains the specific setup code for each mcu.
Definition at line 80 of file clock.c.
Referenced by aes_load_keys(), clock_adjust_ticks(), clock_init(), clock_isr(), clock_time(), lcd_symbol_clr_group(), and lcd_symbol_set_group().
1.8.6