From ccb832c2246a05aac03c19727836102fdea17e1f Mon Sep 17 00:00:00 2001 From: vbextreme Date: Sun, 27 Dec 2015 14:49:25 +0100 Subject: fix delay/yield on avr, if function called by yield takes more a millisecond the delay fails --- cores/arduino/wiring.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cores') diff --git a/cores/arduino/wiring.c b/cores/arduino/wiring.c index 1c3e5a5..b956f78 100644 --- a/cores/arduino/wiring.c +++ b/cores/arduino/wiring.c @@ -105,11 +105,11 @@ unsigned long micros() { void delay(unsigned long ms) { - uint16_t start = (uint16_t)micros(); + uint32_t start = micros(); while (ms > 0) { yield(); - if (((uint16_t)micros() - start) >= 1000) { + while ( ms > 0 && (micros() - start) >= 1000) { ms--; start += 1000; } -- cgit v1.2.3-18-g5258