drivers: dma: stm32u5: set data length in bytes

The block data length field should be in bytes. Setting this to a value
that is not a multiple of the data size results in a user setting error.

Running the ADC DMA test prior to this commit:

west build -p -b nucleo_u575zi_q zephyr/tests/drivers/adc/adc_dma

E: Transfer Error.
I: tc: 0, ht: 0, dte: 0, ule: 0, use: 1
E: DMA sampling complete, but DMA reported error -5

Existing tests using DMA on the nucleo_u575zi_q were not effected
because they only use a data size of one and continue to function
as expected:

west build -p -b nucleo_u575zi_q zephyr/tests/drivers/spi/spi_loopback \
	-DOVERLAY_CONFIG="overlay-stm32-spi-dma.conf"

SUITE PASS - 100.00% [spi_loopback]: pass = 1, fail = 0, ...

west build -p -b nucleo_u575zi_q zephyr/tests/drivers/dma/loop_transfer

SUITE PASS - 100.00% [dma_m2m_loop]: pass = 3, fail = 0, ...

Signed-off-by: Brett Witherspoon <brett@witherspoon.engineering>
This commit is contained in:
Brett Witherspoon 2023-06-26 22:20:19 -04:00 committed by Carles Cufí
parent 3bb5062fae
commit 33cb179b4f

View file

@ -494,13 +494,7 @@ static int dma_stm32_configure(const struct device *dev,
index = find_lsb_set(config->dest_data_size) - 1;
DMA_InitStruct.DestDataWidth = table_dst_size[index];
if (stream->source_periph) {
DMA_InitStruct.BlkDataLength = config->head_block->block_size /
config->source_data_size;
} else {
DMA_InitStruct.BlkDataLength = config->head_block->block_size /
config->dest_data_size;
}
DMA_InitStruct.BlkDataLength = config->head_block->block_size;
/* The request ID is stored in the dma_slot */
DMA_InitStruct.Request = config->dma_slot;