diff options
| author | Peter Harper <peter.harper@raspberrypi.com> | 2024-10-09 18:03:55 +0100 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2024-12-19 16:54:39 +1100 |
| commit | 4a6c2460083607ba05ab8af13a31889767c2ce98 (patch) | |
| tree | 77a899450a10452ff283a69f2bf802f1f1a6396f | |
| parent | 30163e0ae483a3c04e57f8346e903a6bc2e0e2cd (diff) | |
rp2/mphalport: Add mp_hal_is_pin_reserved() function.
As cyw43 pins might be dynamic, add a function that returns if a pin is
reserved. This is used by `MICROPY_HW_PIN_RESERVED` to prevent the pin IRQ
from being reset across a soft-reset.
Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
| -rw-r--r-- | ports/rp2/boards/RPI_PICO_W/mpconfigboard.h | 4 | ||||
| -rw-r--r-- | ports/rp2/mphalport.c | 8 | ||||
| -rw-r--r-- | ports/rp2/mphalport.h | 1 |
3 files changed, 12 insertions, 1 deletions
diff --git a/ports/rp2/boards/RPI_PICO_W/mpconfigboard.h b/ports/rp2/boards/RPI_PICO_W/mpconfigboard.h index ef812b630..45ad6107b 100644 --- a/ports/rp2/boards/RPI_PICO_W/mpconfigboard.h +++ b/ports/rp2/boards/RPI_PICO_W/mpconfigboard.h @@ -20,4 +20,6 @@ #define MICROPY_HW_PIN_EXT_COUNT CYW43_WL_GPIO_COUNT -#define MICROPY_HW_PIN_RESERVED(i) ((i) == CYW43_PIN_WL_HOST_WAKE || (i) == CYW43_PIN_WL_REG_ON) +// If this returns true for a pin then its irq will not be disabled on a soft reboot +int mp_hal_is_pin_reserved(int n); +#define MICROPY_HW_PIN_RESERVED(i) mp_hal_is_pin_reserved(i) diff --git a/ports/rp2/mphalport.c b/ports/rp2/mphalport.c index 3f5015162..caecb6950 100644 --- a/ports/rp2/mphalport.c +++ b/ports/rp2/mphalport.c @@ -278,3 +278,11 @@ void mp_wfe_or_timeout(uint32_t timeout_ms) { // Clean up the timer node if it's not already soft_timer_remove(&timer); } + +int mp_hal_is_pin_reserved(int n) { + #if MICROPY_PY_NETWORK_CYW43 + return n == CYW43_PIN_WL_HOST_WAKE; + #else + return false; + #endif +} diff --git a/ports/rp2/mphalport.h b/ports/rp2/mphalport.h index da865fb7e..33a1073e1 100644 --- a/ports/rp2/mphalport.h +++ b/ports/rp2/mphalport.h @@ -210,5 +210,6 @@ enum { void mp_hal_get_mac(int idx, uint8_t buf[6]); void mp_hal_get_mac_ascii(int idx, size_t chr_off, size_t chr_len, char *dest); void mp_hal_generate_laa_mac(int idx, uint8_t buf[6]); +int mp_hal_is_pin_reserved(int n); #endif // MICROPY_INCLUDED_RP2_MPHALPORT_H |
