static void _sleep_entry(void) { rt_tick_t timeout; rt_uint32_t ms; rt_uint32_t count; system_set_sleepmode(SYSTEM_SLEEPMODE_STANDBY); timeout = rt_timer_next_timeout_tick() - rt_tick_get(); ms = timeout * (1000 / RT_TICK_PER_SECOND); rt_kprintf("os tick:%u entry sleep:%u tick\r\n", rt_tick_get(), timeout); _rtc_timer_start(ms); system_sleep(); rt_enter_critical(); count = rtc_count_get_count(&rtc_instance); ms = (count + 32) / 32.768; rtc_count_disable(&rtc_instance); sleep_tick_adjust(ms); timeout = rt_tick_get(); rt_exit_critical(); rt_kprintf("sleep exited, os tick:%u\n", timeout); }
/** Reads the RTC value * * Reads and return the current time in RTC * @param[void] void * @return the current value in RTC */ time_t rtc_read(void) { if (!rtc_inited) { /* Return invalid time for now! */ return 0; } return (time_t)rtc_count_get_count(&rtc_instance); }
/*---------------------------------------------------------------------------*/ rtimer_clock_t rtimer_arch_now(void) { return rtc_count_get_count(&rtc_instance); }