46 #include "sys/clock.h" 49 #include <ti/devices/DeviceFamily.h> 50 #include DeviceFamily_constructPath(driverlib/aon_rtc.h) 51 #include DeviceFamily_constructPath(driverlib/systick.h) 53 #include <ti/drivers/dpl/ClockP.h> 60 static ClockP_Struct wakeup_clk;
62 #define H_WAKEUP_CLK (ClockP_handle(&wakeup_clk)) 64 #define NO_TIMEOUT (~(uint32_t)0) 66 #define CLOCK_TO_SYSTEM(t) \ 67 (uint32_t)(((uint64_t)(t) * 1000 * 1000) / (CLOCK_SECOND * ClockP_getSystemTickPeriod())) 68 #define SYSTEM_TO_CLOCK(t) \ 69 (clock_time_t)(((uint64_t)(t) * CLOCK_SECOND * ClockP_getSystemTickPeriod()) / (1000 * 1000)) 71 #define RTC_SUBSEC_FRAC ((uint64_t)1 << 32) 77 clock_time_t next_etimer;
83 if(!CLOCK_LT(now, next_etimer)) {
96 wakeup_fxn(uintptr_t arg)
103 get_etimer_timeout(
void)
106 clock_time_t next_etimer;
112 if(!CLOCK_LT(now, next_etimer)) {
119 return CLOCK_TO_SYSTEM(next_etimer - now);
128 get_watchdog_timeout(
void)
130 #if (WATCHDOG_DISABLE == 0) 152 uint32_t etimer_timeout;
153 uint32_t watchdog_timeout;
156 etimer_timeout = get_etimer_timeout();
157 watchdog_timeout = get_watchdog_timeout();
159 timeout = MIN(etimer_timeout, watchdog_timeout);
164 if(timeout == NO_TIMEOUT) {
173 ClockP_setTimeout(H_WAKEUP_CLK, timeout);
174 ClockP_start(H_WAKEUP_CLK);
181 ClockP_stop(H_WAKEUP_CLK);
187 ClockP_Params clk_params;
190 ClockP_Params_init(&clk_params);
191 clk_params.startFlag =
false;
192 clk_params.period = 0;
193 ClockP_construct(&wakeup_clk, wakeup_fxn, 0, &clk_params);
195 ClockP_getCpuFreq(&freq);
198 SysTickIntRegister(systick_fxn);
210 uint64_t now = AONRTCCurrent64BitValueGet();
211 clock_time_t ticks = (clock_time_t)(now / (RTC_SUBSEC_FRAC /
CLOCK_SECOND));
218 unsigned long sec = (
unsigned long)AONRTCSecGet();
void clock_delay(unsigned int i)
Obsolete delay function but we implement it here since some code still uses it.
void etimer_request_poll(void)
Make the event timer aware that the clock has changed.
clock_time_t clock_time(void)
Get the current clock time.
Header file of the CC13xx/CC26xx watchdog driver.
bool clock_arch_enter_idle(void)
Prepare to enter some low-power mode.
clock_time_t etimer_next_expiration_time(void)
Get next event timer expiration time.
#define CLOCK_SECOND
A second, measured in system clock time.
void clock_arch_exit_idle(void)
Cleanup after returning from low-power mode.
uint32_t watchdog_arch_next_timeout(void)
Return the next expiration time for the Watchdog.
void clock_wait(clock_time_t i)
Wait for a given number of ticks.
int etimer_pending(void)
Check if there are any non-expired event timers.
void clock_init(void)
Initialize the clock library.
unsigned long clock_seconds(void)
Get the current value of the platform seconds.
Default definitions of C compiler quirk work-arounds.
void clock_delay_usec(uint16_t usec)
Delay a given number of microseconds.