Skip to content

Commit

Permalink
[beken-72xx] Fix duration rollover in deep sleep (#253)
Browse files Browse the repository at this point in the history
  • Loading branch information
cap9qd authored Feb 22, 2024
1 parent b748d99 commit b78c938
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cores/beken-72xx/base/api/lt_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map) {
deep_sleep_param.gpio_index_map &= (~gpio_index_map);
}

void lt_deep_sleep_config_timer(uint32_t sleep_duration) {
void lt_deep_sleep_config_timer(uint32_t sleep_duration_ms) {
deep_sleep_param.wake_up_way |= PS_DEEP_WAKEUP_RTC;
uint64_t duration_math = 32768 * sleep_duration;
if (duration_math / 1000 > 0xFFFFFFFF) {
// Sleep forever
deep_sleep_param.sleep_time = 0xFFFFFFFF;
uint64_t sleep_ticks = 32.768 * sleep_duration_ms;
if (sleep_ticks >= 0xFFFFFFFF) {
deep_sleep_param.sleep_time = 0xFFFFFFFE;
} else {
deep_sleep_param.sleep_time = (duration_math / 1000) & 0xFFFFFFFF;
deep_sleep_param.sleep_time = sleep_ticks & 0xFFFFFFFF;
}
}

Expand Down

0 comments on commit b78c938

Please sign in to comment.