mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-18 12:52:44 +01:00
cpu/esp32: small fix of rtc_init for light sleep
`rtc_init` is used after light sleep to update the system time from RTC timer. The fix corrects a small difference of about 230 ms which would sum up with each wakeup from light sleep.
This commit is contained in:
parent
825b01e8e1
commit
2cbf90d9fe
@ -101,21 +101,19 @@ static void IRAM_ATTR _rtc_timer_handler(void* arg);
|
||||
|
||||
void rtc_init(void)
|
||||
{
|
||||
uint64_t _rtc_time_us = _rtc_time_to_us(_rtc_get_time_raw());
|
||||
uint64_t _rtc_time = _rtc_get_time_raw();
|
||||
uint64_t _rtc_time_us = _rtc_time_to_us(_rtc_time);
|
||||
|
||||
if (_rtc_time_init == 0 && _rtc_time_init_us == 0) {
|
||||
/* only set it new, if it was not set before */
|
||||
_rtc_time_init = _rtc_get_time_raw();
|
||||
_rtc_time_init = _rtc_time;
|
||||
_rtc_time_init_us = _rtc_time_us;
|
||||
_sys_time_off_us = 0;
|
||||
|
||||
DEBUG("%s saved rtc_init=%lld rtc_init_us=%lld\n",
|
||||
__func__, _rtc_time_init, _rtc_time_init_us);
|
||||
|
||||
}
|
||||
else {
|
||||
_sys_time_off_us = _rtc_time_us - _rtc_time_set_us;
|
||||
}
|
||||
_sys_time_off_us = _rtc_time_us - _rtc_time_set_us - system_get_time_64();
|
||||
_sys_time_set_us = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user