31 #include "sys/clock.h"
34 #include "contiki-conf.h"
35 #include "drivers/legacy_pc/rtc.h"
37 #if CLOCK_CONF_SECOND == 2
39 #elif CLOCK_CONF_SECOND == 4
41 #elif CLOCK_CONF_SECOND == 8
43 #elif CLOCK_CONF_SECOND == 16
44 #define FREQ RTC_16_HZ
45 #elif CLOCK_CONF_SECOND == 32
46 #define FREQ RTC_32_HZ
47 #elif CLOCK_CONF_SECOND == 64
48 #define FREQ RTC_64_HZ
49 #elif CLOCK_CONF_SECOND == 128
50 #define FREQ RTC_128_HZ
51 #elif CLOCK_CONF_SECOND == 256
52 #define FREQ RTC_256_HZ
53 #elif CLOCK_CONF_SECOND == 512
54 #define FREQ RTC_512_HZ
55 #elif CLOCK_CONF_SECOND == 1024
56 #define FREQ RTC_1024_HZ
57 #elif CLOCK_CONF_SECOND == 2048
58 #define FREQ RTC_2048_HZ
59 #elif CLOCK_CONF_SECOND == 4096
60 #define FREQ RTC_4096_HZ
61 #elif CLOCK_CONF_SECOND == 8192
62 #define FREQ RTC_8192_HZ
65 #error "RTC is being used thus CLOCK_CONF_SECOND has to be a value defined by rtc_frequency_t."
68 static volatile clock_time_t tick_count = 0;
78 if(expire != 0 && tick_count >= expire) {
98 return tick_count / CLOCK_CONF_SECOND;
104 clock_time_t initial = tick_count;
106 while(tick_count < t + initial);
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
clock_time_t clock_time(void)
Get the current clock time.
void clock_init()
Initialize the clock library.
static void update_ticks(void)
Update the software clock ticks and seconds.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
void clock_delay_usec(uint16_t usec)
Delay a given number of microseconds.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.