1 parent 80f638f commit 53a8aebCopy full SHA for 53a8aeb
1 file changed
stmhal/spi.c
@@ -290,12 +290,14 @@ void spi_deinit(SPI_HandleTypeDef *spi) {
290
}
291
292
STATIC HAL_StatusTypeDef spi_wait_dma_finished(SPI_HandleTypeDef *spi, uint32_t timeout) {
293
+ // Note: we can't use WFI to idle in this loop because the DMA completion
294
+ // interrupt may occur before the WFI. Hence we miss it and have to wait
295
+ // until the next sys-tick (up to 1ms).
296
uint32_t start = HAL_GetTick();
297
while (HAL_SPI_GetState(spi) != HAL_SPI_STATE_READY) {
298
if (HAL_GetTick() - start >= timeout) {
299
return HAL_TIMEOUT;
300
- __WFI();
301
302
return HAL_OK;
303
0 commit comments