64 #define RTIMER_CLOCK_TICK_RATIO (RTIMER_SECOND / CLOCK_SECOND)
65 #define RELOAD_VALUE (125000 - 1)
67 static volatile uint64_t rt_ticks_startup = 0, rt_ticks_epoch = 0;
83 REG(SYSTICK_STRELOAD) = RELOAD_VALUE;
86 REG(SYSTICK_STCTRL) |= SYSTICK_STCTRL_CLK_SRC | SYSTICK_STCTRL_ENABLE;
89 REG(SYSTICK_STCTRL) |= SYSTICK_STCTRL_INTEN;
115 return rt_ticks_startup / RTIMER_CLOCK_TICK_RATIO;
121 rt_ticks_epoch = (uint64_t)sec * RTIMER_SECOND;
127 return rt_ticks_epoch / RTIMER_SECOND;
136 while(
clock_time() - start < (clock_time_t)i);
186 uint64_t prev_rt_ticks_startup, cur_rt_ticks_startup;
187 uint32_t cur_rt_ticks_startup_hi;
190 prev_rt_ticks_startup = rt_ticks_startup;
192 cur_rt_ticks_startup_hi = prev_rt_ticks_startup >> 32;
193 if(now < (rtimer_clock_t)prev_rt_ticks_startup) {
194 cur_rt_ticks_startup_hi++;
196 cur_rt_ticks_startup = (uint64_t)cur_rt_ticks_startup_hi << 32 | now;
197 rt_ticks_startup = cur_rt_ticks_startup;
199 rt_ticks_epoch += cur_rt_ticks_startup - prev_rt_ticks_startup;
223 REG(SYSTICK_STCTRL) &= ~SYSTICK_STCTRL_ENABLE;
228 REG(SYSTICK_STCTRL) |= SYSTICK_STCTRL_ENABLE;
240 ENERGEST_ON(ENERGEST_TYPE_IRQ);
244 ENERGEST_OFF(ENERGEST_TYPE_IRQ);
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
Header file with prototypes for interrupt control on the cc2538 Cortex-M3 micro.
Header for with definitions related to the cc2538 SysTick.
void clock_init(void)
Initialize the clock library.
Header file with register manipulation macro definitions.
Header file for the energy estimation mechanism
void clock_adjust(void)
Adjust the clock following missed SysTick ISRs.
CCIF clock_time_t clock_time(void)
Get the current clock time.
#define GPTIMER_TAMR
GPTM Timer A mode.
Header file for the cc2538 System Control driver.
#define GPT_0_BASE
GPTIMER0.
Header file for the real-time timer module.
#define GPTIMER_TAPR
GPTM Timer A prescale.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.
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 SYS_CTRL_RCGCGPT_GPT0
GPT0 clock enable, CPU running.
#define GPTIMER_CFG
GPTM configuration.
void clock_delay(unsigned int delay)
Obsolete delay function but we implement it here since some code still uses it.
#define RTIMER_NOW()
Get the current clock time.
#define GPTIMER_TAILR
GPTM Timer A interval load.
Header file for the cc2538 General Purpose Timers.
void clock_wait(clock_time_t t)
Wait for a given number of ticks.
#define GPTIMER_CTL_TAEN
Timer A enable.
#define GPTIMER_CTL
GPTM control.
#define SYS_CTRL_RCGCGPT
GPT[3:0] clocks - active mode.
void clock_isr(void)
The clock Interrupt Service Routine.