src/platforms/arm/rp/README.md
This directory contains FastLED support for Raspberry Pi's RP2xxx microcontroller family, which powers the Raspberry Pi Pico series of boards.
The RP2xxx family represents Raspberry Pi's custom silicon for embedded applications. All chips in this family share a common architecture based on Programmable I/O (PIO) state machines, which FastLED leverages for high-speed, precise LED control.
| Platform | Chip | GPIO Pins | PIO Instances | CPU | Default Clock | Status |
|---|---|---|---|---|---|---|
| RP2040 | RP2040 | 30 (0-29) | 2 (pio0, pio1) | Dual Cortex-M0+ @ 125 MHz | 125 MHz | ✅ Supported |
| RP2350 | RP2350 | 48 (0-47) | 3 (pio0, pio1, pio2) | Dual Cortex-M33 or RISC-V @ 150 MHz | 150 MHz | ✅ Supported |
rp/
├── README.md # This file - RP platform family overview
│
├── rpcommon/ # Shared code for all RP2xxx platforms
│ ├── README.md # Documentation for shared RP code
│ ├── clockless_rp_pio.h # Common PIO-based clockless LED driver
│ ├── pio_asm.h # PIO assembly instruction macros
│ ├── pio_gen.h # PIO program generator for WS2812/etc
│ ├── led_sysdefs_rp_common.h # Common system definitions
│ ├── spi_hw_2_rp.cpp # Dual-lane parallel SPI driver (2 strips)
│ ├── spi_hw_4_rp.cpp # Quad-lane parallel SPI driver (4 strips)
│ └── spi_hw_8_rp.cpp # Octal-lane parallel SPI driver (8 strips)
│
├── rp2040/ # RP2040-specific code
│ ├── README.md # RP2040 platform documentation
│ ├── fastled_arm_rp2040.h # Main platform header
│ ├── fastpin_arm_rp2040.h # Pin definitions (30 pins: 0-29)
│ ├── led_sysdefs_arm_rp2040.h # System defines (125 MHz default)
│ └── clockless_arm_rp2040.h # Clockless wrapper (includes rpcommon)
│
└── rp2350/ # RP2350-specific code
├── README.md # RP2350 platform documentation
├── fastled_arm_rp2350.h # Main platform header
├── fastpin_arm_rp2350.h # Pin definitions (48 pins: 0-47)
├── led_sysdefs_arm_rp2350.h # System defines (150 MHz default)
└── clockless_arm_rp2350.h # Clockless wrapper (includes rpcommon)
All RP2xxx platforms use Programmable I/O (PIO) state machines for clockless LED protocols (WS2812, WS2811, SK6812, etc.). This provides:
The PIO implementation is shared across all RP platforms in rpcommon/clockless_rp_pio.h.
FastLED includes specialized parallel SPI drivers that can control multiple LED strips simultaneously:
spi_hw_2_rp.cpp - 2 parallel APA102/SK9822 stripsspi_hw_4_rp.cpp - 4 parallel stripsspi_hw_8_rp.cpp - 8 parallel stripsThese drivers use PIO to generate parallel clock signals and DMA for data transfer.
All GPIO pins can be used for LED control. The RP2xxx PIO system allows any pin to be configured for input or output with hardware-timed control.
RP2040: Pins 0-29 (30 total) RP2350: Pins 0-47 (48 total on RP2350B variant)
If PIO-based drivers are disabled or unavailable, FastLED automatically falls back to the generic Cortex-M0 bit-banging implementation from platforms/arm/common/.
FastLED automatically detects the platform using these preprocessor macros:
// RP2350 detection (checked first)
#if defined(PICO_RP2350)
#include "platforms/arm/rp/rp2350/fastled_arm_rp2350.h"
// RP2040 detection
#elif defined(ARDUINO_ARCH_RP2040) || defined(PICO_RP2040)
#include "platforms/arm/rp/rp2040/fastled_arm_rp2040.h"
#endif
Platform detection is handled in src/platforms.h.
By default, FastLED uses PIO-based drivers for superior performance:
// Use PIO drivers (default, recommended)
#define FASTLED_RP2040_CLOCKLESS_PIO 1
// Force software bit-banging (slower, not recommended)
#define FASTLED_RP2040_CLOCKLESS_PIO 0
Enable the Cortex-M0 fallback driver alongside PIO:
// Enable both PIO and M0 drivers
#define FASTLED_RP2040_CLOCKLESS_M0_FALLBACK 1
Override the default CPU frequency for timing calculations:
// RP2040: Override default 125 MHz
#define F_CPU 133000000 // 133 MHz (common overclock)
// RP2350: Override default 150 MHz
#define F_CPU 200000000 // 200 MHz (overclocked)
The RP platform family uses a shared-common + platform-specific architecture:
rpcommon/)Code that works identically across all RP2xxx platforms:
NUM_PIOS to adapt to platform capabilitiesrp2040/, rp2350/)Code that varies between platforms:
NUM_PIOS (2 vs 3)This separation ensures:
If Raspberry Pi releases new RP chips (e.g., RP2040B, RP3000), follow these steps:
src/platforms/arm/rp/rp2xxx/fastpin_arm_rp2xxx.h - Define GPIO pin count and pin macrosled_sysdefs_arm_rp2xxx.h - Set F_CPU default, include rpcommon/led_sysdefs_rp_common.hclockless_arm_rp2xxx.h - Thin wrapper including rpcommon/clockless_rp_pio.hfastled_arm_rp2xxx.h - Main header aggregating the above filessrc/platforms.hThe shared code in rpcommon/ typically requires no changes.
When contributing to RP platform support:
rpcommon/ and test on both RP2040 and RP2350rp2040/ or rp2350/ directoryLast Updated: October 2024 Maintainer: FastLED Project Status: Production Ready