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>
This commit is contained in:
Phil Howard 2025-03-11 10:50:22 +00:00 committed by Damien George
parent 1d5dc723b4
commit e75ffc3bcc

View file

@ -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,