mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-31 19:24:33 +02:00
fix(rmt): fix race condition and add receive config error message
Closes https://github.com/espressif/esp-idf/issues/15842 Closes https://github.com/espressif/esp-idf/issues/15836
This commit is contained in:
@@ -374,8 +374,8 @@ esp_err_t rmt_receive(rmt_channel_handle_t channel, void *buffer, size_t buffer_
|
|||||||
|
|
||||||
uint32_t filter_reg_value = ((uint64_t)rx_chan->filter_clock_resolution_hz * config->signal_range_min_ns) / 1000000000UL;
|
uint32_t filter_reg_value = ((uint64_t)rx_chan->filter_clock_resolution_hz * config->signal_range_min_ns) / 1000000000UL;
|
||||||
uint32_t idle_reg_value = ((uint64_t)channel->resolution_hz * config->signal_range_max_ns) / 1000000000UL;
|
uint32_t idle_reg_value = ((uint64_t)channel->resolution_hz * config->signal_range_max_ns) / 1000000000UL;
|
||||||
ESP_RETURN_ON_FALSE_ISR(filter_reg_value <= RMT_LL_MAX_FILTER_VALUE, ESP_ERR_INVALID_ARG, TAG, "signal_range_min_ns too big");
|
ESP_RETURN_ON_FALSE_ISR(filter_reg_value <= RMT_LL_MAX_FILTER_VALUE, ESP_ERR_INVALID_ARG, TAG, "signal_range_min_ns too big, should be less than %"PRIu32" ns", (uint32_t)((uint64_t)RMT_LL_MAX_FILTER_VALUE * 1000000000UL / rx_chan->filter_clock_resolution_hz));
|
||||||
ESP_RETURN_ON_FALSE_ISR(idle_reg_value <= RMT_LL_MAX_IDLE_VALUE, ESP_ERR_INVALID_ARG, TAG, "signal_range_max_ns too big");
|
ESP_RETURN_ON_FALSE_ISR(idle_reg_value <= RMT_LL_MAX_IDLE_VALUE, ESP_ERR_INVALID_ARG, TAG, "signal_range_max_ns too big, should be less than %"PRIu32" ns", (uint32_t)((uint64_t)RMT_LL_MAX_IDLE_VALUE * 1000000000UL / channel->resolution_hz));
|
||||||
|
|
||||||
// check if we're in a proper state to start the receiver
|
// check if we're in a proper state to start the receiver
|
||||||
rmt_fsm_t expected_fsm = RMT_FSM_ENABLE;
|
rmt_fsm_t expected_fsm = RMT_FSM_ENABLE;
|
||||||
@@ -408,11 +408,11 @@ esp_err_t rmt_receive(rmt_channel_handle_t channel, void *buffer, size_t buffer_
|
|||||||
rmt_ll_rx_set_idle_thres(hal->regs, channel_id, idle_reg_value);
|
rmt_ll_rx_set_idle_thres(hal->regs, channel_id, idle_reg_value);
|
||||||
// turn on RMT RX machine
|
// turn on RMT RX machine
|
||||||
rmt_ll_rx_enable(hal->regs, channel_id, true);
|
rmt_ll_rx_enable(hal->regs, channel_id, true);
|
||||||
portEXIT_CRITICAL_SAFE(&channel->spinlock);
|
|
||||||
|
|
||||||
// saying we're in running state, this state will last until the receiving is done
|
// saying we're in running state, this state will last until the receiving is done
|
||||||
// i.e., we will switch back to the enable state in the receive done interrupt handler
|
// i.e., we will switch back to the enable state in the receive done interrupt handler
|
||||||
atomic_store(&channel->fsm, RMT_FSM_RUN);
|
atomic_store(&channel->fsm, RMT_FSM_RUN);
|
||||||
|
portEXIT_CRITICAL_SAFE(&channel->spinlock);
|
||||||
|
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user