mirror of
https://github.com/micropython/micropython.git
synced 2026-01-04 11:10:14 +01:00
stm32,esp32: In machine_i2s, make object reference arrays root pointers.
This change eliminates the risk of the IRQ callback accessing invalid data. Discussed here: https://github.com/micropython/micropython/pull/7183#discussion_r660209875 Signed-off-by: Mike Teachman <mike.teachman@gmail.com>
This commit is contained in:
committed by
Damien George
parent
0be3b91f11
commit
6d5296e65e
@@ -147,11 +147,9 @@ STATIC const int8_t i2s_frame_map[NUM_I2S_USER_FORMATS][I2S_RX_FRAME_SIZE_IN_BYT
|
||||
{ 4, 5, 6, 7, 0, 1, 2, 3 }, // Stereo, 32-bits
|
||||
};
|
||||
|
||||
STATIC machine_i2s_obj_t *machine_i2s_obj[I2S_NUM_MAX];
|
||||
|
||||
void machine_i2s_init0() {
|
||||
for (i2s_port_t p = 0; p < I2S_NUM_MAX; p++) {
|
||||
machine_i2s_obj[p] = NULL;
|
||||
MP_STATE_PORT(machine_i2s_obj)[p] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -507,13 +505,13 @@ 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 (machine_i2s_obj[port] == NULL) {
|
||||
if (MP_STATE_PORT(machine_i2s_obj)[port] == NULL) {
|
||||
self = m_new_obj(machine_i2s_obj_t);
|
||||
machine_i2s_obj[port] = self;
|
||||
MP_STATE_PORT(machine_i2s_obj)[port] = self;
|
||||
self->base.type = &machine_i2s_type;
|
||||
self->port = port;
|
||||
} else {
|
||||
self = machine_i2s_obj[port];
|
||||
self = MP_STATE_PORT(machine_i2s_obj)[port];
|
||||
machine_i2s_deinit(self);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user