Skip to content

Commit 3d2eb3b

Browse files
garywilldpgeorge
authored andcommitted
ports: Guard calls to machine_*_deinit_all() with #if where appropriate.
To allow these features to be properly disabled.
1 parent 4e79698 commit 3d2eb3b

3 files changed

Lines changed: 14 additions & 0 deletions

File tree

ports/esp32/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ void mp_task(void *pvParameter) {
187187

188188
// Deinit uart before timers, as esp32 uart
189189
// depends on a timer instance
190+
#if MICROPY_PY_MACHINE_UART
190191
machine_uart_deinit_all();
192+
#endif
191193
machine_timer_deinit_all();
192194

193195
#if MICROPY_PY_ESP32_PCNT
@@ -210,7 +212,9 @@ void mp_task(void *pvParameter) {
210212
mp_hal_stdout_tx_str("MPY: soft reboot\r\n");
211213

212214
// deinitialise peripherals
215+
#if MICROPY_PY_MACHINE_PWM
213216
machine_pwm_deinit_all();
217+
#endif
214218
// TODO: machine_rmt_deinit_all();
215219
machine_pins_deinit();
216220
#if MICROPY_PY_MACHINE_I2C_TARGET

ports/mimxrt/main.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ int main(void) {
170170
#if MICROPY_PY_NETWORK
171171
mod_network_deinit();
172172
#endif
173+
#if MICROPY_PY_MACHINE_UART
173174
machine_uart_deinit_all();
175+
#endif
176+
#if MICROPY_PY_MACHINE_PWM
174177
machine_pwm_deinit_all();
178+
#endif
175179
soft_timer_deinit();
176180
gc_sweep_all();
177181
mp_deinit();

ports/rp2/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,15 +249,21 @@ int main(int argc, char **argv) {
249249
#if MICROPY_PY_NETWORK
250250
mod_network_deinit();
251251
#endif
252+
#if MICROPY_PY_MACHINE_I2S
252253
machine_i2s_deinit_all();
254+
#endif
253255
rp2_dma_deinit();
254256
rp2_pio_deinit();
255257
#if MICROPY_PY_BLUETOOTH
256258
mp_bluetooth_deinit();
257259
#endif
260+
#if MICROPY_PY_MACHINE_PWM
258261
machine_pwm_deinit_all();
262+
#endif
259263
machine_pin_deinit();
264+
#if MICROPY_PY_MACHINE_UART
260265
machine_uart_deinit_all();
266+
#endif
261267
#if MICROPY_PY_MACHINE_I2C_TARGET
262268
mp_machine_i2c_target_deinit_all();
263269
#endif

0 commit comments

Comments
 (0)