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:
parent
1d5dc723b4
commit
e75ffc3bcc
1 changed files with 9 additions and 3 deletions
|
|
@ -42,11 +42,17 @@
|
||||||
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj);
|
MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(mod_network_country_obj);
|
||||||
#endif
|
#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
|
// Improved version of
|
||||||
// https://github.com/raspberrypi/pico-examples/blob/master/picoboard/button/button.c
|
// https://github.com/raspberrypi/pico-examples/blob/master/picoboard/button/button.c
|
||||||
static bool __no_inline_not_in_flash_func(bootsel_button)(void) {
|
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
|
// Disable interrupts and the other core since they might be
|
||||||
// executing code from flash and we are about to temporarily
|
// executing code from flash and we are about to temporarily
|
||||||
// disable flash access.
|
// 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 HI GPIO registers in SIO can observe and control the 6 QSPI pins.
|
||||||
// The button pulls the QSPI_SS pin *low* when pressed.
|
// 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.
|
// Restore the QSPI_SS pin so we can use flash again.
|
||||||
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
|
hw_write_masked(&ioqspi_hw->io[CS_PIN_INDEX].ctrl,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue