summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgarywill <garywill@disroot.org>2025-11-15 11:40:39 +0800
committerDamien George <damien@micropython.org>2025-11-19 16:56:03 +1100
commit3d2eb3b8e907ee74350a69ff92af7a14d7c2f7c7 (patch)
tree294e750ffd4d84d4eeae81d6ba7e421e02484121
parent4e79698a997465b1043fa8cbc4a72cdac889341f (diff)
ports: Guard calls to machine_*_deinit_all() with #if where appropriate.
To allow these features to be properly disabled.
-rw-r--r--ports/esp32/main.c4
-rw-r--r--ports/mimxrt/main.c4
-rw-r--r--ports/rp2/main.c6
3 files changed, 14 insertions, 0 deletions
diff --git a/ports/esp32/main.c b/ports/esp32/main.c
index 74e31647d..41eea29b0 100644
--- a/ports/esp32/main.c
+++ b/ports/esp32/main.c
@@ -187,7 +187,9 @@ soft_reset_exit:
// Deinit uart before timers, as esp32 uart
// depends on a timer instance
+ #if MICROPY_PY_MACHINE_UART
machine_uart_deinit_all();
+ #endif
machine_timer_deinit_all();
#if MICROPY_PY_ESP32_PCNT
@@ -210,7 +212,9 @@ soft_reset_exit:
mp_hal_stdout_tx_str("MPY: soft reboot\r\n");
// deinitialise peripherals
+ #if MICROPY_PY_MACHINE_PWM
machine_pwm_deinit_all();
+ #endif
// TODO: machine_rmt_deinit_all();
machine_pins_deinit();
#if MICROPY_PY_MACHINE_I2C_TARGET
diff --git a/ports/mimxrt/main.c b/ports/mimxrt/main.c
index 22809916e..dcb1ede16 100644
--- a/ports/mimxrt/main.c
+++ b/ports/mimxrt/main.c
@@ -170,8 +170,12 @@ int main(void) {
#if MICROPY_PY_NETWORK
mod_network_deinit();
#endif
+ #if MICROPY_PY_MACHINE_UART
machine_uart_deinit_all();
+ #endif
+ #if MICROPY_PY_MACHINE_PWM
machine_pwm_deinit_all();
+ #endif
soft_timer_deinit();
gc_sweep_all();
mp_deinit();
diff --git a/ports/rp2/main.c b/ports/rp2/main.c
index 1ffcabdfa..f01522f24 100644
--- a/ports/rp2/main.c
+++ b/ports/rp2/main.c
@@ -249,15 +249,21 @@ int main(int argc, char **argv) {
#if MICROPY_PY_NETWORK
mod_network_deinit();
#endif
+ #if MICROPY_PY_MACHINE_I2S
machine_i2s_deinit_all();
+ #endif
rp2_dma_deinit();
rp2_pio_deinit();
#if MICROPY_PY_BLUETOOTH
mp_bluetooth_deinit();
#endif
+ #if MICROPY_PY_MACHINE_PWM
machine_pwm_deinit_all();
+ #endif
machine_pin_deinit();
+ #if MICROPY_PY_MACHINE_UART
machine_uart_deinit_all();
+ #endif
#if MICROPY_PY_MACHINE_I2C_TARGET
mp_machine_i2c_target_deinit_all();
#endif