Skip to content

cores: arduino: zephyrCommon: rework tone slot handling and timer lifecycle#340

Open
soburi wants to merge 1 commit intoarduino:mainfrom
soburi:improve_tone
Open

cores: arduino: zephyrCommon: rework tone slot handling and timer lifecycle#340
soburi wants to merge 1 commit intoarduino:mainfrom
soburi:improve_tone

Conversation

@soburi
Copy link

@soburi soburi commented Feb 15, 2026

Rework tone/noTone internals to better match Arduino behavior while making
concurrent tone usage configurable and safer.

  • Add CONFIG_ARDUINO_MAX_TONES (default: -1).
    • Negative values fall back to the digital pin count from devicetree.
  • Replace per-pin tone timer arrays with slot-based pin_timer entries.
  • Remove the timeout companion timer and finish finite tones by counting
    remaining toggles in tone_expiry_cb().

@soburi soburi marked this pull request as ready for review February 15, 2026 08:22
Copilot AI review requested due to automatic review settings February 15, 2026 08:22
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the tone() function implementation in the Arduino core for Zephyr to provide more flexible timer allocation and fix issues with tone duration handling. The changes enable dynamic timer allocation instead of requiring one timer per pin, and add a configuration option to control the maximum number of simultaneous tones.

Changes:

  • Added CONFIG_ARDUINO_MAX_TONES Kconfig option to allow configuring the maximum number of simultaneous tones
  • Refactored timer management to use a dynamic allocation scheme with pin_timer structures
  • Consolidated timer callbacks into a single callback that handles both toggling and duration management
  • Modified the tone generation logic to track toggle counts for precise duration control

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.

File Description
Kconfig Adds configuration option for maximum simultaneous tones (default -1 means use all pins)
cores/arduino/zephyrCommon.cpp Refactors tone() implementation with dynamic timer allocation, consolidated callback handling, and new toggle-counting duration logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@per1234 per1234 added bug Something isn't working enhancement New feature or request labels Feb 15, 2026
@soburi soburi marked this pull request as draft February 15, 2026 09:52
@soburi soburi force-pushed the improve_tone branch 2 times, most recently from 600a596 to b8d7958 Compare February 18, 2026 12:46
@soburi soburi requested a review from Copilot February 18, 2026 12:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@soburi soburi marked this pull request as ready for review February 21, 2026 06:37
@soburi soburi changed the title cores: arduino: zephyrCommon: Improve tone cores: arduino: zephyrCommon: rework tone slot handling and timer lifecycle Feb 21, 2026
@soburi soburi force-pushed the improve_tone branch 3 times, most recently from ea2c4bc to f68cf55 Compare February 26, 2026 21:27
@CLAassistant
Copy link

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

…ecycle

Rework tone/noTone internals to better match Arduino behavior while making
concurrent tone usage configurable and safer.

- Add CONFIG_ARDUINO_MAX_TONES (default: -1).
  - Negative values fall back to the digital pin count from devicetree.
- Replace per-pin tone timer arrays with slot-based pin_timer entries.
- Remove the timeout companion timer and finish finite tones by counting
  remaining toggles in tone_expiry_cb().

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@github-actions
Copy link

Built 0.53.2-0.dev+351b2873

CI run PASSED 🟢

ArtifactBoardCoreTestsRAMSketchesWarningsErrors
zephyr_contrib ek_ra8d1 📗

11.9%

2--
frdm_mcxn947 3 🏷️

58.0%

2--
frdm_rw612 1 🏷️

83.0%

2--
✔️* zephyr_main giga 4 🏷️ ✅*

54.5%

448-
nano33ble 1 🏷️ ✅*

78.7%

228-
nano_matter 📗 ✔️*

⚠️ 85.7%

208(2*)
niclasense 2 🏷️ ✅*

⚠️ 87.3%

208-
opta 4 🏷️ ✔️*

46.7%

548(2*)
portentac33 3 🏷️ ✔️*

⚠️ 95.1%

568(8*)
portentah7 3 🏷️ ✔️*

47.3%

588(2*)
✅* zephyr_unoq unoq 📗 ✅*

26.4%

628-
Legend

BoardTestStatus description
🔥 🔥 Test run failed to complete.
🔴 Test completed with unexpected errors.
✔️* 🚫 Test completed with errors, but all are known/expected.
✅* 🟡 Test completed with some warnings; no errors detected.
🟢 Test passed successfully, with no warnings or errors.
🌑 🌑 Test was skipped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants