55 #define PRINTF(...) printf(__VA_ARGS__)
60 static uint32_t last_rtc;
66 if ((CRM->RTC_COUNT - last_rtc) <= 2) {
73 last_rtc = CRM->RTC_COUNT;
87 last_rtc = CRM->RTC_COUNT;
92 CRM->WU_CNTLbits.RTC_WU_EN = 1;
93 CRM->WU_CNTLbits.RTC_WU_IEN = 1;
100 volatile uint32_t now;
102 PRINTF(
"rtimer_arch_schedule time %u; now is %u\n", t, now);
107 CRM->RTC_TIMEOUT = 1;
109 CRM->RTC_TIMEOUT = t - now;
114 rtimer_arch_sleep(rtimer_clock_t howlong)
116 CRM->WU_CNTLbits.TIMER_WU_EN = 1;
117 CRM->WU_CNTLbits.RTC_WU_EN = 0;
118 CRM->WU_TIMEOUT = howlong;
124 CRM->SLEEP_CNTLbits.DOZE = 0;
125 CRM->SLEEP_CNTLbits.RAM_RET = 3;
126 CRM->SLEEP_CNTLbits.MCU_RET = 1;
127 CRM->SLEEP_CNTLbits.DIG_PAD_EN = 1;
128 CRM->SLEEP_CNTLbits.HIB = 1;
131 while((*CRM_STATUS & 0x1) == 0) {
continue; }
138 while((*CRM_STATUS & 0x1) == 0) {
continue; }
142 CRM->WU_CNTLbits.TIMER_WU_EN = 0;
143 CRM->WU_CNTLbits.RTC_WU_EN = 1;
void rtimer_arch_init(void)
We don't need to explicitly initialise anything but this routine is required by the API...
void clock_init(void)
Initialize the clock library.
#define rtimer_arch_now()
Header file for the energy estimation mechanism
void clock_adjust_ticks(clock_time_t howmany)
Adjust the system current clock time.
Header file for the real-time timer module.
void rtimer_arch_schedule(rtimer_clock_t t)
Schedules an rtimer task to be triggered at time t.
void rtimer_run_next(void)
Execute the next real-time task and schedule the next task, if any.