Skip to content

fix(teensy4): fallback to software SPI for invalid pins (#1579) - #4087

Merged
zackees merged 1 commit into
masterfrom
fix/1579-teensy4-software-spi-fallback
Aug 31, 2026
Merged

zackees merged 1 commit into
masterfrom
fix/1579-teensy4-software-spi-fallback

Conversation

@zackees

@zackees zackees commented Aug 31, 2026 •

Copy link
Copy Markdown
Member

Summary:

  • detect valid Teensy 4.0 and 4.1 LPSPI pin routes at compile time
  • retain hardware SPI for every currently supported primary and secondary lane
  • fall back to generic software SPI for arbitrary invalid hardware pin pairs
  • add focused route-selection regression coverage

Validation:

  • focused debug/sanitizer test passed
  • Teensy 4.1 APA102 compile passed on second hardware lane 42/45
  • Teensy 4.1 APA102 compile passed on software fallback pins 1/2
  • Teensy 4.0 APA102 compile passed on second hardware lane 34/37
  • Teensy 4.0 APA102 compile passed on software fallback pins 1/2
  • comprehensive lint and diff check passed

Closes #1579

Summary by CodeRabbit

  • New Features

    • Added automatic SPI pin routing for Teensy 4 boards.
    • Supports hardware SPI on compatible pin pairs and software SPI for unsupported combinations.
    • Added support for selecting the correct SPI bus on Teensy 4.1 devices.
  • Bug Fixes

    • Corrected SPI handling for pin configurations that do not map to the default hardware bus.
  • Tests

    • Added coverage for valid hardware routes, bus selection, and fallback behavior.

@zackees
zackees merged commit 9b7f9e3 into master Aug 31, 2026
20 checks passed
@zackees
zackees deleted the fix/1579-teensy4-software-spi-fallback branch August 31, 2026 04:35
@coderabbitai

coderabbitai Bot commented Aug 31, 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 Plus

Run ID: 75d5f796-7a14-49f9-b639-6123baf17f18

📥 Commits

Reviewing files that changed from the base of the PR and between 63eb055 and 5479bac.

📒 Files selected for processing (3)
  • src/platforms/arm/teensy/teensy4_common/spi_output_selector.h
  • src/platforms/arm/teensy/teensy4_common/spi_output_template.h
  • tests/platforms/arm/teensy/teensy4_common/spi_output_selector.cpp

📝 Walkthrough

Walkthrough

Teensy 4 SPI output now maps supported pin pairs to SPI, SPI1, or SPI2 hardware buses. Other pin pairs use generic software SPI. Tests verify valid and invalid compile-time routes.

Changes

Teensy 4 SPI routing

Layer / File(s) Summary
Define and validate Teensy 4 pin routes
src/platforms/arm/teensy/teensy4_common/spi_output_selector.h, tests/platforms/arm/teensy/teensy4_common/spi_output_selector.cpp
Teensy4SpiPinRoute maps supported pin pairs to hardware buses and reports invalid pairs. Tests verify bus indices and rejected combinations.
Select hardware or software SPI
src/platforms/arm/teensy/teensy4_common/spi_output_template.h
SPIOutput uses SPIDeviceProxy for supported hardware routes and GenericSoftwareSPIOutput for other pin pairs.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ 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 fix/1579-teensy4-software-spi-fallback

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.

@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Aug 31, 2026
@fastled-project-sync fastled-project-sync Bot moved this from Triage to Done in FastLED Tracker Aug 31, 2026
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.

FastLED on Teensy 4.1 doesn't support software-emulated SPI (aka bitbanging) for APA102 chipsets

1 participant