mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
fix(rmt): alloc channel memory from internal
This commit is contained in:
@@ -207,8 +207,8 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_
|
|||||||
ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep");
|
ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep");
|
||||||
#endif // SOC_RMT_SUPPORT_SLEEP_RETENTION
|
#endif // SOC_RMT_SUPPORT_SLEEP_RETENTION
|
||||||
|
|
||||||
// malloc channel memory
|
// allocate channel memory from internal memory because it contains atomic variable
|
||||||
uint32_t mem_caps = RMT_MEM_ALLOC_CAPS;
|
uint32_t mem_caps = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT;
|
||||||
rx_channel = heap_caps_calloc(1, sizeof(rmt_rx_channel_t), mem_caps);
|
rx_channel = heap_caps_calloc(1, sizeof(rmt_rx_channel_t), mem_caps);
|
||||||
ESP_GOTO_ON_FALSE(rx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for rx channel");
|
ESP_GOTO_ON_FALSE(rx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for rx channel");
|
||||||
// gpio is not configured yet
|
// gpio is not configured yet
|
||||||
@@ -219,7 +219,7 @@ esp_err_t rmt_new_rx_channel(const rmt_rx_channel_config_t *config, rmt_channel_
|
|||||||
size_t num_dma_nodes = 0;
|
size_t num_dma_nodes = 0;
|
||||||
if (config->flags.with_dma) {
|
if (config->flags.with_dma) {
|
||||||
// DMA descriptors must be placed in internal SRAM
|
// DMA descriptors must be placed in internal SRAM
|
||||||
mem_caps |= MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA;
|
mem_caps |= MALLOC_CAP_DMA;
|
||||||
num_dma_nodes = config->mem_block_symbols * sizeof(rmt_symbol_word_t) / DMA_DESCRIPTOR_BUFFER_MAX_SIZE + 1;
|
num_dma_nodes = config->mem_block_symbols * sizeof(rmt_symbol_word_t) / DMA_DESCRIPTOR_BUFFER_MAX_SIZE + 1;
|
||||||
num_dma_nodes = MAX(2, num_dma_nodes); // at least 2 DMA nodes for ping-pong
|
num_dma_nodes = MAX(2, num_dma_nodes); // at least 2 DMA nodes for ping-pong
|
||||||
rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, num_dma_nodes, sizeof(rmt_dma_descriptor_t), mem_caps);
|
rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, num_dma_nodes, sizeof(rmt_dma_descriptor_t), mem_caps);
|
||||||
|
|||||||
@@ -272,8 +272,8 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_
|
|||||||
ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep");
|
ESP_RETURN_ON_FALSE(config->flags.allow_pd == 0, ESP_ERR_NOT_SUPPORTED, TAG, "not able to power down in light sleep");
|
||||||
#endif // SOC_RMT_SUPPORT_SLEEP_RETENTION
|
#endif // SOC_RMT_SUPPORT_SLEEP_RETENTION
|
||||||
|
|
||||||
// malloc channel memory
|
// allocate channel memory from internal memory because it contains atomic variable
|
||||||
uint32_t mem_caps = RMT_MEM_ALLOC_CAPS;
|
uint32_t mem_caps = MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT;
|
||||||
tx_channel = heap_caps_calloc(1, sizeof(rmt_tx_channel_t) + sizeof(rmt_tx_trans_desc_t) * config->trans_queue_depth, mem_caps);
|
tx_channel = heap_caps_calloc(1, sizeof(rmt_tx_channel_t) + sizeof(rmt_tx_trans_desc_t) * config->trans_queue_depth, mem_caps);
|
||||||
ESP_GOTO_ON_FALSE(tx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for tx channel");
|
ESP_GOTO_ON_FALSE(tx_channel, ESP_ERR_NO_MEM, err, TAG, "no mem for tx channel");
|
||||||
// GPIO configuration is not done yet
|
// GPIO configuration is not done yet
|
||||||
@@ -281,7 +281,7 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_
|
|||||||
// create DMA descriptors
|
// create DMA descriptors
|
||||||
if (config->flags.with_dma) {
|
if (config->flags.with_dma) {
|
||||||
// DMA descriptors must be placed in internal SRAM
|
// DMA descriptors must be placed in internal SRAM
|
||||||
mem_caps |= MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA;
|
mem_caps |= MALLOC_CAP_DMA;
|
||||||
rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, RMT_DMA_NODES_PING_PONG, sizeof(rmt_dma_descriptor_t), mem_caps);
|
rmt_dma_descriptor_t *dma_nodes = heap_caps_aligned_calloc(RMT_DMA_DESC_ALIGN, RMT_DMA_NODES_PING_PONG, sizeof(rmt_dma_descriptor_t), mem_caps);
|
||||||
ESP_GOTO_ON_FALSE(dma_nodes, ESP_ERR_NO_MEM, err, TAG, "no mem for tx DMA nodes");
|
ESP_GOTO_ON_FALSE(dma_nodes, ESP_ERR_NO_MEM, err, TAG, "no mem for tx DMA nodes");
|
||||||
tx_channel->dma_nodes = dma_nodes;
|
tx_channel->dma_nodes = dma_nodes;
|
||||||
|
|||||||
Reference in New Issue
Block a user