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
40
44
41
45
STATIC uint32_t never_reset_pins [2 ];
42
46
STATIC uint32_t in_use [2 ];
43
47
44
- bool apa102_mosi_in_use ;
45
- bool apa102_sck_in_use ;
46
-
47
48
STATIC void floating_gpio_reset (gpio_num_t pin_number ) {
48
49
// This is the same as gpio_reset_pin(), but without the pullup.
49
50
// Note that gpio_config resets the iomatrix to GPIO_FUNC as well.
@@ -86,6 +87,20 @@ void reset_pin_number(gpio_num_t pin_number) {
86
87
return ;
87
88
}
88
89
#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
+
89
104
}
90
105
91
106
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
@@ -110,6 +125,11 @@ void reset_all_pins(void) {
110
125
#ifdef MICROPY_HW_NEOPIXEL
111
126
neopixel_in_use = false;
112
127
#endif
128
+ #ifdef MICROPY_HW_APA102_MOSI
129
+ apa102_sck_in_use = false;
130
+ apa102_mosi_in_use = false;
131
+ #endif
132
+
113
133
}
114
134
115
135
void claim_pin (const mcu_pin_obj_t * pin ) {
@@ -119,6 +139,15 @@ void claim_pin(const mcu_pin_obj_t* pin) {
119
139
neopixel_in_use = true;
120
140
}
121
141
#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
+
122
151
}
123
152
124
153
void common_hal_mcu_pin_claim (const mcu_pin_obj_t * pin ) {
@@ -131,6 +160,14 @@ bool pin_number_is_free(gpio_num_t pin_number) {
131
160
return !neopixel_in_use ;
132
161
}
133
162
#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
134
171
135
172
uint8_t offset = pin_number / 32 ;
136
173
uint32_t mask = 1 << (pin_number % 32 );
0 commit comments