cores: arduino: zephyrCommon: rework tone slot handling and timer lifecycle#340
cores: arduino: zephyrCommon: rework tone slot handling and timer lifecycle#340soburi wants to merge 1 commit intoarduino:mainfrom
Conversation
There was a problem hiding this comment.
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_TONESKconfig option to allow configuring the maximum number of simultaneous tones - Refactored timer management to use a dynamic allocation scheme with
pin_timerstructures - 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.
There was a problem hiding this comment.
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.
600a596 to
b8d7958
Compare
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
toneea2c4bc to
f68cf55
Compare
…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>
Built
|
| Artifact | Board | Core | Tests | RAM | Sketches | Warnings | Errors |
|---|---|---|---|---|---|---|---|
✅ 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% |
44 | 8 | - |
nano33ble
| 1 🏷️ | ✅* |
78.7% |
22 | 8 | - | |
nano_matter
| 📗 | ✔️* |
|
20 | 8 | (2*) | |
niclasense
| 2 🏷️ | ✅* |
|
20 | 8 | - | |
opta
| 4 🏷️ | ✔️* |
46.7% |
54 | 8 | (2*) | |
portentac33
| 3 🏷️ | ✔️* |
|
56 | 8 | (8*) | |
portentah7
| 3 🏷️ | ✔️* |
47.3% |
58 | 8 | (2*) | |
✅* zephyr_unoq |
unoq
| 📗 | ✅* |
26.4% |
62 | 8 | - |
Legend
Board Test Status 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.
Rework tone/noTone internals to better match Arduino behavior while making
concurrent tone usage configurable and safer.
remaining toggles in tone_expiry_cb().