Skip to content

Configure by connector def#4

Closed
soburi wants to merge 44 commits into
nextfrom
configure_by_connector_def
Closed

Configure by connector def#4
soburi wants to merge 44 commits into
nextfrom
configure_by_connector_def

Conversation

@soburi

@soburi soburi commented Feb 10, 2026

Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings February 10, 2026 22:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR extends ArduinoCore-Zephyr’s board configuration model to support deriving Arduino pin behavior from connector devicetree definitions (when /zephyr,user/digital-pin-gpios isn’t provided), and adds documentation plus a new UNO R4 variant overlay for ADC channel setup.

Changes:

  • Add fallback “global GPIO numbering” logic and connector-derived mappings in the Arduino core (GPIO, PWM, ADC, interrupts).
  • Add new board configuration reference/guide documentation and clarify LED_BUILTIN derivation behavior.
  • Introduce an Arduino UNO R4 overlay enabling/configuring adc0 channels.

Reviewed changes

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

Show a summary per file
File Description
variants/arduino_uno_r4_r7fa4m1ab3cfm/arduino_uno_r4_r7fa4m1ab3cfm.overlay Adds ADC node/channel configuration for UNO R4.
documentation/variants.md Clarifies LED_BUILTIN behavior when digital-pin-gpios is absent.
documentation/configuration-reference.md Adds a detailed reference for /zephyr,user and connector-derived behavior.
documentation/configuration-guide.md Adds a practical guide describing support “levels” and how to reach them.
cores/arduino/zephyrCommon.cpp Implements connector/global-numbering GPIO access and connector-derived PWM/ADC fallback logic.
cores/arduino/Arduino.h Adds connector detection and derives D*/A* enums and LED_BUILTIN for global numbering mode.

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

Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread documentation/configuration-reference.md Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI left a comment

Copy link
Copy Markdown

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 6 out of 6 changed files in this pull request and generated 5 comments.


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

Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #8, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #9, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #10, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #11, to work on those changes. Once the pull request is ready, I'll request review from you.

@soburi soburi force-pushed the configure_by_connector_def branch from 5b861f1 to b3744ae Compare February 10, 2026 23:49
@soburi soburi requested a review from Copilot February 10, 2026 23:49
@soburi soburi force-pushed the configure_by_connector_def branch from b3744ae to 0dbaf95 Compare February 10, 2026 23:54

Copilot AI left a comment

Copy link
Copy Markdown

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 6 out of 6 changed files in this pull request and generated 6 comments.


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

Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/Arduino.h Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated
Comment thread cores/arduino/zephyrCommon.cpp Outdated

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #12, to work on those changes. Once the pull request is ready, I'll request review from you.

@soburi

soburi commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

@copilot TODOを実装して。

Copilot AI commented Feb 11, 2026

Copy link
Copy Markdown

@soburi I've opened a new pull request, #13, to work on those changes. Once the pull request is ready, I'll request review from you.

facchinm and others added 3 commits May 4, 2026 05:58
Co-Authored-by: Martino Facchin <m.facchin@arduino.cc>
Co-Authored-by: Luca Burelli <l.burelli@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Co-Authored-by: Kurt Eckhardt <kurte@rockisland.com>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Make analogReference as weak to allow override by each board
implimentations.

Co-Authored-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch 4 times, most recently from d754f16 to d13186a Compare May 7, 2026 23:31
soburi added 3 commits May 28, 2026 06:07
BeagleConnect Freedom now defines multiple revisions in board.yml,
so specify the revision explicitly in CI.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Update for uart_irq_update() changes introduced with
zephyrproject-rtos/zephyr#105231.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
…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>
@soburi soburi force-pushed the configure_by_connector_def branch from d13186a to edaf5de Compare May 31, 2026 07:13
vs11official and others added 2 commits May 31, 2026 19:05
When analogWrite() is called for a pin that cannot be resolved to a PWM channel,
or when the resolved PWM device is not ready,
fall back to GPIO output instead of returning without changing the pin state.

This matches the common Arduino behavior for pins without hardware PWM support:
values above the midpoint drive the pin HIGH,
while lower values drive it LOW. Existing hardware PWM behavior is unchanged.

Co-Authored-by: Satvik <145106491+vs11official@users.noreply.github.com>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Passing -1 to digital I/O functions may happen when libraries do not
properly sanitize their inputs, leading to undefined behavior. This
commit adds a check to ensure that the pin number is valid before
accessing the arduino_pins array.

Signed-off-by: Luca Burelli <l.burelli@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch from edaf5de to 900de85 Compare May 31, 2026 10:43
facchinm and others added 4 commits June 1, 2026 10:41
Add digitalPinToPortDevice() and digitalPinToPinIndex().

Co-authored-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add F_CPU definition for retrive CPU frequency.

Co-authored-by: Martino Facchin <m.facchin@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Co-authored-by: Mike S <CyberMerln@gmail.com>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Allow Arduino APIs to switch a pin between GPIO and peripheral
functions by re-running the selected device init path when
the requested owner changes.

This is an interim pinmux handoff mechanism for boards where
sketches may move a pin back and forth between
serial/GPIO/PWM-style use.

Co-Authored-by: Martino Facchin <m.facchin@arduino.cc>
Co-Authored-by: pennam <m.pennasilico@arduino.cc>
Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch from 900de85 to 5e4800f Compare June 1, 2026 05:19
soburi added 5 commits June 1, 2026 14:20
Define `invalid_pin_number` and replace `pin_size_t(-1)`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
In preparation for improvements to allow the use of GPIOs without
device tree definitions,
the interface will be changed to specify port and pin instead of
`gpio_dt_spec`.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Like digital pins, ADCs and PWMs are also defined from connectors.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Add guide for adding new board configuration and configuration
reference.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
A new configuration method has been adopted, allowing support to be added
with less configuration than before.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the configure_by_connector_def branch from 5e4800f to d7b3c5b Compare June 1, 2026 05:20
soburi added 4 commits June 1, 2026 14:20
Replace {0} with {} for port_callback, set dac_channel_cfg::internal
explicitly, and expand the adc_sequence initialization to make default
values explicit and avoid C++ initializer warnings.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
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>
Split zephyrCommon.cpp into smaller source files.

wiring_digital.cpp:
  - pinMode
  - digitalWrite
  - digitalRead

wiring_analog.cpp:
  - analogRead
  - analogWrite
  - analogReference
  - analogReadResolution
  - analogWriteResolution

wiring_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>
Move the constant array derived from devicetree to wiring_private.h
and convert it to constexpr.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi closed this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.