Skip to content

[stm32] Adapt enum.zig - #945

Open
JAicewizard wants to merge 2 commits into
ZigEmbeddedGroup:mainfrom
JAicewizard:adapt_common
Open

JAicewizard wants to merge 2 commits into
ZigEmbeddedGroup:mainfrom
JAicewizard:adapt_common

Conversation

@JAicewizard

Copy link
Copy Markdown
Contributor

This is currently a bit messy as it includes the changes in #939, this will be fixed once that is merged.

[The commits intended to be in] this PR remove remove the constant strings for which peripherals should be included, and change how base_perihperal_index works. This last change could technically breaking, but it was extremely unreliable as it depended on the order the peripherals were specified by embassy. I do not believe any correct usage is affected.

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.

Copilot review overview

🟡 Changes recommended

The F429 HAL has a compile-time argument mismatch, and peripheral sorting does not produce the intended numeric order.

Review effort: Balanced
Findings: 1 High severity · 2 Medium severity

Open (3)
What changed in this PR

Adapts STM32 peripheral enums and incorporates generic GPIO support from #939.

Changes:

  • Generates peripheral enums dynamically with reordered subtype indices.
  • Generalizes GPIO ports and adds STM32F429 HAL/board support.
  • Adds STM32F429 to the blinky example path.
File Description
port/​stmicro/​stm32/​src/​hals/​STM32F429.zig Adds pins, enums, and RCC support.
port/​stmicro/​stm32/​src/​hals/​STM32F303.zig Corrects the enums import path.
port/​stmicro/​stm32/​src/​hals/​STM32F103.zig Exposes common enums.
port/​stmicro/​stm32/​src/​hals/​common/​util.zig Generates and sorts peripheral enums.
port/​stmicro/​stm32/​src/​hals/​common/​pins_v2.zig Generalizes GPIO configuration across available ports.
port/​stmicro/​stm32/​src/​hals/​common/​gpio_v2.zig Removes the superseded GPIO implementation.
port/​stmicro/​stm32/​src/​hals/​common/​enums.zig Expands peripheral subtype generation and indexing.
port/​stmicro/​stm32/​src/​hals/​common/​bdma_v2.zig Applies formatting only.
port/​stmicro/​stm32/​src/​boards/​STM32F429IDISCOVERY.zig Adds HAL access and LED configuration.
port/​stmicro/​stm32/​build.zig Attaches the F429 HAL to its board target.
examples/​stmicro/​stm32/​src/​blinky.zig Adds F429 Discovery LED handling.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread port/stmicro/stm32/src/hals/STM32F429.zig Outdated
Comment thread port/stmicro/stm32/src/hals/common/enums.zig Outdated
Comment on lines +42 to +43
const ai = std.fmt.parseInt(u8, aname[an.len..aname.len], 10) catch 0;
const bi = std.fmt.parseInt(u8, bname[bn.len..bname.len], 10) catch 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is right

@mattnite

mattnite commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

@JAicewizard thank you for the wait, the other patch is merged now

@JAicewizard
JAicewizard force-pushed the adapt_common branch 2 times, most recently from 84bc419 to 06aed32 Compare October 15, 2026 11:20
This makes it so that all peripherals always get added, so this should
be good for almost any chip. Only thing that needs to be done is
potentially add more indexed peripherals.

This commit also fixes the peripheral index to work on chips where the
peripherals are not coincidentally in order.

This branch has not been deployed

No deployments
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