37
37
#ifdef MICROPY_HW_NEOPIXEL
38
38
bool neopixel_in_use ;
39
39
#endif
40
- #ifdef MICROPY_HW_APA102_MOSI
41
- bool apa102_sck_in_use ;
42
- bool apa102_mosi_in_use ;
43
- #endif
44
40
45
41
STATIC uint32_t never_reset_pins [2 ];
46
42
STATIC uint32_t in_use [2 ];
47
43
44
+ bool apa102_mosi_in_use ;
45
+ bool apa102_sck_in_use ;
46
+
48
47
STATIC void floating_gpio_reset (gpio_num_t pin_number ) {
49
48
// This is the same as gpio_reset_pin(), but without the pullup.
50
49
// Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
@@ -87,20 +86,6 @@ void reset_pin_number(gpio_num_t pin_number) {
87
86
return ;
88
87
}
89
88
#endif
90
- #ifdef MICROPY_HW_APA102_MOSI
91
- if (pin_number == MICROPY_HW_APA102_MOSI -> number ||
92
- pin_number == MICROPY_HW_APA102_SCK -> number ) {
93
- apa102_mosi_in_use = apa102_mosi_in_use && pin_number != MICROPY_HW_APA102_MOSI -> number ;
94
- apa102_sck_in_use = apa102_sck_in_use && pin_number != MICROPY_HW_APA102_SCK -> number ;
95
- if (!apa102_sck_in_use && !apa102_mosi_in_use ) {
96
- rgb_led_status_init ();
97
- }
98
- return ;
99
- }
100
- #endif
101
-
102
-
103
-
104
89
}
105
90
106
91
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
@@ -125,11 +110,6 @@ void reset_all_pins(void) {
125
110
#ifdef MICROPY_HW_NEOPIXEL
126
111
neopixel_in_use = false;
127
112
#endif
128
- #ifdef MICROPY_HW_APA102_MOSI
129
- apa102_sck_in_use = false;
130
- apa102_mosi_in_use = false;
131
- #endif
132
-
133
113
}
134
114
135
115
void claim_pin (const mcu_pin_obj_t * pin ) {
@@ -139,15 +119,6 @@ void claim_pin(const mcu_pin_obj_t* pin) {
139
119
neopixel_in_use = true;
140
120
}
141
121
#endif
142
- #ifdef MICROPY_HW_APA102_MOSI
143
- if (pin == MICROPY_HW_APA102_MOSI ) {
144
- apa102_mosi_in_use = true;
145
- }
146
- if (pin == MICROPY_HW_APA102_SCK ) {
147
- apa102_sck_in_use = true;
148
- }
149
- #endif
150
-
151
122
}
152
123
153
124
void common_hal_mcu_pin_claim (const mcu_pin_obj_t * pin ) {
@@ -160,18 +131,10 @@ bool pin_number_is_free(gpio_num_t pin_number) {
160
131
return !neopixel_in_use ;
161
132
}
162
133
#endif
163
- #ifdef MICROPY_HW_APA102_MOSI
164
- if (pin_number == MICROPY_HW_APA102_MOSI -> number ) {
165
- return !apa102_mosi_in_use ;
166
- }
167
- if (pin_number == MICROPY_HW_APA102_SCK -> number ) {
168
- return !apa102_sck_in_use ;
169
- }
170
- #endif
171
134
172
135
uint8_t offset = pin_number / 32 ;
173
136
uint32_t mask = 1 << (pin_number % 32 );
174
- return (in_use [offset ] & mask ) == 0 ;
137
+ return (never_reset_pins [ offset ] & mask ) == 0 && ( in_use [offset ] & mask ) == 0 ;
175
138
}
176
139
177
140
bool common_hal_mcu_pin_is_free (const mcu_pin_obj_t * pin ) {
0 commit comments