Skip to content

[DNM] zephyrCommon: Changing pin numbering rules #134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: next
Choose a base branch
from

Conversation

soburi
Copy link
Member

@soburi soburi commented Aug 23, 2025

Zephyr's ba48d83bec18e9f2caf61979aadf9f8537086cee
changes make it easy to configure pin numbering at compile,
so we'll change the pin numbers to be based on the GPIO pin numbers.

This is same as the traditional Arduino, using the GPIO numbers as
pin numbers. Pin names written on the board, such as D1 and D2,
are aliases for these pin numbers.

When using multiple GPIO ports, pin numbers are numbered consecutively
from the beginning. In other words, if you have two 16-port GPIOs,
17 refers to the second pin (idx=1) of the second port.

soburi and others added 14 commits August 23, 2025 22:14
Use the checkpatch.pl included with Zephyr to perform the check.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Changed boards to be specified by their normalized names.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Modify to use west.yml included in the PR version.
Accordingly, the initialization process has been changed.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Added cmsis_6 to the repository in line with the update of Zephyr.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Get the variant name (NORMALIZED_BOARD_TARGET) from the Zephyr build
system as early as possible. This allows to have per-target build
directories.

Note that a bug with the shield specifiers does not currently allow to
reuse the same build directory multiple times.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Co-authored-by: Luca Burelli <l.burelli@arduino.cc>
Fixed an issue where the reference location for the interrupt
handler was a bit mask instead of an index value.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Improved to align more closely with the standard Arduino implementation.

- Eliminated the end timer and used counting to determine the end.
- Improved to handle infinity correctly.
- Added a guard to prevent the timeout value from reaching 0.
- Set the GPIO value to 0 when the timer starts.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Since the general Arduino implementation does not check the GPIO
direction, this check has been removed to improve compatibility.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
If gpio is not initialized, the pulseIn function will terminate
without running the timer.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Since Arduino's `delayMicroseconds` is implemented as a busy loop,
we change it to using `k_busy_wait` to improve compatibility.
Reformatting indentation for `delay` and `millis`.
Added a comment because it was difficult to understand
where the namespace ends.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
The PWM index range check processing was performed after the index
was referenced, so it was now performed first.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
Zephyr's ba48d83bec18e9f2caf61979aadf9f8537086cee
changes make it easy to configure pin numbering at compile,
so we'll change the pin numbers to be based on the GPIO pin numbers.

This is same as the traditional Arduino, using the GPIO numbers as
pin numbers. Pin names written on the board, such as D1 and D2,
are aliases for these pin numbers.

When using multiple GPIO ports, pin numbers are numbered consecutively
from the beginning. In other words, if you have two 16-port GPIOs,
17 refers to the second pin (idx=1) of the second port.

Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
@soburi soburi force-pushed the global_pin_number branch from 0747e08 to 014a6ed Compare August 23, 2025 22:46
@soburi soburi changed the title zephyrCommon: Changing pin numbering rules [DNM] zephyrCommon: Changing pin numbering rules Aug 23, 2025
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.

1 participant