From ae5117365674030c6bb25269a7eee20e410db751 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 3 Mar 2012 11:11:14 +1100 Subject: [PATCH] SITL: fixed delay() to account for signal interrupions when a timer went off we stopped the delay() code --- libraries/Desktop/support/Arduino.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/Desktop/support/Arduino.cpp b/libraries/Desktop/support/Arduino.cpp index ab4caa7d83..78f123577d 100644 --- a/libraries/Desktop/support/Arduino.cpp +++ b/libraries/Desktop/support/Arduino.cpp @@ -59,7 +59,10 @@ long unsigned int micros(void) void delayMicroseconds(unsigned usec) { - usleep(usec); + uint32_t start = micros(); + while (micros() - start < usec) { + usleep(usec - (micros() - start)); + } } void delay(long unsigned msec)