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.
Macros | |
#define | CLOCK_SECOND |
A second, measured in GCLK generator 5 clock source. More... | |
Functions | |
void | clock_delay (unsigned int delay) |
void | clock_delay_usec (uint16_t dt) |
Delay a given number of microseconds. More... | |
unsigned short | clock_fine (void) |
int | clock_fine_max (void) |
Deprecated platform-specific routines. More... | |
void | clock_init (void) |
Initialize the clock library. More... | |
CCIF 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... | |
CCIF clock_time_t | clock_time (void) |
Get the current clock time. More... | |
void | clock_wait (clock_time_t t) |
Wait for a given number of ticks. More... | |
#define CLOCK_SECOND |
A second, measured in GCLK generator 5 clock source.
Referenced by _TC3_Handler(), broadcast_rate_drop(), clock_adjust_ticks(), clock_irq_callback(), default_timebase(), duty_cycle(), echo_reply_callback(), handle_dao_timer(), handle_dio_timer(), if(), main(), new_dio_interval(), phase_wait(), PROCESS_THREAD(), rpl_reset_periodic_timer(), set_dao_lifetime_timer(), uaodv_request_route_to(), uip_ds6_addr_add(), uip_ds6_init(), uip_ds6_send_rs(), and while().
void clock_delay | ( | unsigned int | delay | ) |
Referenced by leds_blink().
void clock_delay_usec | ( | uint16_t | dt | ) |
Delay a given number of microseconds.
dt | How many microseconds to delay. |
unsigned short clock_fine | ( | void | ) |
int clock_fine_max | ( | void | ) |
Deprecated platform-specific routines.
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.
References clock_irq_callback(), tc_config::clock_prescaler, tc_config::clock_source, tc_16bit_config::compare_capture_channel, tc_config::counter_16_bit, GCLK_GENERATOR_5, tc_config::run_in_standby, TC_CALLBACK_CC_CHANNEL0, TC_CLOCK_PRESCALER_DIV1, tc_enable(), tc_enable_callback(), tc_get_config_defaults(), tc_init(), tc_instance, tc_register_callback(), TIMER, and TIMER_PERIOD.
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.
References seconds.
Referenced by print_stats(), stimer_elapsed(), stimer_expired(), stimer_remaining(), stimer_restart(), and stimer_set().
void clock_set_seconds | ( | unsigned long | sec | ) |
Set the value of the platform seconds.
sec | The value to set. |
CCIF clock_time_t clock_time | ( | void | ) |
Get the current clock time.
This function returns the current system clock time.
References system_interrupt_enter_critical_section(), system_interrupt_leave_critical_section(), and ticks.
Referenced by double_interval(), echo_reply_callback(), fire(), if(), make_addrmap(), new_interval(), PROCESS_THREAD(), schedule_for_end(), timer_expired(), timer_remaining(), timer_restart(), timer_set(), and update_time().
void clock_wait | ( | clock_time_t | t | ) |
Wait for a given number of ticks.
t | How many ticks. |