39 #include "sys/clock.h"
46 #define TICK_VAL (32768/128)
48 #if CLOCK_CONF_STACK_FRIENDLY
49 volatile uint8_t sleep_flag;
53 static unsigned long timer_value;
54 static volatile CC_AT_DATA clock_time_t count = 0;
55 static volatile CC_AT_DATA clock_time_t seconds = 0;
98 CLKCON = OSC32K | TICKSPD2 | TICKSPD1;
102 timer_value += ((
unsigned long int)ST1) << 8;
103 timer_value += ((
unsigned long int)ST2) << 16;
104 timer_value += TICK_VAL;
105 ST2 = (
unsigned char)(timer_value >> 16);
106 ST1 = (
unsigned char)(timer_value >> 8);
107 ST0 = (
unsigned char)timer_value;
113 #if CC_CONF_OPTIMIZE_STACK_SIZE
117 clock_ISR(
void) __interrupt(ST_VECTOR)
120 ENERGEST_ON(ENERGEST_TYPE_IRQ);
134 timer_value += ((
unsigned long int)ST1) << 8;
135 timer_value += ((
unsigned long int)ST2) << 16;
136 timer_value += TICK_VAL;
137 ST2 = (
unsigned char)(timer_value >> 16);
138 ST1 = (
unsigned char)(timer_value >> 8);
139 ST0 = (
unsigned char)timer_value;
147 #if (CLOCK_CONF_SECOND & (CLOCK_CONF_SECOND - 1)) != 0
148 #error CLOCK_CONF_SECOND must be a power of two (i.e., 1, 2, 4, 8, 16, 32, 64, ...).
149 #error Change CLOCK_CONF_SECOND in contiki-conf.h.
151 if(count % CLOCK_CONF_SECOND == 0) {
155 #if CLOCK_CONF_STACK_FRIENDLY
165 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
CC2430 registers header file for CC2430.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
void clock_init(void)
Initialize the clock library.
Header file for the energy estimation mechanism
CCIF clock_time_t clock_time(void)
Get the current clock time.
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.
#define SLEEP
Constant SLEEP for sub-register SR_TRX_STATUS.
CCIF unsigned long clock_seconds(void)
Get the current value of the platform seconds.
int etimer_pending(void)
Check if there are any non-expired event timers.
#define DISABLE_INTERRUPTS()
Disable interrupts, saving the previous state so it can be later restored with RESTORE_INTERRUPTS().
void clock_wait(clock_time_t t)
Wait for a given number of ticks.