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> 54 #include <ti/drivers/power/PowerCC26XX.h> 61 static ClockP_Struct wakeup_clk;
63 #define H_WAKEUP_CLK (ClockP_handle(&wakeup_clk)) 65 #define NO_TIMEOUT (~(uint32_t)0) 67 #define CLOCK_TO_SYSTEM(t) \ 68 (uint32_t)(((uint64_t)(t) * 1000 * 1000) / (CLOCK_SECOND * ClockP_getSystemTickPeriod())) 69 #define SYSTEM_TO_CLOCK(t) \ 70 (clock_time_t)(((uint64_t)(t) * CLOCK_SECOND * ClockP_getSystemTickPeriod()) / (1000 * 1000)) 72 #define RTC_SUBSEC_FRAC ((uint64_t)1 << 32) 78 clock_time_t next_etimer;
84 if(!CLOCK_LT(now, next_etimer)) {
97 wakeup_fxn(uintptr_t arg)
104 get_etimer_timeout(
void)
107 clock_time_t next_etimer;
113 if(!CLOCK_LT(now, next_etimer)) {
120 return CLOCK_TO_SYSTEM(next_etimer - now);
129 get_watchdog_timeout(
void)
131 #if (WATCHDOG_DISABLE == 0) 153 uint32_t etimer_timeout;
154 uint32_t watchdog_timeout;
157 etimer_timeout = get_etimer_timeout();
158 watchdog_timeout = get_watchdog_timeout();
160 timeout = MIN(etimer_timeout, watchdog_timeout);
169 if(timeout != NO_TIMEOUT) {
170 ClockP_setTimeout(H_WAKEUP_CLK, timeout);
171 ClockP_start(H_WAKEUP_CLK);
180 ClockP_stop(H_WAKEUP_CLK);
194 PowerCC26XX_standbyPolicy();
202 ClockP_Params clk_params;
205 ClockP_Params_init(&clk_params);
206 clk_params.startFlag =
false;
207 clk_params.period = 0;
208 ClockP_construct(&wakeup_clk, wakeup_fxn, 0, &clk_params);
210 ClockP_getCpuFreq(&freq);
213 SysTickIntRegister(systick_fxn);
225 uint64_t now = AONRTCCurrent64BitValueGet();
226 clock_time_t ticks = (clock_time_t)(now / (RTC_SUBSEC_FRAC /
CLOCK_SECOND));
233 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.
void clock_arch_standby_policy(void)
Called by the Power driver when dropping to some low-power state.