Contiki-NG
|
The clock library is the interface between Contiki and the platform specific clock functionality. More...
Macros | |
#define | CLOCK_SECOND |
A second, measured in system clock time. | |
Functions | |
void | clock_init (void) |
Initialize the clock library. More... | |
clock_time_t | clock_time (void) |
Get the current clock time. More... | |
unsigned long | clock_seconds (void) |
Get the current value of the platform seconds. More... | |
void | clock_set_seconds (unsigned long sec) |
Set the value of the platform seconds. 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... | |
int | clock_fine_max (void) |
Deprecated platform-specific routines. | |
void | clock_delay (unsigned int delay) |
Obsolete delay function but we implement it here since some code still uses it. More... | |
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 | dt | ) |
void clock_delay_usec | ( | uint16_t | dt | ) |
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.
Initialize the clock library.
We initialise the SysTick to fire 128 interrupts per second, giving us a value of 128 for CLOCK_SECOND
We also initialise GPT0:Timer A, which is used by clock_delay_usec(). We use 16-bit range (individual), count-down, one-shot, no interrupts. The prescaler is computed according to the system clock in order to get 1 tick per usec.
Definition at line 93 of file clock.c.
References SysTick_Config().
Referenced by soc_init().
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.
Definition at line 130 of file clock.c.
References CLOCK_SECOND, and clock_time().
Referenced by platform_idle().
void clock_set_seconds | ( | unsigned long | sec | ) |
clock_time_t clock_time | ( | void | ) |
Get the current clock time.
This function returns the current system clock time.
Definition at line 118 of file clock.c.
Referenced by clock_seconds(), and gpiote_event_handler().
void clock_wait | ( | clock_time_t | t | ) |
Wait for a given number of ticks.
t | How many ticks. |
Wait for a given number of ticks.
Definition at line 136 of file clock.c.
Referenced by platform_init_stage_two().