summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorKrzysztof Blazewicz <krzysztof.blazewicz@uxeon.com>2016-09-08 18:13:22 +0200
committerKrzysztof Blazewicz <krzysztof.blazewicz@uxeon.com>2016-11-16 12:43:27 +0100
commit4f7c5fa64769f836b1cb3d357be4864807e10694 (patch)
tree7a84fecf02e106c33ee2b7622c40bcb410f380bb
parentc79ff9930aed2a91a888f8eb58f27946ca8287ca (diff)
downloadmicropython-4f7c5fa64769f836b1cb3d357be4864807e10694.tar.gz
micropython-4f7c5fa64769f836b1cb3d357be4864807e10694.zip
stmhal/hal: reapply HAL commit 9db719b for f4
-rw-r--r--stmhal/hal/f4/src/stm32f4xx_hal.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/stmhal/hal/f4/src/stm32f4xx_hal.c b/stmhal/hal/f4/src/stm32f4xx_hal.c
index d388dbf1c2..c0965368ed 100644
--- a/stmhal/hal/f4/src/stm32f4xx_hal.c
+++ b/stmhal/hal/f4/src/stm32f4xx_hal.c
@@ -337,11 +337,14 @@ __weak uint32_t HAL_GetTick(void)
*/
__weak void HAL_Delay(__IO uint32_t Delay)
{
- uint32_t tickstart = 0U;
- tickstart = HAL_GetTick();
- while((HAL_GetTick() - tickstart) < Delay)
- {
- }
+ uint32_t start = HAL_GetTick();
+
+ // Note that the following works (due to the magic of 2's complement numbers)
+ // even when Delay causes wraparound.
+
+ while (HAL_GetTick() - start <= Delay) {
+ __WFI(); // enter sleep mode, waiting for interrupt
+ }
}
/**