summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Howard <github@gadgetoid.com>2025-03-11 10:50:22 +0000
committerDamien George <damien@micropython.org>2025-03-13 13:54:43 +1100
commite75ffc3bccb8b213704f0ddd2ce82731ab2069ba (patch)
treeafe8e4be19e7ba24fb4a940f57eb6ff987947edc
parent1d5dc723b40d978b84da2f9b1a48e880777385ea (diff)
rp2/modrp2: Fix rp2.bootsel_button() function for RP2350.
Co-authored-by: graham sanderson <graham.sanderson@raspberrypi.com> Signed-off-by: Phil Howard <github@gadgetoid.com>
-rw-r--r--ports/rp2/modrp2.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/ports/rp2/modrp2.c b/ports/rp2/modrp2.c
index c90b6d584..5a43c11e7 100644
--- a/ports/rp2/modrp2.c
+++ b/ports/rp2/modrp2.c
@@ -42,11 +42,17 @@
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj);
#endif
+#define CS_PIN_INDEX 1
+
+#if PICO_RP2040
+#define CS_BIT (1u << CS_PIN_INDEX)
+#else
+#define CS_BIT SIO_GPIO_HI_IN_QSPI_CSN_BITS
+#endif
+
// Improved version of
// https://github.com/raspberrypi/pico-examples/blob/master/picoboard/button/button.c
static bool __no_inline_not_in_flash_func(bootsel_button)(void) {
- const uint CS_PIN_INDEX = 1;
-
// Disable interrupts and the other core since they might be
// executing code from flash and we are about to temporarily
// disable flash access.
@@ -65,7 +71,7 @@ static bool __no_inline_not_in_flash_func(bootsel_button)(void) {
// The HI GPIO registers in SIO can observe and control the 6 QSPI pins.
// The button pulls the QSPI_SS pin *low* when pressed.
- bool button_state = !(sio_hw->gpio_hi_in & (1 << CS_PIN_INDEX));
+ bool button_state = !(sio_hw->gpio_hi_in & CS_BIT);
// Restore the QSPI_SS pin so we can use flash again.
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,