Skip to content

feat(rp2040): phase 0 — resource contracts and mock peripherals #3653

Closed

Description

@zackees

Parent and phase

Implementation Phase 0 of #3648. This is the prerequisite for every RP2040 RX/TX driver phase.

Scope

Build one shared RP2040 resource owner for PIO instruction memory, PIO state machines, DMA channels, and claimed pins. Add injectable PIO/UART/SPI peripheral interfaces with singleton mocks, configuration/transaction history, deterministic completion, and failure injection. Use Pico SDK APIs and headers; do not add handwritten register maps.

Acceptance criteria

  • Host tests cover every resource/DREQ mapping used by later phases.
  • Success, partial initialization, exhaustion, timeout, abort, destruction, and retry leave no outstanding claims.
  • IRQ/shared state is safe on dual-core RP2040.
  • Mocks prove READY/BUSY/DRAINING/ERROR and cleanup behavior before hardware implementation.

Exit gate

Host-only evidence is sufficient for this phase. No attached-board driver claim is allowed.

Activity

  1. zackees commented on Jul 15, 2026

    @zackees
    MemberAuthor

    Implementation decision for Phase 0:

    I compared three approaches:

    1. Add one generic PIO/UART/SPI virtual peripheral interface now.
    2. Centralize only the RP resource ownership boundary and leave each protocol phase to add its own focused mock.
    3. Leave the current direct SDK claims in place and add tests around them later.

    We are taking (2). A common transaction interface would encode behavior that PIO RX, UART, and SPI do not actually share, before their drivers exist; it would make later driver tests less truthful. Phase 0 instead supplies a host-testable ownership ledger (PIO SMs, DMA channels, and pins), a Pico-SDK adapter guarded by an RP hardware spinlock, and transactional rollback in the current PIO/DMA users. Each driver phase will add an injectable peripheral mock at its real driver boundary, where configuration and transaction history have concrete semantics.

    This keeps the phase sequence intact while making the existing drivers safe to compose now.

  2. moved this from Triage to Done in FastLED Trackeron Jul 15, 2026
  3. added a commit that references this issue on Jul 15, 2026
    a878e2c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions