mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-07 01:54:26 +01:00
fix delay/yield on avr, if function called by yield takes more a millisecond the delay fails
This commit is contained in:
parent
d893aa0b65
commit
b1231c39e9
@ -105,11 +105,11 @@ unsigned long micros() {
|
|||||||
|
|
||||||
void delay(unsigned long ms)
|
void delay(unsigned long ms)
|
||||||
{
|
{
|
||||||
uint16_t start = (uint16_t)micros();
|
uint32_t start = micros();
|
||||||
|
|
||||||
while (ms > 0) {
|
while (ms > 0) {
|
||||||
yield();
|
yield();
|
||||||
if (((uint16_t)micros() - start) >= 1000) {
|
while ( ms > 0 && (micros() - start) >= 1000) {
|
||||||
ms--;
|
ms--;
|
||||||
start += 1000;
|
start += 1000;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user