Skip to content

Refactor microcontroller wrapper utilities#512

Merged
ducky64 merged 16 commits into
masterfrom
mcu-wrapper-unify
Jun 2, 2026
Merged

Refactor microcontroller wrapper utilities#512
ducky64 merged 16 commits into
masterfrom
mcu-wrapper-unify

Conversation

@ducky64

@ducky64 ducky64 commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Refactors some of the common functionality in microcontroller dev board blocks into common shared utilities:

  • moves power in/out port requirements and mutual exclusivity constraints into their respective mixins
  • moves the ground and power internal node generation / port muxing into a utility function
  • ground and vusb_out unconditionally export-tapped since connected-ness does not affect modeling

Other refactorings:

  • Add concrete type annotation to dummy gnd / voltage ports

Resolves #505

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

Refactors microcontroller dev-board wrappers to centralize power/ground constraints and shared wrapping behavior in common utilities, reducing duplicated logic across board definitions and aligning netlist exports with the refactored port model (resolves #505).

Changes:

  • Moves power/ground mutual-exclusion + “gnd required when power used” constraints into IoController / interface mixins, and adds shared helpers for generating internal dummy GND/PWR nodes.
  • Introduces _wrap_inner_model_device to unify model/device pin-assign wrapping + IO export/export_tap, and updates multiple dev-board wrappers to use it.
  • Updates example netlists and adds a regression test to ensure an unpowered dev-board wrapper still compiles; adds concrete type annotations to dummy GND/voltage ports.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
examples/TestBlinkyBasic/TestBlinkyBasic.svgpcb.js Updates exported net name to match new vusb_out naming.
examples/TestBlinkyBasic/TestBlinkyBasic.net.ref Updates reference netlist to match renamed USB/VBUS net.
examples/BasicKeyboard/BasicKeyboard.svgpcb.js Updates exported power/ground net names to match refactored wrapper exports.
examples/BasicKeyboard/BasicKeyboard.net.ref Updates reference netlist for renamed GND / VUSB nets.
edg/parts/microcontroller/test_mcu_wrapper.py Adds compilation test for a wrapper with no power/ground connections.
edg/parts/microcontroller/Stm32f303.py Removes wrapper-local power constraints now enforced by mixins.
edg/parts/microcontroller/Rp2040.py Refactors Xiao RP2040 wrapper to use shared wrap + node-generation helpers.
edg/parts/microcontroller/nRF52840.py Refactors Feather nRF52840 wrapper to shared wrap + node-generation helpers; moves constraints to mixins.
edg/parts/microcontroller/Esp32s3.py Refactors Freenove ESP32S3 wrapper to shared wrap + node-generation helpers.
edg/parts/microcontroller/Esp32c3.py Refactors ESP32C3 wrapper(s) to shared wrap + node-generation helpers.
edg/parts/microcontroller/Esp32.py Refactors Freenove ESP32 wrapper to shared wrap + node-generation helpers (but currently has a VUSB tap bug).
edg/electronics_interfaces/VoltageDummy.py Adds concrete typing for dummy voltage ports.
edg/electronics_interfaces/GroundDummy.py Adds concrete typing for dummy ground port.
edg/abstract_parts/IoControllerWrapper.py Adds _wrap_inner_model_device helper (but currently missing an override import and ignores its parameters).
edg/abstract_parts/IoControllerInterfaceMixins.py Adds shared power/ground constraints to mixins + helper node-generation utilities.
edg/abstract_parts/IoController.py Adds base constraint pwr -> gnd to allow unpowered IO-only usage while validating powered usage.
edg/abstract_parts/init.py Updates exports to reflect wrapper class relocation/import path.
Comments suppressed due to low confidence (3)

edg/abstract_parts/IoControllerWrapper.py:236

  • @override is used here but override is not imported in this module, which will raise a NameError at import time. Add from typing_extensions import override near the top of this file (consistent with the rest of the repo).
    edg/abstract_parts/IoControllerWrapper.py:254
  • This method takes model as a parameter but ignores it and instead hard-codes self.model. This makes the helper brittle (and contradicts the signature/docstring) if the caller ever passes a different instance or refactors attribute names.
    edg/abstract_parts/IoControllerWrapper.py:258
  • Similarly, device is a parameter but the implementation uses self.device directly. Using the parameter keeps this helper reusable and avoids accidental coupling to wrapper attribute names.

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

Comment thread edg/parts/microcontroller/Esp32.py Outdated

if self.get(self.vusb_out.is_connected()):
self.export_tap(self.vusb_out.net, self.device.vcc)
self.export_tap(self.vusb_out.net, self.device.vusb)

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

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

@ducky64 ducky64 merged commit 938283d into master Jun 2, 2026
12 checks passed
@ducky64 ducky64 deleted the mcu-wrapper-unify branch June 2, 2026 07:34
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.

Clean up export_tap-based microcontroller dev boards

2 participants