Skip to content

feat(zdevice): add GPIO_ACTIVE_HIGH flag macro#52

Merged
swoisz merged 1 commit into
mainfrom
fix/gpio-active-high
Jun 22, 2026
Merged

feat(zdevice): add GPIO_ACTIVE_HIGH flag macro#52
swoisz merged 1 commit into
mainfrom
fix/gpio-active-high

Conversation

@swoisz

@swoisz swoisz commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

What

gpio_dt.h defined GPIO_ACTIVE_LOW but not its companion GPIO_ACTIVE_HIGH. Active-high pins already behaved correctly at runtime (active-high is simply the absence of the active-low bit — see gpio_pin_get_dt/gpio_pin_set_dt), but any board, devicetree, or application code that referenced the symbol explicitly failed to compile.

Change

  • Define GPIO_ACTIVE_HIGH as (0 << 0), mirroring upstream Zephyr's named-zero form in dt-bindings/gpio/gpio.h:
    #define GPIO_ACTIVE_LOW  (1 << 0)
    #define GPIO_ACTIVE_HIGH (0 << 0)
  • Add a test asserting the macro is zero and that a gpio_dt_spec declared with it behaves identically to the active-high default.

Testing

Linux test suite (idf.py --preview set-target linux && idf.py build && ./build/boreas_test.elf): 224 tests, 0 failures.

The new GPIO test compiles on the esp32s3 target only — test_gpio_flags.c is excluded from the Linux build because the mock requires ESP-IDF's driver/gpio.h.

🤖 Generated with Claude Code

gpio_dt.h defined GPIO_ACTIVE_LOW but not its companion GPIO_ACTIVE_HIGH.
Active-high pins already behaved correctly (active-high is the absence of
the active-low bit), but code referencing the symbol explicitly failed to
compile.

Define GPIO_ACTIVE_HIGH as (0 << 0), mirroring upstream Zephyr's named-zero
form in dt-bindings/gpio/gpio.h. Add a test asserting it is zero and that a
spec declared with it behaves identically to the active-high default.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

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 adds an explicit GPIO_ACTIVE_HIGH macro to the Zephyr-compatible gpio_dt.h GPIO DT helpers so devicetree/board/application code can state active-high intent without failing to compile, and adds a unit test verifying it is a named-zero flag and behaves identically to the default active-high behavior.

Changes:

  • Define GPIO_ACTIVE_HIGH as a named-zero macro ((0 << 0)) alongside GPIO_ACTIVE_LOW.
  • Add a unit test that asserts GPIO_ACTIVE_HIGH == 0 and that gpio_pin_set_dt() does not invert values when using it.
  • Register the new test in the existing GPIO flags test group.

Reviewed changes

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

File Description
components/zdevice/include/boreas/gpio_dt.h Adds GPIO_ACTIVE_HIGH named-zero macro to match Zephyr dt-bindings semantics and avoid compile failures when referenced explicitly.
test/main/test_gpio_flags.c Adds a test ensuring GPIO_ACTIVE_HIGH is zero and behaves the same as default active-high DT flags.

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

@swoisz swoisz requested a review from robhelvestine June 22, 2026 17:41
@swoisz swoisz self-assigned this Jun 22, 2026
@swoisz swoisz merged commit dc06e54 into main Jun 22, 2026
6 checks passed
@swoisz swoisz deleted the fix/gpio-active-high branch June 22, 2026 18:13
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