Skip to content

Commit 535a7e4

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 750e711 commit 535a7e4

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
@@ -229,14 +229,12 @@ void tone_expiry_cb(struct k_timer *timer) {
229229
struct pin_timer *pt = CONTAINER_OF(timer, struct pin_timer, timer);
230230
const struct gpio_dt_spec *spec = &arduino_pins[pt->pin];
231231

232-
if (pt->count == 0) {
232+
if (pt->count == 0 && !pt->infinity) {
233233
k_timer_stop(timer);
234234
gpio_pin_set_dt(spec, 0);
235235
} else {
236236
gpio_pin_toggle_dt(spec);
237-
if (!pt->infinity) {
238-
pt->count--;
239-
}
237+
pt->count--;
240238
}
241239
}
242240

0 commit comments

Comments
 (0)