File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,6 +38,15 @@ config ARDUINO_MAX_TONES
3838 If set to -1 (or any other negative value), the maximum number will be
3939 determined from the system's digital pin configuration.
4040
41+ config ARDUINO_DELAY_US_COMPENSATION
42+ int "delayMicroseconds() compensation value (us)"
43+ default 1
44+ range 0 2147483647
45+ help
46+ Compensation value, in microseconds, subtracted from the requested
47+ delay in delayMicroseconds() to account for software overhead.
48+ This can improve short-delay accuracy.
49+
4150endif
4251
4352if USB_DEVICE_STACK_NEXT
Original file line number Diff line number Diff line change @@ -18,10 +18,16 @@ inline __attribute__((always_inline)) void delay(unsigned long ms) {
1818}
1919
2020inline __attribute__((always_inline )) void delayMicroseconds (unsigned int us ) {
21+ #if CONFIG_ARDUINO_DELAY_US_COMPENSATION < 2
2122 if (us == 0 ) {
2223 return ;
2324 }
24- k_busy_wait (us - 1 );
25+ #else
26+ if (us < CONFIG_ARDUINO_DELAY_US_COMPENSATION ) {
27+ return ;
28+ }
29+ #endif
30+ k_busy_wait (us - CONFIG_ARDUINO_DELAY_US_COMPENSATION );
2531}
2632
2733#endif /* __INLINES_H__ */
You can’t perform that action at this time.
0 commit comments