rp2/machine_i2s: Deinit all active I2S instances on soft reset.
Add `machine_i2s_deinit_all` to teardown any active I2S instances on soft reset. Prior to this fix, code using I2S required a try/finally in order to avoid a hard fault on soft reset. Fixes issue #14339. Signed-off-by: Phil Howard <phil@gadgetoid.com>
This commit is contained in:
parent
ad3552ae2c
commit
d2e33fe309
@ -171,6 +171,15 @@ void machine_i2s_init0(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void machine_i2s_deinit_all(void) {
|
||||||
|
for (uint8_t i = 0; i < MAX_I2S_RP2; i++) {
|
||||||
|
machine_i2s_obj_t *i2s = MP_STATE_PORT(machine_i2s_obj[i]);
|
||||||
|
if (i2s) {
|
||||||
|
mp_machine_i2s_deinit(i2s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int8_t get_frame_mapping_index(int8_t bits, format_t format) {
|
static int8_t get_frame_mapping_index(int8_t bits, format_t format) {
|
||||||
if (format == MONO) {
|
if (format == MONO) {
|
||||||
if (bits == 16) {
|
if (bits == 16) {
|
||||||
|
|||||||
@ -214,6 +214,7 @@ int main(int argc, char **argv) {
|
|||||||
#if MICROPY_PY_NETWORK
|
#if MICROPY_PY_NETWORK
|
||||||
mod_network_deinit();
|
mod_network_deinit();
|
||||||
#endif
|
#endif
|
||||||
|
machine_i2s_deinit_all();
|
||||||
rp2_dma_deinit();
|
rp2_dma_deinit();
|
||||||
rp2_pio_deinit();
|
rp2_pio_deinit();
|
||||||
#if MICROPY_PY_BLUETOOTH
|
#if MICROPY_PY_BLUETOOTH
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
void machine_pin_init(void);
|
void machine_pin_init(void);
|
||||||
void machine_pin_deinit(void);
|
void machine_pin_deinit(void);
|
||||||
void machine_i2s_init0(void);
|
void machine_i2s_init0(void);
|
||||||
|
void machine_i2s_deinit_all(void);
|
||||||
void machine_pwm_deinit_all(void);
|
void machine_pwm_deinit_all(void);
|
||||||
|
|
||||||
struct _machine_spi_obj_t *spi_from_mp_obj(mp_obj_t o);
|
struct _machine_spi_obj_t *spi_from_mp_obj(mp_obj_t o);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user