64#define RTIMER_CLOCK_TICK_RATIO (RTIMER_SECOND / CLOCK_SECOND)
67#if SYS_CTRL_SYS_CLOCK < SYS_CTRL_1MHZ
68#error System clock speeds below 1MHz are not supported
70#define PRESCALER_VALUE (SYS_CTRL_SYS_CLOCK / SYS_CTRL_1MHZ - 1)
73#if SYS_CTRL_SYS_CLOCK % CLOCK_SECOND
75#error System clock speed too slow for CLOCK_SECOND, accuracy reduced
77#define SYSTICK_PERIOD (SYS_CTRL_SYS_CLOCK / CLOCK_SECOND)
79static volatile uint64_t rt_ticks_startup = 0, rt_ticks_epoch = 0;
95 SysTick_Config(SYSTICK_PERIOD);
120 return rt_ticks_startup / RTIMER_CLOCK_TICK_RATIO;
190 uint64_t prev_rt_ticks_startup, cur_rt_ticks_startup;
191 uint32_t cur_rt_ticks_startup_hi;
194 prev_rt_ticks_startup = rt_ticks_startup;
196 cur_rt_ticks_startup_hi = prev_rt_ticks_startup >> 32;
197 if(now < (rtimer_clock_t)prev_rt_ticks_startup) {
198 cur_rt_ticks_startup_hi++;
200 cur_rt_ticks_startup = (uint64_t)cur_rt_ticks_startup_hi << 32 | now;
201 rt_ticks_startup = cur_rt_ticks_startup;
203 rt_ticks_epoch += cur_rt_ticks_startup - prev_rt_ticks_startup;
227 SysTick->CTRL &= ~SysTick_CTRL_ENABLE_Msk;
232 SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
CMSIS Cortex-M3 core peripheral access layer header file for CC2538.
Header file with prototypes for interrupt control on the cc2538 Cortex-M3 micro.
Header file for the energy estimation mechanism.
Header file for the cc2538 General Purpose Timers.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
void clock_adjust(void)
Adjust the clock following missed SysTick ISRs.
static void update_ticks(void)
Update the software clock ticks and seconds.
void clock_init(void)
Arch-specific implementation of clock_init for the cc2538.
void clock_isr(void)
The clock Interrupt Service Routine.
void clock_delay_usec(uint16_t dt)
Delay a given number of microseconds.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
clock_time_t clock_time(void)
Get the current clock time.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
#define GPTIMER_CFG
GPTM configuration.
#define GPT_0_BASE
GPTIMER0.
#define GPTIMER_TAMR
GPTM Timer A mode.
#define GPTIMER_CTL_TAEN
Timer A enable.
#define GPTIMER_TAILR
GPTM Timer A interval load.
#define GPTIMER_TAPR
GPTM Timer A prescale.
#define GPTIMER_CTL
GPTM control.
#define SYS_CTRL_RCGCGPT_GPT0
GPT0 clock enable, CPU running.
#define SYS_CTRL_RCGCGPT
GPT[3:0] clocks - active mode.
int etimer_pending(void)
Check if there are any non-expired event timers.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
#define RTIMER_SECOND
Number of rtimer ticks for 1 second.
#define RTIMER_NOW()
Get the current clock time.
static void start(void)
Start measurement.
Header file with register manipulation macro definitions.
Header file for the real-time timer module.
Header file for the cc2538 System Control driver.