Skip to content

feat(rp2040): add PIO FLEX_IO SPI fallback - #3709

Merged
zackees merged 1 commit into
masterfrom
feat/rp2040-flex-io-spi
Jul 16, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/rp2040-flex-io-spi

Conversation

@zackees

@zackees zackees commented Jul 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • make the RP2040 PIO engine a unified FLEX_IO driver for clockless and mode-0 SPI output
  • route arbitrary MOSI/SCK pairs through PIO + DMA while retaining native SPI0/SPI1 on canonical pin pairs
  • add host lifecycle coverage for PIO SPI packing and native-SPI preference

Validation

  • �ash test tests/platforms/arm/rp/rpcommon/channel_engine_rp_pio
  • build build -e rp2040 -v (Blink)

Note

  • targeted �ash lint --cpp is blocked locally because the Rust C++ linter cannot build without the x86_64-pc-windows-msvc Rust target.

Summary by CodeRabbit

  • New Features
    • Added SPI transmission support to FLEX_IO on RP2040 and RP2350 devices.
    • FLEX_IO can now use arbitrary valid MOSI and SCK pin pairs when native SPI routing is unavailable.
    • Added DMA-backed SPI transfers with improved transmission lifecycle handling.
  • Bug Fixes
    • Improved resource allocation and rollback when PIO, DMA, or GPIO resources cannot be acquired.
  • Tests
    • Added coverage for SPI transfers, DMA output, and pin-routing capability checks.

@coderabbitai

coderabbitai Bot commented Jul 16, 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: 8f5a399d-4f06-446d-a5ea-c77db3990a98

📥 Commits

Reviewing files that changed from the base of the PR and between 906f22b and a2f4b39.

📒 Files selected for processing (9)
  • src/platforms/arm/rp/rpcommon/_build.cpp.hpp
  • src/platforms/arm/rp/rpcommon/channel_engine_rp_pio.cpp.hpp
  • src/platforms/arm/rp/rpcommon/channel_engine_rp_pio.h
  • src/platforms/arm/rp/rpcommon/irp_pio_spi_peripheral.h
  • src/platforms/arm/rp/rpcommon/rp_pio_dma_resource_manager.h
  • src/platforms/arm/rp/rpcommon/rp_pio_spi_peripheral.cpp.hpp
  • src/platforms/arm/rp/rpcommon/rp_pio_spi_peripheral.h
  • src/platforms/arm/rp/rpcommon/rp_pio_tx_bus_traits.h
  • tests/platforms/arm/rp/rpcommon/channel_engine_rp_pio.cpp

📝 Walkthrough

Walkthrough

Adds RP FLEX_IO SPI transmission using a new PIO/DMA peripheral, shared resource claiming, dual-mode channel-engine handling, bus integration, and host tests for DMA words, lifecycle, and pin selection.

Changes

RP FLEX_IO SPI support

Layer / File(s) Summary
SPI contract and resource acquisition
src/platforms/arm/rp/rpcommon/irp_pio_spi_peripheral.h, src/platforms/arm/rp/rpcommon/rp_pio_dma_resource_manager.h
Defines the SPI peripheral interface and adds atomic claiming of PIO, two GPIO pins, and DMA resources with rollback.
PIO SPI peripheral implementation
src/platforms/arm/rp/rpcommon/rp_pio_spi_peripheral.*
Implements mode-0 PIO setup, DMA transmission, completion detection, abort, and deinitialization.
Channel engine SPI mode
src/platforms/arm/rp/rpcommon/channel_engine_rp_pio.*
Extends FLEX_IO with SPI capability checks, DMA word conversion, SPI polling, and separate clockless/SPI lifecycle handling.
FLEX_IO wiring and validation
src/platforms/arm/rp/rpcommon/rp_pio_tx_bus_traits.h, src/platforms/arm/rp/rpcommon/_build.cpp.hpp, tests/platforms/arm/rp/rpcommon/channel_engine_rp_pio.cpp
Wires the SPI peripheral into the bus, advertises SPI support, includes the implementation, and adds SPI mock coverage. Estimated code review effort: 3 (Moderate)

Possibly related issues

Possibly related PRs

  • FastLED/FastLED#3662 — Provides the centralized PIO/DMA resource ownership that this SPI path extends.
  • FastLED/FastLED#3666 — Introduces the ChannelEngineRpPio implementation extended here with SPI mode.
✨ 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-flex-io-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.

@zackees
zackees merged commit 3940ab1 into master Jul 16, 2026
6 of 9 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jul 16, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Jul 16, 2026
@zackees
zackees deleted the feat/rp2040-flex-io-spi branch August 21, 2026 19:15
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