Skip to content

Commit e75ffc3

Browse files
Gadgetoidkilograham
authored andcommitted
rp2/modrp2: Fix rp2.bootsel_button() function for RP2350.
Co-authored-by: graham sanderson <[email protected]> Signed-off-by: Phil Howard <[email protected]>
1 parent 1d5dc72 commit e75ffc3

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

ports/rp2/modrp2.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,17 @@
4242
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj);
4343
#endif
4444

45+
#define CS_PIN_INDEX 1
46+
47+
#if PICO_RP2040
48+
#define CS_BIT (1u << CS_PIN_INDEX)
49+
#else
50+
#define CS_BIT SIO_GPIO_HI_IN_QSPI_CSN_BITS
51+
#endif
52+
4553
// Improved version of
4654
// https://github.com/raspberrypi/pico-examples/blob/master/picoboard/button/button.c
4755
static bool __no_inline_not_in_flash_func(bootsel_button)(void) {
48-
const uint CS_PIN_INDEX = 1;
49-
5056
// Disable interrupts and the other core since they might be
5157
// executing code from flash and we are about to temporarily
5258
// disable flash access.
@@ -65,7 +71,7 @@ static bool __no_inline_not_in_flash_func(bootsel_button)(void) {
6571

6672
// The HI GPIO registers in SIO can observe and control the 6 QSPI pins.
6773
// The button pulls the QSPI_SS pin *low* when pressed.
68-
bool button_state = !(sio_hw->gpio_hi_in & (1 << CS_PIN_INDEX));
74+
bool button_state = !(sio_hw->gpio_hi_in & CS_BIT);
6975

7076
// Restore the QSPI_SS pin so we can use flash again.
7177
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,

0 commit comments

Comments
 (0)