Skip to content

Commit eccf541

Browse files
djiatsaf-stdanieldegrasse
authored andcommitted
drivers: spi: stm32: dynamically update spi word/frame size
Update the source_data and dest_data sizes with the frame size in bytes before performing the transfer. With these changes, we can handle cases where the buffers switch between 8-bit and 16-bit modes. Signed-off-by: Fabrice DJIATSA <[email protected]>
1 parent 994efc0 commit eccf541

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/spi/spi_ll_stm32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,13 @@ static int transceive_dma(const struct device *dev,
11861186
/* This is turned off in spi_stm32_complete(). */
11871187
spi_stm32_cs_control(dev, true);
11881188

1189+
uint8_t word_size_bytes = bits2bytes(SPI_WORD_SIZE_GET(config->operation));
1190+
1191+
data->dma_rx.dma_cfg.source_data_size = word_size_bytes;
1192+
data->dma_rx.dma_cfg.dest_data_size = word_size_bytes;
1193+
data->dma_tx.dma_cfg.source_data_size = word_size_bytes;
1194+
data->dma_tx.dma_cfg.dest_data_size = word_size_bytes;
1195+
11891196
while (data->ctx.rx_len > 0 || data->ctx.tx_len > 0) {
11901197
size_t dma_len;
11911198

0 commit comments

Comments
 (0)