Contiki 2.6
|
The clock library is the interface between Contiki and the platform specific clock functionality. More...
Defines | |
#define | CLOCK_SECOND |
A second, measured in system clock time. | |
Functions | |
void | clock_init (void) |
Initialize the clock library. | |
CCIF clock_time_t | clock_time (void) |
Get the current clock time. | |
CCIF unsigned long | clock_seconds (void) |
Get the current value of the platform seconds. | |
void | clock_set_seconds (unsigned long sec) |
Set the value of the platform seconds. | |
void | clock_wait (clock_time_t t) |
Wait for a given number of ticks. | |
void | clock_delay_usec (uint16_t dt) |
Delay a given number of microseconds. | |
int | clock_fine_max (void) |
Deprecated platform-specific routines. | |
void | clock_delay (unsigned int delay) |
Delay the CPU for a multiple of 2.83 us. |
The clock library is the interface between Contiki and the platform specific clock functionality.
The clock library defines a macro, CLOCK_SECOND, to convert seconds into the tick resolution of the platform. Typically this is 1-10 milliseconds, e.g. 4*CLOCK_SECOND could be 512. A 16 bit counter would thus overflow every 1-10 minutes. Platforms use the tick interrupt to maintain a long term count of seconds since startup.
Platforms may also implement rtimers for greater time resolution and for real-time interrupts, These use a corresponding RTIMER_SECOND.
void clock_delay | ( | unsigned int | i | ) |
Delay the CPU for a multiple of 2.83 us.
Delay the CPU for a multiple of 2.83 us.
The original clock_delay for the msp430 used a granularity of 2.83 usec. This approximates that delay for values up to 1456 usec. (The largest core call in leds.c uses 400).
Definition at line 60 of file clock.c.
References clock_delay_usec().
Referenced by beep_alarm(), beep_beep(), beep_down(), beep_spinup(), leds_blink(), and main().
void clock_delay_usec | ( | uint16_t | howlong | ) |
Delay a given number of microseconds.
dt | How many microseconds to delay. |
Delay a given number of microseconds.
Use the 250KHz MACA clock for longer delays to avoid interrupt effects. However that can't be used if the radio is being power cycled!
Definition at line 62 of file clock.c.
References DISABLE_INTERRUPTS.
Referenced by cc2430_rf_command(), clock_delay(), clock_delay_msec(), and main().
void clock_init | ( | void | ) |
Initialize the clock library.
This function initializes the clock library and should be called from the main() function of the system.
set Timer/Counter0 to be asynchronous from the CPU clock with a second external clock(32,768kHz) driving it.
Wait for TCN0UB, OCR0UB, and TCR0UB.
Definition at line 110 of file clock.c.
References adc_init(), ATOMIC, CLOCK_SECOND, and NULL.
Referenced by main().
CCIF unsigned long clock_seconds | ( | void | ) |
Get the current value of the platform seconds.
This could be the number of seconds since startup, or since a standard epoch.
Get the current value of the platform seconds.
The comparison avoids the need to disable clock interrupts for an atomic read of the four-byte variable.
Definition at line 93 of file clock.c.
References NULL.
Referenced by main(), stimer_elapsed(), stimer_expired(), stimer_remaining(), stimer_restart(), and stimer_set().
void clock_set_seconds | ( | unsigned long | sec | ) |
CCIF clock_time_t clock_time | ( | void | ) |
Get the current clock time.
This function returns the current system clock time.
Get the current clock time.
When 16 bit it typically wraps every 10 minutes. The comparison avoids the need to disable clock interrupts for an atomic read of the multi-byte variable.
Definition at line 87 of file clock.c.
References NULL.
Referenced by clock_wait(), main(), timer_expired(), timer_remaining(), timer_restart(), timer_set(), and uip_ds6_nbr_add().
void clock_wait | ( | clock_time_t | i | ) |
Wait for a given number of ticks.
t | How many ticks. |
Definition at line 78 of file clock.c.
References clock_time().
Referenced by beep_long().