From 0f3e30a0c3f06aae58a7f343fd7820dded6b08c8 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 6 Dec 2012 13:37:56 +1100 Subject: [PATCH] HAL_AVR: fixed race condition in delay() --- libraries/AP_HAL_AVR/Scheduler.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libraries/AP_HAL_AVR/Scheduler.cpp b/libraries/AP_HAL_AVR/Scheduler.cpp index bd6fac5699..46fd4fddc0 100644 --- a/libraries/AP_HAL_AVR/Scheduler.cpp +++ b/libraries/AP_HAL_AVR/Scheduler.cpp @@ -1,3 +1,4 @@ +/// -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- #include #include @@ -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) {