mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-30 11:24:12 +01:00
Fixing delay() to delay at least N milliseconds.
Fixing register name in micros() for ATmega8.
This commit is contained in:
parent
32b1245ee9
commit
9fc613ad6f
@ -59,8 +59,14 @@ unsigned long micros() {
|
|||||||
|
|
||||||
cli();
|
cli();
|
||||||
t = TCNT0;
|
t = TCNT0;
|
||||||
|
|
||||||
|
#ifdef TIFR0
|
||||||
if ((TIFR0 & _BV(TOV0)) && (t == 0))
|
if ((TIFR0 & _BV(TOV0)) && (t == 0))
|
||||||
t = 256;
|
t = 256;
|
||||||
|
#else
|
||||||
|
if ((TIFR & _BV(TOV0)) && (t == 0))
|
||||||
|
t = 256;
|
||||||
|
#endif
|
||||||
|
|
||||||
m = timer0_overflow_count;
|
m = timer0_overflow_count;
|
||||||
SREG = oldSREG;
|
SREG = oldSREG;
|
||||||
@ -72,7 +78,7 @@ void delay(unsigned long ms)
|
|||||||
{
|
{
|
||||||
unsigned long start = millis();
|
unsigned long start = millis();
|
||||||
|
|
||||||
while (millis() - start < ms)
|
while (millis() - start <= ms)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user