From 22ae8fca22ba66cb12b2eec36f784e7f8ccf2d06 Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Fri, 22 Aug 2025 06:31:43 +0900 Subject: [PATCH 1/2] zephyrCommon: Change `delayMicroseconds` to busy loop Since Arduino's `delayMicroseconds` is implemented as a busy loop, we change it to using `k_busy_wait` to improve compatibility. Signed-off-by: TOKITA Hiroshi --- cores/arduino/zephyrCommon.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cores/arduino/zephyrCommon.cpp b/cores/arduino/zephyrCommon.cpp index 6fa94bc4..c5611380 100644 --- a/cores/arduino/zephyrCommon.cpp +++ b/cores/arduino/zephyrCommon.cpp @@ -259,7 +259,9 @@ void noTone(pin_size_t pinNumber) { void delay(unsigned long ms) { k_sleep(K_MSEC(ms)); } -void delayMicroseconds(unsigned int us) { k_sleep(K_USEC(us)); } +void delayMicroseconds(unsigned int us) { + k_busy_wait(us); +} unsigned long micros(void) { return k_cyc_to_us_floor32(k_cycle_get_32()); From e2a0eb889dca61f9732b827fb5a21080e7fe819d Mon Sep 17 00:00:00 2001 From: TOKITA Hiroshi Date: Sat, 23 Aug 2025 11:02:37 +0900 Subject: [PATCH 2/2] zephyrCommon: apply Arduino-style indentation Reformatting indentation for `delay` and `millis`. Signed-off-by: TOKITA Hiroshi --- cores/arduino/zephyrCommon.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cores/arduino/zephyrCommon.cpp b/cores/arduino/zephyrCommon.cpp index c5611380..c8681f93 100644 --- a/cores/arduino/zephyrCommon.cpp +++ b/cores/arduino/zephyrCommon.cpp @@ -257,7 +257,9 @@ void noTone(pin_size_t pinNumber) { gpio_pin_set_dt(&arduino_pins[pinNumber], 0); } -void delay(unsigned long ms) { k_sleep(K_MSEC(ms)); } +void delay(unsigned long ms) { + k_sleep(K_MSEC(ms)); +} void delayMicroseconds(unsigned int us) { k_busy_wait(us); @@ -267,7 +269,9 @@ unsigned long micros(void) { return k_cyc_to_us_floor32(k_cycle_get_32()); } -unsigned long millis(void) { return k_uptime_get_32(); } +unsigned long millis(void) { + return k_uptime_get_32(); +} #ifdef CONFIG_PWM