File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
peripherals/stm32l4/stm32l4r5xx Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change
1
+ import board
2
+ import digitalio
3
+ import time
4
+
5
+ def monitor_button (pin , callback ):
6
+ with digitalio .DigitalInOut (pin ) as button :
7
+ newstate = not button .value # state is inverted
8
+ state = not newstate # ensure change reported to start with
9
+ while callback (newstate , newstate != state ):
10
+ state = newstate
11
+ newstate = button .value
12
+ time .sleep (0.01 )
13
+
14
+ def print_changes (state , changed ):
15
+ if changed :
16
+ print (f"button pressed { state } " )
17
+ return True
18
+
19
+ monitor_button (board .BUTTON_USR , print_changes )
20
+
21
+
Original file line number Diff line number Diff line change @@ -38,7 +38,6 @@ void stm32_peripherals_gpio_init(void) {
38
38
__HAL_RCC_GPIOG_CLK_ENABLE ();
39
39
40
40
// Never reset pins
41
- never_reset_pin_number (2 ,13 ); // PC13 anti tamp
42
41
never_reset_pin_number (2 ,14 ); // PC14 OSC32_IN
43
42
never_reset_pin_number (2 ,15 ); // PC15 OSC32_OUT
44
43
never_reset_pin_number (0 ,13 ); // PA13 SWDIO
You can’t perform that action at this time.
0 commit comments