diff options
| author | Damien George <damien.p.george@gmail.com> | 2015-06-03 23:20:23 +0100 |
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2015-06-03 23:20:23 +0100 |
| commit | 53a8aeb6e7a89ad169ad3f9e5553d51fb86c03b8 (patch) | |
| tree | 4affb6ec9de948138a7a66a1fda55bb74ad0a112 | |
| parent | 80f638fe19f6d40c53792eebda2dfdecc82ad75e (diff) | |
stmhal: Fix slow SPI DMA transfers by removing wfi from DMA wait loop.
Addresses issue #1268.
| -rw-r--r-- | stmhal/spi.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/stmhal/spi.c b/stmhal/spi.c index da24b701f..19c36d0a3 100644 --- a/stmhal/spi.c +++ b/stmhal/spi.c @@ -290,12 +290,14 @@ void spi_deinit(SPI_HandleTypeDef *spi) { } STATIC HAL_StatusTypeDef spi_wait_dma_finished(SPI_HandleTypeDef *spi, uint32_t timeout) { + // Note: we can't use WFI to idle in this loop because the DMA completion + // interrupt may occur before the WFI. Hence we miss it and have to wait + // until the next sys-tick (up to 1ms). uint32_t start = HAL_GetTick(); while (HAL_SPI_GetState(spi) != HAL_SPI_STATE_READY) { if (HAL_GetTick() - start >= timeout) { return HAL_TIMEOUT; } - __WFI(); } return HAL_OK; } |
