mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
feat(dma): advanced dma malloc helper
This commit is contained in:
@@ -277,7 +277,11 @@ esp_err_t sdmmc_io_rw_extended(sdmmc_card_t* card, int func,
|
||||
.blklen = SDMMC_IO_BLOCK_SIZE /* TODO: read max block size from CIS */
|
||||
};
|
||||
|
||||
if (unlikely(datalen > 0 && !esp_dma_is_buffer_aligned(datap, buflen, ESP_DMA_BUF_LOCATION_AUTO))) {
|
||||
esp_dma_mem_info_t dma_mem_info = {
|
||||
.heap_caps = MALLOC_CAP_DMA,
|
||||
.custom_alignment = 4,
|
||||
};
|
||||
if (unlikely(datalen > 0 && !esp_dma_is_buffer_alignment_satisfied(datap, buflen, &dma_mem_info))) {
|
||||
if (datalen > SDMMC_IO_BLOCK_SIZE || card->host.dma_aligned_buffer == NULL) {
|
||||
// User gives unaligned buffer while `SDMMC_HOST_FLAG_ALLOC_ALIGNED_BUF` not set.
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@@ -386,7 +390,11 @@ esp_err_t sdmmc_io_write_bytes(sdmmc_card_t* card, uint32_t function,
|
||||
esp_err_t sdmmc_io_read_blocks(sdmmc_card_t* card, uint32_t function,
|
||||
uint32_t addr, void* dst, size_t size)
|
||||
{
|
||||
if (unlikely(!esp_dma_is_buffer_aligned(dst, size, ESP_DMA_BUF_LOCATION_INTERNAL))) {
|
||||
esp_dma_mem_info_t dma_mem_info = {
|
||||
.heap_caps = MALLOC_CAP_DMA,
|
||||
.custom_alignment = 4,
|
||||
};
|
||||
if (unlikely(!esp_dma_is_buffer_alignment_satisfied(dst, size, &dma_mem_info))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return sdmmc_io_rw_extended(card, function, addr,
|
||||
@@ -397,7 +405,11 @@ esp_err_t sdmmc_io_read_blocks(sdmmc_card_t* card, uint32_t function,
|
||||
esp_err_t sdmmc_io_write_blocks(sdmmc_card_t* card, uint32_t function,
|
||||
uint32_t addr, const void* src, size_t size)
|
||||
{
|
||||
if (unlikely(!esp_dma_is_buffer_aligned(src, size, ESP_DMA_BUF_LOCATION_INTERNAL))) {
|
||||
esp_dma_mem_info_t dma_mem_info = {
|
||||
.heap_caps = MALLOC_CAP_DMA,
|
||||
.custom_alignment = 4,
|
||||
};
|
||||
if (unlikely(!esp_dma_is_buffer_alignment_satisfied(src, size, &dma_mem_info))) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
return sdmmc_io_rw_extended(card, function, addr,
|
||||
|
Reference in New Issue
Block a user