File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed
ports/raspberrypi/common-hal/microcontroller Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change 31
31
32
32
#include "src/rp2_common/hardware_gpio/include/hardware/gpio.h"
33
33
34
+ static uint32_t gpio_bank0_pin_claimed ;
35
+
34
36
#if CIRCUITPY_CYW43
35
37
#include "bindings/cyw43/__init__.h"
36
38
#include "pico/cyw43_arch.h"
@@ -76,6 +78,7 @@ void reset_pin_number(uint8_t pin_number) {
76
78
return ;
77
79
}
78
80
81
+ gpio_bank0_pin_claimed &= ~(1 << pin_number );
79
82
never_reset_pins &= ~(1 << pin_number );
80
83
81
84
// We are very aggressive in shutting down the pad fully. Both pulls are
@@ -105,19 +108,20 @@ void claim_pin(const mcu_pin_obj_t *pin) {
105
108
#if CIRCUITPY_CYW43
106
109
if (pin -> base .type == & cyw43_pin_type ) {
107
110
cyw_pin_claimed |= (1 << pin -> number );
111
+ return ;
108
112
}
109
113
#endif
110
- // Nothing to do because all changes will set the GPIO settings.
114
+ if (pin -> number >= NUM_BANK0_GPIOS ) {
115
+ return ;
116
+ }
117
+ gpio_bank0_pin_claimed |= (1 << pin -> number );
111
118
}
112
119
113
120
bool pin_number_is_free (uint8_t pin_number ) {
114
121
if (pin_number >= NUM_BANK0_GPIOS ) {
115
122
return false;
116
123
}
117
-
118
- uint32_t pad_state = padsbank0_hw -> io [pin_number ];
119
- return (pad_state & PADS_BANK0_GPIO0_IE_BITS ) == 0 &&
120
- (pad_state & PADS_BANK0_GPIO0_OD_BITS ) != 0 ;
124
+ return !(gpio_bank0_pin_claimed & (1 << pin_number ));
121
125
}
122
126
123
127
bool common_hal_mcu_pin_is_free (const mcu_pin_obj_t * pin ) {
You can’t perform that action at this time.
0 commit comments