Skip to content

picow: Turn off wifi co-processor regulator when entering deep sleep #7050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ports/raspberrypi/bindings/cyw43/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@

static int power_management_value = PM_DISABLED;

void cyw43_enter_deep_sleep(void) {
#define WL_REG_ON 23
gpio_set_dir(WL_REG_ON, GPIO_OUT);
gpio_put(WL_REG_ON, false);
}

void bindings_cyw43_wifi_enforce_pm() {
cyw43_wifi_pm(&cyw43_state, power_management_value);
}
Expand Down
1 change: 1 addition & 0 deletions ports/raspberrypi/bindings/cyw43/__init__.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ const mcu_pin_obj_t *validate_obj_is_pin_including_cyw43(mp_obj_t obj);
#define PM_DISABLED CONSTANT_CYW43_PM_VALUE(CYW43_NO_POWERSAVE_MODE, 200, 1, 1, 10)

extern void bindings_cyw43_wifi_enforce_pm(void);
void cyw43_enter_deep_sleep(void);
8 changes: 8 additions & 0 deletions ports/raspberrypi/common-hal/alarm/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

#include "shared-bindings/microcontroller/__init__.h"

#if CIRCUITPY_CYW43
#include "bindings/cyw43/__init__.h"
#endif

#include "supervisor/port.h"
#include "supervisor/shared/workflow.h"

Expand Down Expand Up @@ -204,6 +208,10 @@ void common_hal_alarm_set_deep_sleep_alarms(size_t n_alarms, const mp_obj_t *ala
void NORETURN common_hal_alarm_enter_deep_sleep(void) {
bool timealarm_set = alarm_time_timealarm_is_set();

#if CIRCUITPY_CYW43
cyw43_enter_deep_sleep();
#endif

// If there's a timealarm, just enter a very deep light sleep
if (timealarm_set) {
// Prune the clock for sleep
Expand Down