Skip to content

Refactor microcontroller wrappers, refactor nRF52 devices#502

Draft
ducky64 wants to merge 29 commits into
masterfrom
micro-wrapper-next
Draft

Refactor microcontroller wrappers, refactor nRF52 devices#502
ducky64 wants to merge 29 commits into
masterfrom
micro-wrapper-next

Conversation

@ducky64
Copy link
Copy Markdown
Collaborator

@ducky64 ducky64 commented May 29, 2026

Refactors the microcontroller wrapper:

  • Refactors the remapping into two steps: remapping the assign list to a pindict, then using that pindict to generate either a footprint pin mapping from IOs or as the input to another pin assign param.
  • Restrict allowed pins in the model to those supported by the wrapper
  • Refactors STM32s, LPC1549 to eliminate BaseIoControllerExportable and use explicit _wrap_inner

Note, ideally both the from and to remapping would be put in the wrapping class, however the to remapping requires the model block to be solved, which the current generator structure does not support. A future structure that enables this might be separating param-only generators from structural (circuit) generators.

Updates the RP2040 to use this new style, adding a _model param to the device to remove requirement for some ports. Migrates the nRF52 devices to use microcontroller wrappers.

Adds a unit test based on the RP2040 that tests automatic assignment, specified assignment (checking remapping), and overflow.

Also refactors the base pin map util to:

  • save the original pin name (like GPIO0) and persist it across remaps (to pin numbers)
  • always display this instead of the "resource name"
  • add filter pins util

TODOs for future PRs:

  • Support allowed_pins as an IoController construct
  • Deprecate BaseIoControllerExportable
  • Refactor other microcontrollers

TODO changes

  • propagate resource name as part of remapping
  • remapping only works at the pin level, expects two-part pin assigns? how to disambiguate user assigns?
  • consider separate get_pins or something to get leaf-level pins that are eligible for remap
  • in pinmap util, unify naming of resource vs. pinname
  • make rp2040 power pins passive, move modeling to wrapping

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.

1 participant