Skip to content

Commit

Permalink
esp32/machine_i2s: Add I2S finaliser which calls deinit().
Browse files Browse the repository at this point in the history
So that the FreeRTOS resources can be freed, eg on soft reset.

Fixes issue #9366.

Signed-off-by: Damien George <damien@micropython.org>
  • Loading branch information
dpgeorge committed Oct 4, 2022
1 parent 7705b9b commit 0ee877a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ports/esp32/machine_i2s.c
Expand Up @@ -533,7 +533,8 @@ STATIC mp_obj_t machine_i2s_make_new(const mp_obj_type_t *type, size_t n_pos_arg

machine_i2s_obj_t *self;
if (MP_STATE_PORT(machine_i2s_obj)[port] == NULL) {
self = mp_obj_malloc(machine_i2s_obj_t, &machine_i2s_type);
self = m_new_obj_with_finaliser(machine_i2s_obj_t);
self->base.type = &machine_i2s_type;
MP_STATE_PORT(machine_i2s_obj)[port] = self;
self->port = port;
} else {
Expand Down Expand Up @@ -688,6 +689,7 @@ STATIC const mp_rom_map_elem_t machine_i2s_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&machine_i2s_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR_irq), MP_ROM_PTR(&machine_i2s_irq_obj) },
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&machine_i2s_deinit_obj) },

// Static method
{ MP_ROM_QSTR(MP_QSTR_shift), MP_ROM_PTR(&machine_i2s_shift_obj) },
Expand Down

0 comments on commit 0ee877a

Please sign in to comment.