Repository navigation
Implement SiliconTwin.Abstractions (RP2040Mcu) - #70
Merged
Merged
Conversation
RP2040Mcu implements IMcu, IGpio, IPwmSource, IAdcInput and IPeripheralMap over RP2040Machine. Run(cycleBudget) is backed by a new RP2040Machine.RunCycles that sizes instruction slices from the measured CPI. The GPIO bank resolves output state through the function mux and raises cycle-stamped PinChanged batches, armed only while subscribed. Core additions: IoBank0Peripheral.PadsChanged, GetPadOutputState, ReleaseExternalInput, SioPeripheral.ReleaseGpioExternal and UartPeripheral.TryInjectByte.
master rewrote pad evaluation while this branch was open, so the conflicts were semantic rather than textual: - IoBank0Peripheral.NotifyPads: master added EvaluatePads(mask), this branch added the PadsChanged batch event. Edge latching and peripheral inputs must run regardless of listeners, so EvaluatePads goes first and only the notification half is skipped when nobody subscribes. - IoBank0Peripheral.ReleaseExternalInput: written against a per-pin _gpioInput shadow and a LatchInputEdge helper, neither of which master has any more -- _padLevel and EvaluatePads replaced them. Re-reading the released pad through EvaluatePads(bit) latches the edge the same way. The _externalInput mask also went: master tracks only _externalHeld, with the level living in the SIO. - SioPeripheral: ReleaseGpioExternal and master's GpioMask constants are independent additions. Kept both. - CHANGELOG: both entries kept. RP2040McuContractTests.Pull_masks_follow_the_pads_registers expected every pull mask to start at 0. The spec audit fixed PADS_BANK0_GPIOn to its SVD reset value 0x56 (IE, 4 mA, PDE, Schmitt), so on real silicon every GPIO comes out of reset pulled down. Updated the expectation to the hardware's state. 670 unit + 197 integration tests green.
begeistert
marked this pull request as ready for review
October 16, 2026 04:01
Only CHANGELOG conflicted; both entries kept. 676 unit + 197 integration tests green with the SPI/DMA fix in.
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.
Implements the shared embedder contract SiliconTwin.Abstractions (silicon-twin/abstractions#1). The AVR counterpart is PyMCU/AVR8Sharp#31.
Draft until
SiliconTwin.Abstractions0.1.0 is on nuget.org. CI cannot restore until then. It was built and tested locally against the packed package.RP2040McuimplementsIMcu,IGpio(one 30-pin bank resolved through the function mux),IPwmSource,IAdcInputandIPeripheralMap(UART, SPI and I2C, including firmware as I2C slave).RP2040Machine.RunCycles(budget): slices are sized from the measured CPI. It overshoots by about one instruction and costs the same as plain instruction batches (around 450 Mcycles/s).PinChangedis batched per pad sweep and stamped with the cycle. It is armed only while subscribed.PadsChangedGetPadOutputStateReleaseExternalInputandReleaseGpioExternal, which make an externally driven pad releasableTryInjectByteCyclesfollows core 0.PinChanged; read them throughIPwmSource.Tests:
RP2040Sharp.Tests: 589 (538 before, plus 51 contract tests)