From b1a350a18a13232b25cbacb35d500e6ec45ae85f Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Fri, 6 Sep 2024 15:11:29 -0500 Subject: [PATCH] bsps/stm32h7: Add full duplex support for SPI --- bsps/arm/stm32h7/spi/spi-support.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/bsps/arm/stm32h7/spi/spi-support.c b/bsps/arm/stm32h7/spi/spi-support.c index 45df6aae72..026e25a062 100644 --- a/bsps/arm/stm32h7/spi/spi-support.c +++ b/bsps/arm/stm32h7/spi/spi-support.c @@ -298,13 +298,19 @@ static int stm32h7_spi_transfer( return 1; } /* perform transfer */ - if (msg->tx_buf != NULL) { + if (msg->tx_buf != NULL && msg->rx_buf != NULL) { + status = HAL_SPI_TransmitReceive( + &ctx->spi, msg->tx_buf, msg->rx_buf, msg->len, 100 + ); + if (status != HAL_OK) { + return 1; + } + } else if (msg->tx_buf != NULL) { status = HAL_SPI_Transmit(&ctx->spi, msg->tx_buf, msg->len, 100); if (status != HAL_OK) { return 1; } - } - if (msg->rx_buf != NULL) { + } else if (msg->rx_buf != NULL) { status = HAL_SPI_Receive(&ctx->spi, msg->rx_buf, msg->len, 100); if (status != HAL_OK) { return 1;