Skip to content

Commit

Permalink
stmhal: Fix slow SPI DMA transfers by removing wfi from DMA wait loop.
Browse files Browse the repository at this point in the history
Addresses issue #1268.
  • Loading branch information
dpgeorge committed Jun 3, 2015
1 parent 80f638f commit 53a8aeb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion stmhal/spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 53a8aeb

Please sign in to comment.