Skip to content

Commit e7b324a

Browse files
committed
Fix millis() in a cross platform way
1 parent 1a8f79c commit e7b324a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cores/arduino/wiring.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222

2323
#include "wiring_private.h"
2424

25+
static mbed::Timer t;
26+
2527
unsigned long millis()
2628
{
27-
return us_ticker_read() / 1000L;
29+
return t.read_ms();
2830
}
2931

3032
unsigned long micros() {
31-
return us_ticker_read();
33+
return t.read_us();
3234
}
3335

3436
void delay(unsigned long ms)
@@ -42,7 +44,9 @@ void delayMicroseconds(unsigned int us)
4244
}
4345

4446
void init()
45-
{}
47+
{
48+
t.start();
49+
}
4650

4751
void yield() {
4852
rtos::ThisThread::yield();

0 commit comments

Comments
 (0)