Skip to content

Commit

Permalink
Fix RMT mutex unlock using incorrect channel number in rmtDeinit (#10034
Browse files Browse the repository at this point in the history
)
  • Loading branch information
paccerdk committed Jul 16, 2024
1 parent 6bd3274 commit 54c4b0c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions cores/esp32/esp32-hal-rmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -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) {
Expand Down

0 comments on commit 54c4b0c

Please sign in to comment.