Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ config ARDUINO_MAX_TONES
If set to -1 (or any other negative value), the maximum number will be
determined from the system's digital pin configuration.

config ARDUINO_DELAY_US_COMPENSATION
int "delayMicroseconds() compensation value (us)"
Comment thread
soburi marked this conversation as resolved.
Comment thread
soburi marked this conversation as resolved.
default 1
range 0 2147483647
help
Compensation value, in microseconds, subtracted from the requested
delay in delayMicroseconds() to account for software overhead.
This can improve short-delay accuracy.

endif

if USB_DEVICE_STACK_NEXT
Expand Down
8 changes: 7 additions & 1 deletion cores/arduino/inlines.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ inline __attribute__((always_inline)) void delay(unsigned long ms) {
}

inline __attribute__((always_inline)) void delayMicroseconds(unsigned int us) {
#if CONFIG_ARDUINO_DELAY_US_COMPENSATION < 2
if (us == 0) {
return;
}
k_busy_wait(us - 1);
#else
if (us < CONFIG_ARDUINO_DELAY_US_COMPENSATION) {
return;
}
#endif
k_busy_wait(us - CONFIG_ARDUINO_DELAY_US_COMPENSATION);
Comment thread
soburi marked this conversation as resolved.
}

#endif /* __INLINES_H__ */
Loading