From 79efdb18635dab0b5538febdf4de4f57714bdcfd Mon Sep 17 00:00:00 2001 From: Daniel Fekete Date: Sun, 25 Jun 2017 11:44:22 +0200 Subject: [PATCH] delay: call yield() --- STM32/cores/arduino/stm32/stm32_clock.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/STM32/cores/arduino/stm32/stm32_clock.h b/STM32/cores/arduino/stm32/stm32_clock.h index dec2b00..b605720 100644 --- a/STM32/cores/arduino/stm32/stm32_clock.h +++ b/STM32/cores/arduino/stm32/stm32_clock.h @@ -35,7 +35,11 @@ extern "C"{ #endif inline void delay(unsigned long millis) { - HAL_Delay(millis); + uint32_t tickstart = 0; + tickstart = HAL_GetTick(); + while((HAL_GetTick() - tickstart) < millis) { + yield(); + } } inline uint32_t millis() { @@ -59,7 +63,9 @@ inline uint32_t micros() { inline void delayMicroseconds(uint32_t microseconds){ uint32_t start = micros(); - while(start + microseconds > micros()); + while(start + microseconds > micros()) { + yield(); + } } #ifdef __cplusplus