File tree 10 files changed +28
-21
lines changed
atmel-samd/common-hal/microcontroller
litex/common-hal/microcontroller
nrf/common-hal/microcontroller
stm/common-hal/microcontroller 10 files changed +28
-21
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
169
169
}
170
170
171
171
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
172
+ if (pin == NULL ) {
173
+ return ;
174
+ }
172
175
reset_pin_number (pin -> number );
173
176
}
174
177
Original file line number Diff line number Diff line change @@ -248,12 +248,8 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
248
248
spi_bus_free (self -> host_id );
249
249
250
250
common_hal_reset_pin (self -> clock_pin );
251
- if (self -> MOSI_pin != NULL ) {
252
- common_hal_reset_pin (self -> MOSI_pin );
253
- }
254
- if (self -> MISO_pin != NULL ) {
255
- common_hal_reset_pin (self -> MISO_pin );
256
- }
251
+ common_hal_reset_pin (self -> MOSI_pin );
252
+ common_hal_reset_pin (self -> MISO_pin );
257
253
self -> clock_pin = NULL ;
258
254
self -> MISO_pin = NULL ;
259
255
self -> MOSI_pin = NULL ;
Original file line number Diff line number Diff line change @@ -89,6 +89,9 @@ void reset_pin_number(gpio_num_t pin_number) {
89
89
}
90
90
91
91
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
92
+ if (pin == NULL ) {
93
+ return ;
94
+ }
92
95
reset_pin_number (pin -> number );
93
96
}
94
97
Original file line number Diff line number Diff line change @@ -42,6 +42,9 @@ void reset_pin_number(uint8_t pin_port, uint8_t pin_number) {
42
42
}
43
43
44
44
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
45
+ if (pin == NULL ) {
46
+ return ;
47
+ }
45
48
reset_pin_number (0 , pin -> number );
46
49
}
47
50
Original file line number Diff line number Diff line change @@ -220,12 +220,9 @@ void common_hal_busio_spi_deinit(busio_spi_obj_t *self) {
220
220
never_reset_spi [self -> clock -> bank_idx - 1 ] = false;
221
221
222
222
common_hal_reset_pin (self -> clock -> pin );
223
- if (self -> mosi != NULL ) {
224
- common_hal_reset_pin (self -> mosi -> pin );
225
- }
226
- if (self -> miso != NULL ) {
227
- common_hal_reset_pin (self -> miso -> pin );
228
- }
223
+ common_hal_reset_pin (self -> mosi -> pin );
224
+ common_hal_reset_pin (self -> miso -> pin );
225
+
229
226
self -> clock = NULL ;
230
227
self -> mosi = NULL ;
231
228
self -> miso = NULL ;
Original file line number Diff line number Diff line change @@ -295,12 +295,10 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
295
295
LPUART_Deinit (self -> uart );
296
296
gc_free (self -> ringbuf );
297
297
298
- if (self -> rx ) {
299
- common_hal_reset_pin (self -> rx -> pin );
300
- }
301
- if (self -> tx ) {
302
- common_hal_reset_pin (self -> tx -> pin );
303
- }
298
+
299
+ common_hal_reset_pin (self -> rx -> pin );
300
+ common_hal_reset_pin (self -> tx -> pin );
301
+
304
302
305
303
self -> rx = NULL ;
306
304
self -> tx = NULL ;
Original file line number Diff line number Diff line change @@ -67,6 +67,9 @@ void reset_all_pins(void) {
67
67
// Since i.MX pins need extra register and reset information to reset properly,
68
68
// resetting pins by number alone has been removed.
69
69
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
70
+ if (pin == NULL ) {
71
+ return ;
72
+ }
70
73
never_reset_pins [pin -> mux_idx ] = false;
71
74
claimed_pins [pin -> mux_idx ] = false;
72
75
* (uint32_t * )pin -> mux_reg = pin -> mux_reset ;
Original file line number Diff line number Diff line change @@ -134,6 +134,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
134
134
}
135
135
136
136
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
137
+ if (pin == NULL ) {
138
+ return ;
139
+ }
137
140
reset_pin_number (pin -> number );
138
141
}
139
142
Original file line number Diff line number Diff line change @@ -125,6 +125,9 @@ void common_hal_never_reset_pin(const mcu_pin_obj_t* pin) {
125
125
}
126
126
127
127
void common_hal_reset_pin (const mcu_pin_obj_t * pin ) {
128
+ if (pin == NULL ) {
129
+ return ;
130
+ }
128
131
reset_pin_number (pin -> port , pin -> number );
129
132
}
130
133
Original file line number Diff line number Diff line change @@ -76,9 +76,7 @@ void common_hal_displayio_fourwire_deinit(displayio_fourwire_obj_t* self) {
76
76
77
77
common_hal_reset_pin (self -> command .pin );
78
78
common_hal_reset_pin (self -> chip_select .pin );
79
- if (self -> reset .pin ) {
80
- common_hal_reset_pin (self -> reset .pin );
81
- }
79
+ common_hal_reset_pin (self -> reset .pin );
82
80
}
83
81
84
82
bool common_hal_displayio_fourwire_reset (mp_obj_t obj ) {
You can’t perform that action at this time.
0 commit comments