Refactor microcontroller wrapper utilities#512
Merged
Conversation
There was a problem hiding this comment.
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_deviceto 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
@overrideis used here butoverrideis not imported in this module, which will raise aNameErrorat import time. Addfrom typing_extensions import overridenear the top of this file (consistent with the rest of the repo).
edg/abstract_parts/IoControllerWrapper.py:254- This method takes
modelas a parameter but ignores it and instead hard-codesself.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,
deviceis a parameter but the implementation usesself.devicedirectly. 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.
|
|
||
| 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) |
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.
Refactors some of the common functionality in microcontroller dev board blocks into common shared utilities:
Other refactorings:
Resolves #505