diff --git a/ports/stm/boards/swan_r5/tests/button.py b/ports/stm/boards/swan_r5/tests/button.py new file mode 100644 index 0000000000..58825452da --- /dev/null +++ b/ports/stm/boards/swan_r5/tests/button.py @@ -0,0 +1,21 @@ +import board +import digitalio +import time + +def monitor_button(pin, callback): + with digitalio.DigitalInOut(pin) as button: + newstate = not button.value # state is inverted + state = not newstate # ensure change reported to start with + while callback(newstate, newstate!=state): + state = newstate + newstate = button.value + time.sleep(0.01) + +def print_changes(state, changed): + if changed: + print(f"button pressed {state}") + return True + +monitor_button(board.BUTTON_USR, print_changes) + + diff --git a/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c index 9cd4c7240d..cfd65771ae 100644 --- a/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c +++ b/ports/stm/peripherals/stm32l4/stm32l4r5xx/gpio.c @@ -38,7 +38,6 @@ void stm32_peripherals_gpio_init(void) { __HAL_RCC_GPIOG_CLK_ENABLE(); // Never reset pins - never_reset_pin_number(2,13); // PC13 anti tamp never_reset_pin_number(2,14); // PC14 OSC32_IN never_reset_pin_number(2,15); // PC15 OSC32_OUT never_reset_pin_number(0,13); // PA13 SWDIO