Conversation
a2f7406 to
4fbaf90
Compare
There was a problem hiding this comment.
Pull request overview
This PR refactors the Arduino Zephyr core by splitting the large zephyrCommon.cpp implementation into smaller, more focused compilation units. It also updates multiple sample CMakeLists.txt files to locate devicetree overlay files from variant directories (including revision-specific variants).
Changes:
- Remove
cores/arduino/zephyrCommon.cppand replace it with separate wiring/utility/interrupt/tone source files. - Add
cores/arduino/wiring_private.hto share devicetree-derived pin/port constants across the new units. - Update sample builds to select overlays from variant directories (including
${NORMALIZED_BOARD_TARGET}_${BOARD_REVISION}) and enable ADC/PWM in the blinky sample config.
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| samples/threads_arduino/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/spi_controller/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/serial_event/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/i2cdemo/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/hello_arduino/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/fade/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/button_press_led/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/blinky_arduino/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/attach_interrupt/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/analog_input/CMakeLists.txt | Adds variant directory + overlay selection logic. |
| samples/blinky_arduino/prj.conf | Enables ADC/PWM configs for the blinky sample. |
| cores/arduino/zephyrCommon.cpp | Removed; functionality redistributed into new files. |
| cores/arduino/wiring.cpp | Adds yield/delay/micros/millis wiring functions. |
| cores/arduino/wiring_digital.cpp | Adds pinMode/digitalRead/digitalWrite implementation. |
| cores/arduino/wiring_analog.cpp | Adds PWM/ADC/DAC wiring implementation (gated by Kconfig). |
| cores/arduino/wiring_pulse.cpp | Adds pulseIn() implementation. |
| cores/arduino/WInterrupts.cpp | Adds attach/detach/noInterrupts/interrupts implementation. |
| cores/arduino/WMath.cpp | Adds random/randomSeed implementation (when non-minimal libc). |
| cores/arduino/Tone.cpp | Adds tone/noTone implementation. |
| cores/arduino/wiring_private.h | Introduces shared devicetree-derived pin/port constants. |
| cores/arduino/CMakeLists.txt | Replaces zephyrCommon.cpp with the new split source list. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| namespace arduino { | ||
| namespace zephyr { | ||
|
|
||
| constexpr struct gpio_dt_spec arduino_pins[] = { |
There was a problem hiding this comment.
arduino_pins is defined in this header with internal linkage, so every .cpp that includes wiring_private.h will get its own copy of the pins table. This can unnecessarily increase flash/RAM usage on embedded targets. Prefer a single definition in a .cpp with an extern declaration here (e.g., extern const gpio_dt_spec arduino_pins[NUM_OF_DIGITAL_PINS];), or use an inline variable approach if the project is guaranteed to build with C++17+.
| constexpr struct gpio_dt_spec arduino_pins[] = { | |
| inline constexpr struct gpio_dt_spec arduino_pins[] = { |
8c8d243 to
9fb90ae
Compare
9fb90ae to
48685d8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
48685d8 to
83753ff
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
83753ff to
97e1a67
Compare
e596183 to
b216d39
Compare
Move constexpr-specified constants and functions used for compile-time calculations from zephyrCommon.cpp to wiring_private.h Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
f5ffc41 to
ae2cd5c
Compare
Split zephyrCommon.cpp into small cpp files. wirinig_digital.cpp: - pinMode - digitalWrite - digitalRead wirinig_analog.cpp: - analogRead - analogWrite - analogReference - analogReadResolution - analogWriteResolution wirinig_pulse.cpp: - pulseIn WInterrupts.cpp: - attachInterrupt - detachInterrupt - interrupts - noInterrupts - digitalPinToInterrupt WMath.cpp: - randomSeed - random Tone.cpp: - tone - noTone Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
ae2cd5c to
ed51751
Compare
Built
|
| Artifact | Board | Core | Tests | RAM | Sketches | Warnings | Errors |
|---|---|---|---|---|---|---|---|
✅* zephyr_contrib |
ek_ra8d1
| 📗 | ✅* |
11.9% |
2 | 2 | - |
frdm_mcxn947
| 3 🏷️ | ✅* |
57.9% |
2 | 2 | - | |
frdm_rw612
| 1 🏷️ | ✅* |
83.0% |
2 | 2 | - | |
✔️* zephyr_main |
giga
| 4 🏷️ | ✅* |
54.5% |
44 | 14 | - |
nano33ble
| 1 🏷️ | ✅* |
78.7% |
22 | 10 | - | |
nano_matter
| 📗 | ✔️* |
|
20 | 10 | (2*) | |
niclasense
| 2 🏷️ | ✅* |
|
20 | 10 | - | |
opta
| 4 🏷️ | ✔️* |
46.6% |
54 | 26 | (2*) | |
portentac33
| 3 🏷️ | ✔️* |
|
56 | 28 | (8*) | |
portentah7
| 3 🏷️ | ✔️* |
47.3% |
58 | 28 | (2*) | |
✅* zephyr_unoq |
unoq
| 📗 | ✅* |
26.3% |
52 | 10 | - |
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.
Split zephyrCommon.cpp into small cpp files.