50 static volatile uint64_t count;
55 ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
56 while(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
57 PRCM_DOMAIN_POWER_ON);
72 if(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
73 PRCM_DOMAIN_POWER_ON) {
77 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0);
78 ti_lib_prcm_load_set();
79 while(!ti_lib_prcm_load_get());
82 HWREG(GPT0_BASE + GPT_O_CTL) &= ~(GPT_CTL_TAEN | GPT_CTL_TBEN);
88 ti_lib_timer_configure(GPT0_BASE,
89 TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);
92 HWREG(GPT0_BASE + GPT_O_CFG) = TIMER_CFG_SPLIT_PAIR >> 24;
100 ti_lib_timer_prescale_set(GPT0_BASE, TIMER_B, 49);
103 HWREG(GPT0_BASE + GPT_O_TBMR) =
104 ((TIMER_CFG_B_ONE_SHOT >> 8) & 0xFF) | GPT_TBMR_TBPWMIE;
107 HWREGBITW(AON_RTC_BASE + AON_RTC_O_CTL, AON_RTC_CTL_RTC_UPD_EN_BITN) = 1;
111 update_clock_variable(
void)
113 uint32_t aon_rtc_secs_now;
114 uint32_t aon_rtc_secs_now2;
115 uint16_t aon_rtc_ticks_now;
118 aon_rtc_secs_now = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
119 aon_rtc_ticks_now = HWREG(AON_RTC_BASE + AON_RTC_O_SUBSEC) >> 16;
120 aon_rtc_secs_now2 = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
121 }
while(aon_rtc_secs_now != aon_rtc_secs_now2);
124 count = (aon_rtc_secs_now *
CLOCK_SECOND) + (aon_rtc_ticks_now >> 9);
130 update_clock_variable();
132 return (clock_time_t)(count & 0xFFFFFFFF);
138 update_clock_variable();
148 bool interrupts_disabled;
151 interrupts_disabled = ti_lib_int_master_disable();
153 secs_now = ti_lib_aon_rtc_sec_get();
156 if(!interrupts_disabled) {
157 ti_lib_int_master_enable();
160 return (
unsigned long)secs_now;
169 while(
clock_time() - start < (clock_time_t)i);
175 uint32_t clock_status;
177 if(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
178 PRCM_DOMAIN_POWER_ON) {
182 clock_status = HWREG(PRCM_BASE + PRCM_O_GPTCLKGR) & PRCM_GPIOCLKGR_CLK_EN;
184 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0);
185 ti_lib_prcm_load_set();
186 while(!ti_lib_prcm_load_get());
188 ti_lib_timer_load_set(GPT0_BASE, TIMER_B, len);
189 ti_lib_timer_enable(GPT0_BASE, TIMER_B);
195 while(HWREG(GPT0_BASE + GPT_O_CTL) & GPT_CTL_TBEN);
197 if(clock_status == 0) {
198 ti_lib_prcm_peripheral_run_disable(PRCM_PERIPH_TIMER0);
199 ti_lib_prcm_load_set();
200 while(!ti_lib_prcm_load_get());
Header file with macros which rename TI CC26xxware functions.
static bool start(void)
Start measurement.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
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.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
#define CLOCK_SECOND
A second, measured in system clock time.
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_init(void)
Arch-specific implementation of clock_init for the cc2538.