Merge branch 'bugfix/fix_rmt_err_interrupt_crash_bug' into 'master'

Bugfix(rmt):  Fix the rmt err interrupt crash bug

See merge request espressif/esp-idf!7282
This commit is contained in:
Angus Gratton 2020-01-14 08:27:53 +08:00
commit e40c9684dc
2 changed files with 19 additions and 1 deletions

View file

@ -387,7 +387,6 @@ esp_err_t rmt_set_tx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_th
RMT_CHECK(evt_thresh <= 256, "RMT EVT THRESH ERR", ESP_ERR_INVALID_ARG);
RMT_ENTER_CRITICAL();
rmt_ll_set_tx_limit(p_rmt_obj[channel]->hal.regs, channel, evt_thresh);
rmt_ll_enable_tx_pingpong(p_rmt_obj[channel]->hal.regs, true);
rmt_ll_enable_tx_thres_interrupt(p_rmt_obj[channel]->hal.regs, channel, true);
RMT_EXIT_CRITICAL();
} else {
@ -454,6 +453,7 @@ static esp_err_t rmt_internal_config(rmt_dev_t *dev, const rmt_config_t *rmt_par
RMT_ENTER_CRITICAL();
rmt_ll_enable_tx_cyclic(dev, channel, rmt_param->tx_config.loop_en);
rmt_ll_enable_tx_pingpong(dev, true);
/*Set idle level */
rmt_ll_enable_tx_idle(dev, channel, rmt_param->tx_config.idle_output_en);
rmt_ll_set_tx_idle_level(dev, channel, idle_level);
@ -675,6 +675,9 @@ static void IRAM_ATTR rmt_driver_isr_default(void *arg)
status &= ~(1 << channel);
rmt_obj_t *p_rmt = p_rmt_obj[channel];
if (p_rmt) {
// Reset the receiver/transmitter's write/read addresses to prevent endless err interrupts.
rmt_ll_reset_tx_pointer(p_rmt_obj[channel]->hal.regs, channel);
rmt_ll_reset_rx_pointer(p_rmt_obj[channel]->hal.regs, channel);
ESP_EARLY_LOGD(RMT_TAG, "RMT[%d] ERR", channel);
ESP_EARLY_LOGD(RMT_TAG, "status: 0x%08x", rmt_ll_get_channel_status(p_rmt_obj[channel]->hal.regs, channel));
}

View file

@ -311,6 +311,21 @@ static void rx_init(void)
rmt_driver_install(rmt_rx.channel, (sizeof(rmt_item32_t) * DATA_ITEM_NUM * (RMT_TX_DATA_NUM + 6)), 0);
}
//A sample case to test if sending 63 data will cause crash in error interrupt.
TEST_CASE("RMT tx test", "[rmt][test_env=UT_T1_RMT]")
{
tx_init();
rmt_item32_t *items = (rmt_item32_t*)malloc(sizeof(rmt_item32_t) * 63);
for(int i = 0; i < 63; i++) {
items[i] = (rmt_item32_t){{{200, 1, 200, 0}}};
}
TEST_ESP_OK(rmt_write_items(RMT_TX_CHANNEL, items,
63, /* Number of items */
1 /* wait till done */));
TEST_ESP_OK(rmt_driver_uninstall(RMT_TX_CHANNEL));
free(items);
}
TEST_CASE("RMT init config", "[rmt][test_env=UT_T1_RMT]")
{
// tx settings