Skip to content

feat(rp2040): add fixed SPI0/SPI1 DMA channel drivers - #3668

Merged
zackees merged 1 commit into
masterfrom
feat/rp2040-phase6-fixed-spi
Jul 15, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/rp2040-phase6-fixed-spi

Conversation

@zackees

@zackees zackees commented Jul 15, 2026 •

Copy link
Copy Markdown
Member

Implements Phase 6 software scope for #3659 / #3648.\n\n- Adds separate fixed-function PL022 SPI0/SPI1 IChannelDriver lanes with canonical RP2040 mux triples.\n- Uses Pico SDK mode-0, MSB-first SPI with paired TX and RX-drain DMA, ownership rollback, timeout/error cleanup, and spi_is_busy() wire-idle gating.\n- Makes RP true-SPI the default SpiChipsetConfig bus while retaining the PIO parallel-SPI adapter separately.\n\nValidated locally:\n- �ash test channel_engine_rp_spi --debug\n- �ash test channel_engine_rp_spi --cpp\n- �ash test rp_resource_ledger --cpp\n- uv run --no-sync python ci/lint_cpp/run_all_checkers.py --no-rust\n\nThe attached-board SPI0/SPI1 MOSI-to-MISO loopback acceptance remains tracked by #3659 and hardware gate #3631; the Pico headers are not installed.\n\nCloses #3659

Summary by CodeRabbit

  • New Features

    • Added native SPI bus support for RP2040 and RP2350 boards, including both SPI0 and SPI1.
    • Enabled DMA-driven SPI channel transmissions with validated pin mappings and configurable clock limits.
    • Added reliable handling for queued transfers, completion states, errors, timeouts, and resource cleanup.
  • Bug Fixes

    • Improved SPI resource allocation and rollback when setup fails.
  • Tests

    • Added coverage for SPI transfers, pin validation, clock limiting, failures, timeouts, and resource ownership.

@zackees
zackees merged commit 0c64dc4 into master Jul 15, 2026
8 of 11 checks passed
@zackees
zackees deleted the feat/rp2040-phase6-fixed-spi branch July 15, 2026 13:00
@coderabbitai

coderabbitai Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 76e33139-4dc9-4eef-ba28-1b8bd69a3693

📥 Commits

Reviewing files that changed from the base of the PR and between ec99646 and f4eadc6.

📒 Files selected for processing (13)
  • src/fl/channels/bus.h
  • src/platforms/arm/rp/rpcommon/_build.cpp.hpp
  • src/platforms/arm/rp/rpcommon/channel_engine_rp_spi.cpp.hpp
  • src/platforms/arm/rp/rpcommon/channel_engine_rp_spi.h
  • src/platforms/arm/rp/rpcommon/init_channel_driver_rp.cpp.hpp
  • src/platforms/arm/rp/rpcommon/irp_spi_peripheral.h
  • src/platforms/arm/rp/rpcommon/rp_pio_dma_resource_manager.h
  • src/platforms/arm/rp/rpcommon/rp_resource_ledger.h
  • src/platforms/arm/rp/rpcommon/rp_spi_bus_traits.h
  • src/platforms/arm/rp/rpcommon/rp_spi_peripheral.cpp.hpp
  • src/platforms/arm/rp/rpcommon/rp_spi_peripheral.h
  • tests/platforms/arm/rp/rpcommon/channel_engine_rp_spi.cpp
  • tests/platforms/arm/rp/rpcommon/rp_resource_ledger.cpp

📝 Walkthrough

Walkthrough

RP2040/RP2350 builds now expose SPI0 and SPI1 channel drivers with validated pin mappings, DMA-backed transmission, resource ownership, lifecycle handling, bus registration, and host coverage for completion, clock clamping, errors, and timeouts.

Changes

RP SPI channel driver

Layer / File(s) Summary
SPI bus mapping and registration
src/fl/channels/bus.h, src/platforms/arm/rp/rpcommon/rp_spi_bus_traits.h, src/platforms/arm/rp/rpcommon/init_channel_driver_rp.cpp.hpp
RP platforms map SPI chipsets to Bus::SPI, expose two instances, define SPI0/SPI1 traits, and register both drivers with ChannelManager.
SPI resource ownership and rollback
src/platforms/arm/rp/rpcommon/rp_resource_ledger.h, src/platforms/arm/rp/rpcommon/rp_pio_dma_resource_manager.h, tests/platforms/arm/rp/rpcommon/rp_resource_ledger.cpp
SPI ownership tracking and atomic SPI/DMA/pin acquisition now include deterministic rollback and release validation.
SPI peripheral and DMA implementation
src/platforms/arm/rp/rpcommon/irp_spi_peripheral.h, src/platforms/arm/rp/rpcommon/rp_spi_peripheral.h, src/platforms/arm/rp/rpcommon/rp_spi_peripheral.cpp.hpp
The RP SPI peripheral validates configuration, claims hardware resources, performs RX/TX DMA transfers, reports status, and cleans up resources.
Queued channel execution and validation
src/platforms/arm/rp/rpcommon/channel_engine_rp_spi.h, src/platforms/arm/rp/rpcommon/channel_engine_rp_spi.cpp.hpp, src/platforms/arm/rp/rpcommon/_build.cpp.hpp, tests/platforms/arm/rp/rpcommon/channel_engine_rp_spi.cpp
ChannelEngineRpSpi sequences queued transmissions, handles busy/draining/ready/error states, and is included in RP builds with tests for pin selection, clock clamping, completion, failures, and timeouts.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related issues

  • FastLED/FastLED 3659: Covers the fixed-function RP2040/RP2350 SPI0/SPI1 channel-driver functionality implemented here.
  • FastLED/FastLED 3647: Covers the RP SPI TX driver, bus traits, DMA transmission, and resource lifecycle implemented here.
  • FastLED/FastLED 3439: Covers related bus instance counting, default bus resolution, and bus-based driver selection.

Possibly related PRs

  • FastLED/FastLED#3662: Adds directly related SPI ownership and bus-resource wiring in the RP resource ledger and DMA manager.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/rp2040-phase6-fixed-spi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant