Skip to content

Commit 3e3cc3e

Browse files
committed
drivers: dma: stm32: the source and destination sizes must only match in v1
Commit e7f222a fixed the bug where a data size mismatch produces unexpected behavior with the DMA on V1 devices. However, this limitation is only valid for the STM32 series with V1 DMA, V2 doesn't have this. The STM32CubeMX configuration tool correctly implements this limitation in the UI, it is a good way to cross-check. Signed-off-by: Benedek Kupper <[email protected]>
1 parent d98f7ff commit 3e3cc3e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

drivers/dma/dma_stm32.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,25 @@ DMA_STM32_EXPORT_API int dma_stm32_configure(const struct device *dev,
344344
dev->name);
345345
return -ENOTSUP;
346346
}
347-
#endif /* CONFIG_DMA_STM32_V1 */
348-
349347
/* Support only the same data width for source and dest */
350-
if ((config->dest_data_size != config->source_data_size)) {
348+
if (config->dest_data_size != config->source_data_size) {
351349
LOG_ERR("source and dest data size differ.");
352350
return -EINVAL;
353351
}
352+
#else
353+
if (config->dest_data_size != 4U &&
354+
config->dest_data_size != 2U &&
355+
config->dest_data_size != 1U) {
356+
LOG_ERR("dest unit size error, %d",
357+
config->dest_data_size);
358+
return -EINVAL;
359+
}
360+
#endif /* CONFIG_DMA_STM32_V1 */
354361

355362
if (config->source_data_size != 4U &&
356363
config->source_data_size != 2U &&
357364
config->source_data_size != 1U) {
358-
LOG_ERR("source and dest unit size error, %d",
365+
LOG_ERR("source unit size error, %d",
359366
config->source_data_size);
360367
return -EINVAL;
361368
}

0 commit comments

Comments
 (0)