Skip to content

Commit

Permalink
[beken-72xx] Allow setting deep sleep wake-up pins as floating (#275)
Browse files Browse the repository at this point in the history
According to guide `gpio_stay_*_map` are specifically there to prevent
pulling pins to a specific level and let them float during deep sleep.

https://docs.bekencorp.com/sdk_3.0.x/bk7238/build/en/latest/developer-guide/power_save/sleep_test.html

This allows any external low-power circuitry to change a pin level, as
required, to trigger the wake up

This requires changes in BDK and was implemented via fixup. Also, exposed
`gpio_stay_lo_map` parameter via `lt_deep_sleep_keep_floating_gpio` to
manage this configuration for pins in range P0-P31.
  • Loading branch information
devgs authored Sep 5, 2024
1 parent fbaae21 commit e1c5761
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cores/beken-72xx/base/api/lt_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ void lt_deep_sleep_unset_gpio(uint32_t gpio_index_map) {
deep_sleep_param.gpio_index_map &= (~gpio_index_map);
}

void lt_deep_sleep_keep_floating_gpio(uint32_t gpio_index_map, bool enabled) {
if (enabled) {
deep_sleep_param.gpio_stay_lo_map |= gpio_index_map;
} else {
deep_sleep_param.gpio_stay_lo_map &= (~gpio_index_map);
}
}

void lt_deep_sleep_config_timer(uint32_t sleep_duration_ms) {
deep_sleep_param.wake_up_way |= PS_DEEP_WAKEUP_RTC;
uint64_t sleep_ticks = 32.768 * sleep_duration_ms;
Expand All @@ -33,7 +41,7 @@ void lt_deep_sleep_enter() {
bk_misc_update_set_type(RESET_SOURCE_DEEPPS_GPIO);
GLOBAL_INT_DECLARATION();
GLOBAL_INT_DISABLE();
sctrl_enter_rtos_deep_sleep((PS_DEEP_CTRL_PARAM *)&deep_sleep_param);
sctrl_enter_rtos_deep_sleep_fix((PS_DEEP_CTRL_PARAM *)&deep_sleep_param);
ps_delay(500);
GLOBAL_INT_RESTORE();
}
Loading

0 comments on commit e1c5761

Please sign in to comment.