refactor(sd): replace esp_dma_ with heap_caps_

This commit is contained in:
Armando
2025-01-15 16:16:10 +08:00
parent d8166220fd
commit e8ad9b05aa
16 changed files with 186 additions and 103 deletions

View File

@@ -395,20 +395,30 @@ esp_err_t sdmmc_allocate_aligned_buf(sdmmc_card_t* card)
{
if (card->host.flags & SDMMC_HOST_FLAG_ALLOC_ALIGNED_BUF) {
void* buf = NULL;
size_t actual_size = 0;
esp_dma_mem_info_t dma_mem_info;
card->host.get_dma_info(card->host.slot, &dma_mem_info);
esp_err_t ret = esp_dma_capable_malloc(SDMMC_IO_BLOCK_SIZE, &dma_mem_info, &buf, &actual_size);
if (ret != ESP_OK) {
return ret;
size_t actual_size = 0;
buf = heap_caps_malloc(SDMMC_IO_BLOCK_SIZE, MALLOC_CAP_DMA);
if (!buf) {
ESP_LOGE(TAG, "%s: not enough mem, err=0x%x", __func__, ESP_ERR_NO_MEM);
return ESP_ERR_NO_MEM;
}
actual_size = heap_caps_get_allocated_size(buf);
assert(actual_size == SDMMC_IO_BLOCK_SIZE);
card->host.dma_aligned_buffer = buf;
}
return ESP_OK;
}
esp_err_t sdmmc_check_host_function_ptr_integrity(sdmmc_card_t *card)
{
if (!card->host.check_buffer_alignment) {
ESP_LOGE(TAG, "%s: host drv check_buffer_alignment not initialised, err=0x%x", __func__, ESP_ERR_INVALID_ARG);
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
uint32_t sdmmc_get_erase_timeout_ms(const sdmmc_card_t* card, int arg, size_t erase_size_kb)
{
if (card->is_mmc) {