mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
fix(rmt): deal with spurious RX done interrupts on ESP32
Closes https://github.com/espressif/esp-idf/issues/15948
This commit is contained in:
@@ -571,6 +571,16 @@ static bool IRAM_ATTR rmt_isr_handle_rx_done(rmt_rx_channel_t *rx_chan)
|
||||
rmt_ll_rx_enable(hal->regs, channel_id, false);
|
||||
portEXIT_CRITICAL_ISR(&channel->spinlock);
|
||||
|
||||
#if !SOC_RMT_SUPPORT_ASYNC_STOP
|
||||
// This is a workaround for ESP32.
|
||||
// The RX engine can not be disabled once it is enabled in ESP32
|
||||
// If the state isn't RMT_FSM_RUN, it means the RX engine was disabled
|
||||
// and we shouldn't process the data.
|
||||
if (atomic_load(&channel->fsm) != RMT_FSM_RUN) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint32_t offset = rmt_ll_rx_get_memory_writer_offset(hal->regs, channel_id);
|
||||
|
||||
// Start from C6, the actual pulse count is the number of input pulses N - 1.
|
||||
|
||||
@@ -808,14 +808,14 @@ static esp_err_t rmt_tx_disable(rmt_channel_handle_t channel)
|
||||
// disable the hardware
|
||||
portENTER_CRITICAL(&channel->spinlock);
|
||||
rmt_ll_tx_enable_loop(hal->regs, channel->channel_id, false);
|
||||
#if SOC_RMT_SUPPORT_TX_ASYNC_STOP
|
||||
#if SOC_RMT_SUPPORT_ASYNC_STOP
|
||||
rmt_ll_tx_stop(hal->regs, channel->channel_id);
|
||||
#endif
|
||||
portEXIT_CRITICAL(&channel->spinlock);
|
||||
|
||||
portENTER_CRITICAL(&group->spinlock);
|
||||
rmt_ll_enable_interrupt(hal->regs, RMT_LL_EVENT_TX_MASK(channel_id), false);
|
||||
#if !SOC_RMT_SUPPORT_TX_ASYNC_STOP
|
||||
#if !SOC_RMT_SUPPORT_ASYNC_STOP
|
||||
// we do a trick to stop the undergoing transmission
|
||||
// stop interrupt, insert EOF marker to the RMT memory, polling the trans_done event
|
||||
channel->hw_mem_base[0].val = 0;
|
||||
|
||||
Reference in New Issue
Block a user