From 007c84b84050b3d31a563294fbb1b504425dff41 Mon Sep 17 00:00:00 2001 From: Marek Ledworowski Date: Sun, 21 Apr 2024 19:26:51 +0200 Subject: [PATCH] ports/rp2/machine_i2s.c: Detect and deinitialize I2S instances on boot. During early init some I2S instances may still be present in buffer. This issue would cause system to hang when using soft_reset without deinitializing I2S instance first. --- ports/rp2/machine_i2s.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ports/rp2/machine_i2s.c b/ports/rp2/machine_i2s.c index 47eb5350a6..a9214f2b05 100644 --- a/ports/rp2/machine_i2s.c +++ b/ports/rp2/machine_i2s.c @@ -167,6 +167,9 @@ static mp_obj_t machine_i2s_deinit(mp_obj_t self_in); void machine_i2s_init0(void) { for (uint8_t i = 0; i < MAX_I2S_RP2; i++) { + if (MP_STATE_PORT(machine_i2s_obj[i]) != NULL) { + mp_machine_i2s_deinit(MP_STATE_PORT(machine_i2s_obj[i])); + } MP_STATE_PORT(machine_i2s_obj[i]) = NULL; } }