Merge pull request #12116 from maribu/arduino-millis

sys/arduino: Added millis()
This commit is contained in:
benpicco 2019-09-05 04:12:46 +02:00 committed by GitHub
commit f421cb7d9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -59,7 +59,7 @@ int digitalRead(int pin)
void delay(unsigned long msec) void delay(unsigned long msec)
{ {
xtimer_usleep(1000 * msec); xtimer_usleep(msec * US_PER_MS);
} }
void delayMicroseconds(unsigned long usec) void delayMicroseconds(unsigned long usec)
@ -72,6 +72,11 @@ unsigned long micros()
return xtimer_now_usec(); return xtimer_now_usec();
} }
unsigned long millis()
{
return xtimer_now_usec() / US_PER_MS;
}
int analogRead(int arduino_pin) int analogRead(int arduino_pin)
{ {
/* /*

View File

@ -103,6 +103,13 @@ void delayMicroseconds(unsigned long usec);
*/ */
unsigned long micros(); unsigned long micros();
/**
* @brief Returns the number of milliseconds since start
*
* @return value of milliseconds since start
*/
unsigned long millis();
/** /**
* @brief Read the current value of the given analog pin * @brief Read the current value of the given analog pin
* *