Skip to content

Commit

Permalink
Wakeup: Move wakeup pin assert and latch out of patches.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Sep 17, 2024
1 parent 8c7b209 commit c1018db
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 315 deletions.
136 changes: 0 additions & 136 deletions micropython/board/PICO_W_ENVIRO/pico_sdk.patch

This file was deleted.

136 changes: 0 additions & 136 deletions micropython/board/PICO_W_INKY/pico_sdk.patch

This file was deleted.

3 changes: 3 additions & 0 deletions micropython/modules/micropython-enviro.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ include(wakeup/micropython)
# Configure wakeup for Enviro
target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_HAS_RTC=1
-DWAKEUP_PIN_MASK=0b01000100
-DWAKEUP_PIN_DIR=0b01000100
-DWAKEUP_PIN_VALUE=0b01000100
)

# LEDs & Matrices
Expand Down
3 changes: 3 additions & 0 deletions micropython/modules/micropython-inky_frame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ include(wakeup/micropython)
target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_HAS_RTC=1
-DWAKEUP_HAS_SHIFT_REGISTER=1
-DWAKEUP_PIN_MASK=0b01000100
-DWAKEUP_PIN_DIR=0b01000100
-DWAKEUP_PIN_VALUE=0b01000100
)

# LEDs & Matrices
Expand Down
1 change: 0 additions & 1 deletion micropython/modules/wakeup/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ add_library(usermod_${MOD_NAME} INTERFACE)
target_sources(usermod_${MOD_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.cpp
#${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.S
)

target_include_directories(usermod_${MOD_NAME} INTERFACE
Expand Down
36 changes: 0 additions & 36 deletions micropython/modules/wakeup/wakeup.S

This file was deleted.

24 changes: 18 additions & 6 deletions micropython/modules/wakeup/wakeup.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#include "hardware/gpio.h"
#include "wakeup.config.hpp"

extern uint32_t runtime_wakeup_gpio_state;

namespace {
struct Wakeup {
public:
uint8_t shift_register_state = 0b0;
uint32_t gpio_state = 0;

Wakeup() {
// Assert wakeup pins (indicator LEDs, VSYS hold etc)
//gpio_init_mask(WAKEUP_PIN_MASK);
//gpio_set_dir_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_DIR);
//gpio_put_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_VALUE);
gpio_init_mask(WAKEUP_PIN_MASK);
gpio_set_dir_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_DIR);
gpio_put_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_VALUE);

// Init all GPIOS not specified in the wakeup mask
#if PICO_RP2350
gpio_init_mask(~WAKEUP_PIN_MASK);
gpio_set_dir_in_masked(~WAKEUP_PIN_MASK);
#endif
gpio_state = gpio_get_all();
sleep_ms(5);
gpio_state |= gpio_get_all();
#if PICO_RP2350
gpio_init_mask(~WAKEUP_PIN_MASK);
#endif

#if WAKEUP_HAS_RTC==1
// Set up RTC I2C pins and send reset command
Expand Down Expand Up @@ -59,11 +71,11 @@ extern "C" {
#include "wakeup.h"

mp_obj_t Wakeup_get_gpio_state() {
return mp_obj_new_int(runtime_wakeup_gpio_state);
return mp_obj_new_int(wakeup.gpio_state);
}

mp_obj_t Wakeup_reset_gpio_state() {
runtime_wakeup_gpio_state = 0;
wakeup.gpio_state = 0;
return mp_const_none;
}

Expand Down

0 comments on commit c1018db

Please sign in to comment.