Skip to content

Commit 0167e6f

Browse files
muhaidongTingCheng1008
authored andcommitted
changes: change esp_dma_calloc to esp_dma_capable_calloc to fix build warrning
1 parent a75eae4 commit 0167e6f

File tree

5 files changed

+36
-8
lines changed

5 files changed

+36
-8
lines changed

src/esp_sip.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,11 @@ esp_err_t esp_sip_write_mem(uint32_t addr, const uint8_t *buf, uint32_t len)
7777

7878
if (sip->rawbuf == NULL) {
7979
size_t actual_size = 0;
80-
err = esp_dma_calloc(1, SIP_BOOT_BUF_SIZE, 0, (void*)&sip->rawbuf, &actual_size);
80+
esp_dma_mem_info_t dma_mem_info = {
81+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
82+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
83+
};
84+
err = esp_dma_capable_malloc(SIP_BOOT_BUF_SIZE, &dma_mem_info, (void*)&sip->rawbuf, &actual_size);
8185
}
8286

8387
chdr = (struct sip_hdr *)sip->rawbuf;

src/ext_sdio_adapter.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ esp_err_t esp_extconn_sdio_read_reg_window(unsigned int reg_addr, uint8_t *value
222222
ESP_RETURN_ON_FALSE(reg_addr <= 0x7f, ESP_ERR_INVALID_ARG, TAG, "Invalid parameters");
223223

224224
size_t actual_size = 0;
225-
esp_dma_calloc(1, sizeof(uint32_t), 0, (void*)&p_tbuf, &actual_size);
225+
esp_dma_mem_info_t dma_mem_info = {
226+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
227+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
228+
};
229+
esp_dma_capable_malloc(sizeof(uint32_t), &dma_mem_info, (void*)&p_tbuf, &actual_size);
226230
ESP_RETURN_ON_FALSE(p_tbuf != NULL, ESP_ERR_NO_MEM, TAG, "Fatal: Sufficient memory");
227231

228232
p_tbuf[0] = (reg_addr & 0x7f);
@@ -255,7 +259,11 @@ static int esp_extconn_sdio_write_reg_window(unsigned int reg_addr, uint8_t *val
255259
ESP_RETURN_ON_FALSE(reg_addr <= 0x7f, ESP_ERR_INVALID_ARG, TAG, "Invalid parameters");
256260

257261
size_t actual_size = 0;
258-
esp_dma_calloc(1, sizeof(uint32_t), 0, (void*)&p_tbuf, &actual_size);
262+
esp_dma_mem_info_t dma_mem_info = {
263+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
264+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
265+
};
266+
esp_dma_capable_malloc(sizeof(uint32_t), &dma_mem_info, (void*)&p_tbuf, &actual_size);
259267
ESP_RETURN_ON_FALSE(p_tbuf != NULL, ESP_ERR_NO_MEM, TAG, "Fatal: Sufficient memory");
260268

261269
memcpy(p_tbuf, value, 4);
@@ -272,7 +280,11 @@ static esp_err_t esp_extconn_sdio_init_slave_link(void)
272280
{
273281
uint32_t *t_buf = NULL;
274282
size_t actual_size = 0;
275-
esp_dma_calloc(1, sizeof(uint32_t), 0, (void*)&t_buf, &actual_size);
283+
esp_dma_mem_info_t dma_mem_info = {
284+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
285+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
286+
};
287+
esp_dma_capable_malloc(sizeof(uint32_t), &dma_mem_info, (void*)&t_buf, &actual_size);
276288
ESP_RETURN_ON_FALSE(t_buf != NULL, ESP_ERR_NO_MEM, TAG, "Fatal: Sufficient memory");
277289

278290
// set stitch en
@@ -303,7 +315,7 @@ static esp_err_t esp_extconn_sdio_init_slave_link(void)
303315

304316
// Enable target interrupt
305317
uint32_t *val = 0;
306-
esp_dma_calloc(1, sizeof(uint32_t), 0, (void*)&val, &actual_size);
318+
esp_dma_capable_malloc(sizeof(uint32_t), &dma_mem_info, (void*)&val, &actual_size);
307319
ESP_RETURN_ON_FALSE(val != NULL, ESP_ERR_NO_MEM, TAG, "Fatal: Sufficient memory");
308320

309321
extconn_sdio_read_bytes(host->card, 1, ESP_SDIO_FUNC1_INT_ENA, (uint8_t *)val, sizeof(uint32_t));

src/trans_bt.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ static void bt_tx_task(void *arg)
6868

6969
if (buf.data && buf.len) {
7070
size_t actual_size = 0;
71-
ESP_ERROR_CHECK(esp_dma_calloc(1, sizeof(sbp_hdr_t) + buf.len, 0, (void*)&hdr, &actual_size));
71+
esp_dma_mem_info_t dma_mem_info = {
72+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
73+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
74+
};
75+
ESP_ERROR_CHECK(esp_dma_capable_malloc(sizeof(sbp_hdr_t) + buf.len, &dma_mem_info, (void*)&hdr, &actual_size));
7276

7377
hdr->len = sizeof(sbp_hdr_t) + buf.len;
7478
hdr->type = 0;

src/trans_recv.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,11 @@ esp_err_t esp_extconn_trans_recv_init(esp_extconn_config_t *config)
174174
{
175175
sdio_mutex = xSemaphoreCreateMutex();
176176
size_t actual_size = 0;
177-
ESP_ERROR_CHECK(esp_dma_calloc(1, RECV_BUF_LEN, 0, (void*)&recv_buf, &actual_size));
177+
esp_dma_mem_info_t dma_mem_info = {
178+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
179+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
180+
};
181+
ESP_ERROR_CHECK(esp_dma_capable_malloc(RECV_BUF_LEN, &dma_mem_info, (void*)&recv_buf, &actual_size));
178182

179183
ESP_RETURN_ON_FALSE(recv_buf, ESP_ERR_NO_MEM, TAG, "buffer malloc failed");
180184

src/trans_wifi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,11 @@ static void wifi_send_task(void *args)
143143
uint8_t *send_buf = NULL; //calloc(1, WIFI_SEND_BUFFER_LEN);
144144

145145
size_t actual_size = 0;
146-
ESP_ERROR_CHECK(esp_dma_calloc(1, WIFI_SEND_BUFFER_LEN, 0, (void*)&send_buf, &actual_size));
146+
esp_dma_mem_info_t dma_mem_info = {
147+
.extra_heap_caps = MALLOC_CAP_DMA | MALLOC_CAP_INTERNAL,
148+
.dma_alignment_bytes = 4, //legacy API behaviour is only check max dma buffer alignment
149+
};
150+
ESP_ERROR_CHECK(esp_dma_capable_malloc(WIFI_SEND_BUFFER_LEN, &dma_mem_info, (void*)&send_buf, &actual_size));
147151

148152
ESP_LOGI(TAG, "WiFi Send START");
149153

0 commit comments

Comments
 (0)