HAL_AVR: fixed race condition in delay()

This commit is contained in:
Andrew Tridgell 2012-12-06 13:37:56 +11:00
parent ca4bc8d760
commit 0f3e30a0c3
1 changed files with 2 additions and 0 deletions

View File

@ -1,3 +1,4 @@
/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*-
#include <avr/io.h>
#include <avr/interrupt.h>
@ -183,6 +184,7 @@ void AVRScheduler::delay(uint32_t ms)
while (ms > 0) {
while ((micros() - start) >= 1000) {
ms--;
if (ms == 0) break;
start += 1000;
}
if (_min_delay_cb_ms <= ms) {