Skip to content

Conversation

@benpicco
Copy link
Contributor

Contribution description

The GPIO peripheral of the sam0 MCUs have a feature where they can read back the output level of a GPIO as if the GPIO was in input. (As opposed to the currently implemented mode where gpio_read() just returns the configured register value).

image

This can be useful to detect hardware defects.
The drawback is slightly higher power draw (according to the data sheet, didn't measure), so guard this behind the periph_gpio_read_output, just like periph_gpio_fast_read.

Testing procedure

The GPIO test application tests/periph/gpio has been updated to make use of the feature when available.

2025-12-16 17:22:39,054 # > init_out 1 5
2025-12-16 17:22:41,031 # > read 1 5
2025-12-16 17:22:41,033 # GPIO_PIN(1.05) is LOW

2025-12-16 17:22:43,160 # > set 1 5
2025-12-16 17:22:44,309 # > read 1 5
2025-12-16 17:22:44,311 # GPIO_PIN(1.05) is HIGH

2025-12-16 17:22:48,471 # > clear 1 5
2025-12-16 17:22:49,971 # > read 1 5
2025-12-16 17:22:49,973 # GPIO_PIN(1.05) is LOW

Issues/PRs references

@github-actions github-actions bot added Platform: ARM Platform: This PR/issue effects ARM-based platforms Area: tests Area: tests and testing framework Area: build system Area: Build system Area: cpu Area: CPU/MCU ports labels Dec 16, 2025
@benpicco benpicco requested a review from maribu December 16, 2025 16:27
@benpicco benpicco added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Dec 16, 2025
@riot-ci
Copy link

riot-ci commented Dec 16, 2025

Murdock results

✔️ PASSED

403c748 tests/periph/gpio: use periph_gpio_read_output when available

Success Failures Total Runtime
10950 0 10950 09m:13s

Artifacts

@crasbe crasbe added the Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation label Dec 16, 2025
@benpicco benpicco force-pushed the periph_gpio_read_output branch from 28b361d to 403c748 Compare December 16, 2025 17:49
@benpicco benpicco requested a review from maribu January 20, 2026 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: tests Area: tests and testing framework CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants