rmt: fix rmt buffer allocation issue

This commit is contained in:
morris
2023-02-14 13:40:39 +08:00
parent e0c98da169
commit 0a25c48d89
2 changed files with 5 additions and 4 deletions

View File

@@ -1184,12 +1184,12 @@ esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn)
const uint32_t block_size = mem_blocks * RMT_MEM_ITEM_NUM * sizeof(rmt_item32_t);
if (p_rmt_obj[channel]->tx_buf == NULL) {
#if !CONFIG_SPIRAM_USE_MALLOC
p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)malloc(block_size);
p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)calloc(1, block_size);
#else
if (p_rmt_obj[channel]->intr_alloc_flags & ESP_INTR_FLAG_IRAM) {
p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)malloc(block_size);
} else {
p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)heap_caps_calloc(1, block_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
} else {
p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)calloc(1, block_size);
}
#endif
if (p_rmt_obj[channel]->tx_buf == NULL) {