Skip to content

Commit d148f91

Browse files
committed
cores: arduino: zephyrCommon: Correct tone() behavior with duration=0
Fixed a bug where tone() with duration=0 would stop the tone immediately instead of ringing infinitely. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
1 parent 766dd5b commit d148f91

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cores/arduino/zephyrCommon.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,14 +247,12 @@ void tone_expiry_cb(struct k_timer *timer) {
247247
struct pin_timer *pt = CONTAINER_OF(timer, struct pin_timer, timer);
248248
const struct gpio_dt_spec *spec = &arduino_pins[pt->pin];
249249

250-
if (pt->count == 0) {
250+
if (pt->count == 0 && !pt->infinity) {
251251
k_timer_stop(timer);
252252
gpio_pin_set_dt(spec, 0);
253253
} else {
254254
gpio_pin_toggle_dt(spec);
255-
if (!pt->infinity) {
256-
pt->count--;
257-
}
255+
pt->count--;
258256
}
259257
}
260258

0 commit comments

Comments
 (0)