diff --git a/Upstream/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h b/Upstream/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h index dfdc0c5..0e86632 100644 --- a/Upstream/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h +++ b/Upstream/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_spi.h @@ -302,6 +302,8 @@ typedef struct __SPI_HandleTypeDef * @} */ +#define SPI_TIMEOUT_VALUE 2 + /** * @} */ diff --git a/Upstream/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c b/Upstream/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c index d412fdc..be5326a 100644 --- a/Upstream/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c +++ b/Upstream/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c @@ -104,7 +104,6 @@ /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ -#define SPI_TIMEOUT_VALUE 2 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ diff --git a/Upstream/Src/upstream_spi.c b/Upstream/Src/upstream_spi.c index caf20b1..e4787d1 100644 --- a/Upstream/Src/upstream_spi.c +++ b/Upstream/Src/upstream_spi.c @@ -442,13 +442,16 @@ void Upstream_BeginTransmitPacketSize(void) { UpstreamInterfaceState = UPSTREAM_INTERFACE_TX_SIZE; SPI1_NSS_ASSERT; - if (HAL_SPI_TransmitReceive_DMA(&Hspi1, + if (HAL_SPI_TransmitReceive(&Hspi1, (uint8_t*)&CurrentWorkingPacket->Length16, (uint8_t*)&TemporaryIncomingPacketLength, - 2) != HAL_OK) //We only need to write one word, but the peripheral library freaks out... + 2, + SPI_TIMEOUT_VALUE) != HAL_OK) //We only need to write one word, but the peripheral library freaks out... { UPSTREAM_SPI_FREAKOUT; } + + HAL_SPI_TxRxCpltCallback(&Hspi1); } @@ -485,13 +488,16 @@ void Upstream_BeginReceivePacketSize(UpstreamPacketTypeDef* freePacket) CurrentWorkingPacket = freePacket; CurrentWorkingPacket->Length16 = 0; //Our RX buffer is used by HAL_SPI_TransmitReceive_DMA as dummy TX data, we set Length to 0 so downstream will know this is a dummy packet. SPI1_NSS_ASSERT; - if (HAL_SPI_TransmitReceive_DMA(&Hspi1, + if (HAL_SPI_TransmitReceive(&Hspi1, (uint8_t*)&CurrentWorkingPacket->Length16, (uint8_t*)&CurrentWorkingPacket->Length16, - 2) != HAL_OK) //We only need to write one word, but the peripheral library freaks out... + 2, + SPI_TIMEOUT_VALUE) != HAL_OK) //We only need to write one word, but the peripheral library freaks out... { UPSTREAM_SPI_FREAKOUT; } + + HAL_SPI_TxRxCpltCallback(&Hspi1); }