Skip to content

Fix ADC_PINS and PWM_PINS compilation in global-GPIO mode#10

Merged
soburi merged 5 commits into
configure_by_connector_deffrom
copilot/sub-pr-4-one-more-time
Feb 10, 2026
Merged

Fix ADC_PINS and PWM_PINS compilation in global-GPIO mode#10
soburi merged 5 commits into
configure_by_connector_deffrom
copilot/sub-pr-4-one-more-time

Conversation

Copilot AI commented Feb 10, 2026

Copy link
Copy Markdown

When adc_pin_gpios or pwm_pin_gpios are used without digital_pin_gpios, the DIGITAL_PIN_GPIOS_FIND_PIN macro is unavailable, causing compilation failure.

Changes

  • ADC_PINS and PWM_PINS macros: Added conditional compilation to use ZARD_GLOBAL_GPIO_NUM when digital_pin_gpios is absent, deriving global GPIO numbers directly from GPIO specifiers (port + pin).
#if DT_NODE_HAS_PROP(DT_PATH(zephyr_user), digital_pin_gpios)
#define ADC_PINS(n, p, i) \
	DIGITAL_PIN_GPIOS_FIND_PIN( \
                DT_REG_ADDR(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)), \
                DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin)),
#else
#define ADC_PINS(n, p, i) \
	ZARD_GLOBAL_GPIO_NUM(DT_PHANDLE_BY_IDX(DT_PATH(zephyr_user), p, i)) + \
	                DT_PHA_BY_IDX(DT_PATH(zephyr_user), p, i, pin),
#endif

This aligns with the existing approach used in analogPins enum (Arduino.h:162-169).


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 10, 2026 22:59
When adc_pin_gpios or pwm_pin_gpios are used without digital_pin_gpios
(global-GPIO mode), the DIGITAL_PIN_GPIOS_FIND_PIN macro is not available.
This commit adds conditional compilation to use ZARD_GLOBAL_GPIO_NUM in
global-GPIO mode, which derives the global GPIO number from the GPIO
specifier (port and pin).

Fixes compilation issue when using adc-pin-gpios or pwm-pin-gpios in
global-GPIO mode.

Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
Align continuation lines consistently with the rest of the code style.

Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
Remove accidentally committed CodeQL build artifacts from the repository
and add them to .gitignore to prevent future commits.

Co-authored-by: soburi <458281+soburi@users.noreply.github.com>
Copilot AI changed the title [WIP] Address feedback from review on connector def PR Fix ADC_PINS and PWM_PINS compilation in global-GPIO mode Feb 10, 2026
Copilot AI requested a review from soburi February 10, 2026 23:02
@soburi soburi marked this pull request as ready for review February 10, 2026 23:25
Copilot AI review requested due to automatic review settings February 10, 2026 23:25
@soburi soburi merged commit 0b0c156 into configure_by_connector_def Feb 10, 2026

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

Fixes build failures in Zephyr “global-GPIO” mode by making ADC_PINS and PWM_PINS work when digital_pin_gpios is not defined (and DIGITAL_PIN_GPIOS_FIND_PIN is therefore unavailable).

Changes:

  • Add conditional compilation for PWM_PINS to fall back to global GPIO numbering via ZARD_GLOBAL_GPIO_NUM(...) + pin when digital_pin_gpios is absent.
  • Add the same conditional compilation for ADC_PINS.
  • Ignore CodeQL build artifacts in .gitignore.

Reviewed changes

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

File Description
cores/arduino/zephyrCommon.cpp Adds digital_pin_gpios-aware fallbacks so PWM/ADC pin mapping compiles in global-GPIO mode.
.gitignore Ignores CodeQL-generated build directories/files.

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

@soburi soburi deleted the copilot/sub-pr-4-one-more-time branch February 11, 2026 03:53
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.

3 participants