From a80fd4fcb6cf5a7fd658aa5f2af1705a911444f4 Mon Sep 17 00:00:00 2001 From: Jidong Chen <123861172+jchen-dawnscene@users.noreply.github.com> Date: Mon, 13 Nov 2023 09:07:17 +0100 Subject: [PATCH] fix(SPI): avoid 0 delay when SPI clock > 1MHz Fixes #2181. Signed-off-by: Jidong Chen <123861172+jchen-dawnscene@users.noreply.github.com> Co-Authored-By: Frederic Pillon --- libraries/SPI/src/utility/spi_com.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/SPI/src/utility/spi_com.c b/libraries/SPI/src/utility/spi_com.c index a67813e6b7..2cc6c28907 100644 --- a/libraries/SPI/src/utility/spi_com.c +++ b/libraries/SPI/src/utility/spi_com.c @@ -214,7 +214,7 @@ static uint32_t compute_disable_delay(spi_t *obj) SPI_HandleTypeDef *handle = &(obj->handle); prescaler = 1 << ((handle->Init.BaudRatePrescaler >> SPI_CFG1_MBR_Pos) + 1); - disable_delay = ((prescaler * 1000000) / spi_freq) / 2; + disable_delay = (((prescaler * 1000000) / spi_freq) / 2) + 1; return disable_delay; } #endif