stm32/machine_i2s: Allow I2S.deinit to be called multiple times.
In particular, it is called by the constructor if the instance already exists. So if the previous instance was deinit'd then it will be deinit'd a second time. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
c90dfba04c
commit
2a91c8a888
|
@ -887,9 +887,9 @@ STATIC mp_obj_t machine_i2s_init(size_t n_pos_args, const mp_obj_t *pos_args, mp
|
|||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2s_init_obj, 1, machine_i2s_init);
|
||||
|
||||
STATIC mp_obj_t machine_i2s_deinit(mp_obj_t self_in) {
|
||||
|
||||
machine_i2s_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
if (self->ring_buffer_storage != NULL) {
|
||||
dma_deinit(self->dma_descr_tx);
|
||||
dma_deinit(self->dma_descr_rx);
|
||||
HAL_I2S_DeInit(&self->hi2s);
|
||||
|
@ -905,6 +905,8 @@ STATIC mp_obj_t machine_i2s_deinit(mp_obj_t self_in) {
|
|||
}
|
||||
|
||||
m_free(self->ring_buffer_storage);
|
||||
self->ring_buffer_storage = NULL;
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue