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) 79 static volatile uint64_t rt_ticks_startup = 0, rt_ticks_epoch = 0;
120 return rt_ticks_startup / RTIMER_CLOCK_TICK_RATIO;
126 rt_ticks_epoch = (uint64_t)sec * RTIMER_SECOND;
132 return rt_ticks_epoch / RTIMER_SECOND;
141 while(
clock_time() - start < (clock_time_t)i);
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;
Header file for the cc2538 System Control driver.
Header file for the cc2538 General Purpose Timers.
#define GPTIMER_TAPR
GPTM Timer A prescale.
static bool start(void)
Start measurement.
#define GPT_0_BASE
GPTIMER0.
Header file for the energy estimation mechanism
#define GPTIMER_TAILR
GPTM Timer A interval load.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
CMSIS Cortex-M3 core peripheral access layer header file for CC2538.
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.
Header file with register manipulation macro definitions.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
#define GPTIMER_CTL_TAEN
Timer A enable.
#define GPTIMER_TAMR
GPTM Timer A mode.
#define RTIMER_NOW()
Get the current clock time.
#define SYS_CTRL_RCGCGPT
GPT[3:0] clocks - active mode.
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
System Tick Configuration.
Header file for the real-time timer module.
int etimer_pending(void)
Check if there are any non-expired event timers.
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
clock_time_t clock_time(void)
Get the current clock time.
void clock_isr(void)
The clock Interrupt Service Routine.
#define SYS_CTRL_RCGCGPT_GPT0
GPT0 clock enable, CPU running.
Header file with prototypes for interrupt control on the cc2538 Cortex-M3 micro.
void clock_set_seconds(unsigned long sec)
Set the value of the platform seconds.
#define SysTick_CTRL_ENABLE_Msk
void clock_adjust(void)
Adjust the clock following missed SysTick ISRs.
#define GPTIMER_CTL
GPTM control.
static void update_ticks(void)
Update the software clock ticks and seconds.
#define GPTIMER_CFG
GPTM configuration.
void clock_init(void)
Arch-specific implementation of clock_init for the cc2538.