diff --git a/cores/esp32/esp32-hal-rmt.c b/cores/esp32/esp32-hal-rmt.c index 309cd13b327..0c711946ddc 100644 --- a/cores/esp32/esp32-hal-rmt.c +++ b/cores/esp32/esp32-hal-rmt.c @@ -325,22 +325,23 @@ bool rmtDeinit(rmt_obj_t *rmt) return false; } - RMT_MUTEX_LOCK(rmt->channel); + int channel = rmt->channel; + RMT_MUTEX_LOCK(channel); // force stopping rmt processing if (rmt->tx_not_rx) { - rmt_tx_stop(rmt->channel); + rmt_tx_stop(channel); } else { - rmt_rx_stop(rmt->channel); + rmt_rx_stop(channel); if(rmt->rxTaskHandle){ vTaskDelete(rmt->rxTaskHandle); rmt->rxTaskHandle = NULL; } } - rmt_driver_uninstall(rmt->channel); + rmt_driver_uninstall(channel); - size_t from = rmt->channel; - size_t to = rmt->buffers + rmt->channel; + size_t from = channel; + size_t to = rmt->buffers + channel; size_t i; for (i = from; i < to; i++) { @@ -349,7 +350,7 @@ bool rmtDeinit(rmt_obj_t *rmt) g_rmt_objects[from].channel = 0; g_rmt_objects[from].buffers = 0; - RMT_MUTEX_UNLOCK(rmt->channel); + RMT_MUTEX_UNLOCK(channel); #if !CONFIG_DISABLE_HAL_LOCKS if(g_rmt_objlocks[from] != NULL) {