From a4d6036302a558d0619237a554db39f95e0192fa Mon Sep 17 00:00:00 2001 From: jazzpi Date: Sat, 30 Jul 2022 22:25:09 +0200 Subject: [PATCH] Reduce SPI frame timeout --- Core/Inc/SPI_Slave_Communication.h | 2 ++ Core/Src/SPI_Slave_Communication.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Core/Inc/SPI_Slave_Communication.h b/Core/Inc/SPI_Slave_Communication.h index 2eaee6b..e6a80f6 100644 --- a/Core/Inc/SPI_Slave_Communication.h +++ b/Core/Inc/SPI_Slave_Communication.h @@ -27,6 +27,8 @@ #define GET_ERROR_CMD_LEN 1 #define GET_MEASUREMENTS_CMD_LEN 1 +#define SPI_FRAME_TIMEOUT 300 + void spi_communication_init(SPI_HandleTypeDef* spi, AIRStateHandler* airstatemaschine); void checkSPI(); diff --git a/Core/Src/SPI_Slave_Communication.c b/Core/Src/SPI_Slave_Communication.c index 94e38f1..122b4c4 100644 --- a/Core/Src/SPI_Slave_Communication.c +++ b/Core/Src/SPI_Slave_Communication.c @@ -335,7 +335,7 @@ void InterSTMFrame() { spi_transfer_complete = 0; HAL_SPI_Receive_IT(spibus, spirxbuf, 13); HAL_GPIO_WritePin(Inter_STM_IRQ_GPIO_Port, Inter_STM_IRQ_Pin, GPIO_PIN_SET); - uint32_t timeout = HAL_GetTick() + 500; + uint32_t timeout = HAL_GetTick() + SPI_FRAME_TIMEOUT; while (!spi_transfer_complete && HAL_GetTick() < timeout) { } HAL_GPIO_WritePin(Inter_STM_IRQ_GPIO_Port, Inter_STM_IRQ_Pin, GPIO_PIN_RESET);