stmhal/hal: reapply HAL commit 9db719b for f4

This commit is contained in:
Krzysztof Blazewicz 2016-09-08 18:13:22 +02:00
parent c79ff9930a
commit 4f7c5fa647
1 changed files with 8 additions and 5 deletions

View File

@ -337,10 +337,13 @@ __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
}
}