66 static volatile uint64_t
count;
71 ti_lib_prcm_power_domain_on(PRCM_DOMAIN_PERIPH);
72 while(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
73 PRCM_DOMAIN_POWER_ON);
88 if(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
89 PRCM_DOMAIN_POWER_ON) {
93 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0);
94 ti_lib_prcm_load_set();
95 while(!ti_lib_prcm_load_get());
98 HWREG(GPT0_BASE + GPT_O_CTL) &= ~(GPT_CTL_TAEN | GPT_CTL_TBEN);
104 ti_lib_timer_configure(GPT0_BASE,
105 TIMER_CFG_SPLIT_PAIR | TIMER_CFG_B_ONE_SHOT);
108 HWREG(GPT0_BASE + GPT_O_CFG) = TIMER_CFG_SPLIT_PAIR >> 24;
116 ti_lib_timer_prescale_set(GPT0_BASE, TIMER_B, 49);
119 HWREG(GPT0_BASE + GPT_O_TBMR) =
120 ((TIMER_CFG_B_ONE_SHOT >> 8) & 0xFF) | GPT_TBMR_TBPWMIE;
124 update_clock_variable(
void)
126 uint32_t aon_rtc_secs_now;
127 uint32_t aon_rtc_secs_now2;
128 uint16_t aon_rtc_ticks_now;
131 aon_rtc_secs_now = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
132 aon_rtc_ticks_now = HWREG(AON_RTC_BASE + AON_RTC_O_SUBSEC) >> 16;
133 aon_rtc_secs_now2 = HWREG(AON_RTC_BASE + AON_RTC_O_SEC);
134 }
while(aon_rtc_secs_now != aon_rtc_secs_now2);
143 update_clock_variable();
145 return (clock_time_t)(
count & 0xFFFFFFFF);
151 update_clock_variable();
161 bool interrupts_disabled;
164 interrupts_disabled = ti_lib_int_master_disable();
166 secs_now = ti_lib_aon_rtc_sec_get();
169 if(!interrupts_disabled) {
170 ti_lib_int_master_enable();
173 return (
unsigned long)secs_now;
182 while(
clock_time() - start < (clock_time_t)i);
188 uint32_t clock_status;
190 if(ti_lib_prcm_power_domain_status(PRCM_DOMAIN_PERIPH) !=
191 PRCM_DOMAIN_POWER_ON) {
195 clock_status = HWREG(PRCM_BASE + PRCM_O_GPTCLKGR) & PRCM_GPIOCLKGR_CLK_EN;
197 ti_lib_prcm_peripheral_run_enable(PRCM_PERIPH_TIMER0);
198 ti_lib_prcm_load_set();
199 while(!ti_lib_prcm_load_get());
201 ti_lib_timer_load_set(GPT0_BASE, TIMER_B, len);
202 ti_lib_timer_enable(GPT0_BASE, TIMER_B);
208 while(HWREG(GPT0_BASE + GPT_O_CTL) & GPT_CTL_TBEN);
210 if(clock_status == 0) {
211 ti_lib_prcm_peripheral_run_disable(PRCM_PERIPH_TIMER0);
212 ti_lib_prcm_load_set();
213 while(!ti_lib_prcm_load_get());
static void start(void)
Start measurement.
Header file with macros which rename TI CC26xxware functions.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
int etimer_pending(void)
Check if there are any non-expired event timers.
clock_time_t clock_time(void)
Get the current clock time.
void clock_init()
Initialize the clock library.
#define CLOCK_SECOND
A second, measured in system clock time.
static volatile clock_time_t count
These routines define the AVR-specific calls declared in /core/sys/clock.h CLOCK_SECOND is the number...
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
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.
void clock_delay_usec(uint16_t usec)
Delay a given number of microseconds.