Skip to content

Commit 5f501e5

Browse files
authored
Fix: Increase accuracy of "delay()" routine. (#203)
This fixes #194.
1 parent 1e94dfe commit 5f501e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: cores/arduino/time.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
// this file implements the following public funcions: delay, delayMicroseconds, yield, millis, micros
66

7-
__attribute__((weak)) void delay(uint32_t ms) {
8-
R_BSP_SoftwareDelay(ms, BSP_DELAY_UNITS_MILLISECONDS);
7+
__attribute__((weak)) void delay(uint32_t ms)
8+
{
9+
auto const start = millis();
10+
auto const stop = start + ms;
11+
while(millis() < stop) yield();
912
}
1013

1114
void delayMicroseconds(unsigned int us) {

0 commit comments

Comments
 (0)