diff options
-rw-r--r-- | ports/rp2/modrp2.c | 12 |
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, |