GPIO: don't turn off on boot#84
Open
xarantolus wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the gpio-leds pipeline (device-tree codegen → HAL registry → kernel LED driver init) so LEDs no longer get forced off during boot, and instead honor the DTS default-state property (e.g., "on").
Changes:
- Extend dtgen gpio-leds codegen to parse
default-stateand emit it inLedRegistryEntry. - Add a
LedDefaultStateenum to the generated device-tree API and the host/test stub API. - Update the kernel LED driver to set the initial output level based on
default-state(including a best-effortkeepbehavior).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| xtasks/crates/dtgen/src/codegen/led.rs | Parse default-state from DT and emit LedDefaultState + default_state in the registry entries. |
| src/drivers/led.rs | Initialize GPIO output level according to the generated default_state value and log it. |
| machine/cortex-m/src/stub/device_tree.rs | Mirror the new LedDefaultState/default_state API in the stub device tree for host/test builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+101
to
+106
| // Pre-MODER level from DT `default-state`; `Keep` is only | ||
| // meaningful on warm restart (cold reset reads 0 from analog). | ||
| let initial = match entry.default_state { | ||
| LedDefaultState::Off => level_for(entry, false), | ||
| LedDefaultState::On => level_for(entry, true), | ||
| LedDefaultState::Keep => hal::gpio::read(pin_of(entry)).unwrap_or(Level::Low), |
| pub enum LedDefaultState { | ||
| Off, | ||
| On, | ||
| /// Preserve current ODR (warm restart); cold boot reads analog → 0. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this, #82 turned off the LED on boot. Now it takes the default-state value: