Skip to content

feat(nrf52): add FASTLED_NRF52_ALLOW_NFC_PINS / _USR_LED opt-ins (#2446) - #2447

Merged
zackees merged 1 commit into
masterfrom
feat/nrf52-pin-optins-2446
May 10, 2026
Merged

zackees merged 1 commit into
masterfrom
feat/nrf52-pin-optins-2446

Conversation

@zackees

@zackees zackees commented May 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Resolves #2446 by introducing two compile-time switches that re-enable pins which are by default declared _FL_DEF_INVALID_PIN on the SuperMini, nice!nano v2, nRFMicro, XIAO nRF52840, and XIAO nRF52840 Sense variant blocks in src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h.

  • FASTLED_NRF52_ALLOW_NFC_PINS: P0.09 / P0.10 (NFC1/NFC2) become valid FastLED output pins on every nRF52840 variant block in this file. The macro is necessary but not sufficient — users also need CONFIG_NFCT_PINS_AS_GPIOS=1 in the BSP/build flags, or a call to the Adafruit nRF52 core's NFC_PINS_AS_GPIO() at boot, for the pins to actually drive a strip.
  • FASTLED_NRF52_ALLOW_USR_LED: on-board user-LED pins become valid FastLED output pins (P0.15 SuperMini/nice!nano v2, P1.10 nRFMicro, and the three XIAO RGB LEDs at P0.26 / P0.06 / P0.30).

EXT_VCC enable pins (P0.13 SuperMini/nice!nano v2, P1.09 nRFMicro), VBAT-sense pins (P0.04 nRFMicro, P0.14/P0.31 XIAO), HICHG, ~CHG, and QSPI flash pins remain invalid unconditionally per the decision matrix in #2446 — toggling EXT_VCC mid-show() browns out the regulator, and the others are not safe for FastLED output.

Implementation

  • Two new helper macros _FL_DEFPIN_NFC and _FL_DEFPIN_USR_LED expand to either _FL_DEFPIN or _FL_DEF_INVALID_PIN based on whether the user defined the corresponding FASTLED_NRF52_ALLOW_* switch.
  • Each affected line in the five variant blocks swaps _FL_DEF_INVALID_PIN for the appropriate helper. No other lines are touched (EXT_VCC, VBAT, HICHG, ~CHG, QSPI all stay invalid).
  • src/platforms/arm/nrf52/README.md documents both new macros and reiterates the BSP-side requirement for the NFC opt-in.

Default behaviour

Unchanged. Without either macro defined, exactly the same set of pins remains invalid as before this PR. The opt-ins are strictly additive.

Test plan

  • bash lint --cpp passes
  • bash test --cpp passes (302/302)
  • Manual verification on hardware (XIAO nRF52840 / SuperMini / nice!nano v2 / nRFMicro) once a community user with the relevant board exercises the new macros — covered separately by the open issue follow-up

Closes #2446

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Summary by CodeRabbit

  • New Features

    • Added optional support for NFC pins as FastLED output pins (requires build configuration)
    • Added optional support for onboard LED pins as FastLED output pins
  • Documentation

    • Updated nRF52 documentation with configuration guidance and warnings about potential pin conflicts with other library or sketch usage

Review Change Stack

Resolves #2446 by introducing two compile-time switches that re-enable
pins which are by default declared _FL_DEF_INVALID_PIN on the SuperMini,
nice!nano v2, nRFMicro, XIAO nRF52840, and XIAO nRF52840 Sense variant
blocks in src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h.

- FASTLED_NRF52_ALLOW_NFC_PINS: P0.09 / P0.10 (NFC1/NFC2) become valid
  output pins. The macro is necessary but not sufficient -- users also
  need CONFIG_NFCT_PINS_AS_GPIOS=1 in the BSP, or to call the Adafruit
  nRF52 core's NFC_PINS_AS_GPIO() at boot, for the pins to actually
  drive a strip.
- FASTLED_NRF52_ALLOW_USR_LED: on-board user-LED pins become valid
  output pins (P0.15 SuperMini/nice!nano v2, P1.10 nRFMicro, and the
  three XIAO RGB LEDs at P0.26 / P0.06 / P0.30).

EXT_VCC enable pins (P0.13 SuperMini/nice!nano v2, P1.09 nRFMicro),
VBAT-sense pins (P0.04 nRFMicro, P0.14/P0.31 XIAO), HICHG / ~CHG, and
QSPI flash pins remain invalid unconditionally per the decision matrix
in #2446.

Implementation:
- Two new helper macros _FL_DEFPIN_NFC and _FL_DEFPIN_USR_LED expand to
  either _FL_DEFPIN or _FL_DEF_INVALID_PIN based on whether the user
  defined the corresponding FASTLED_NRF52_ALLOW_* switch.
- Each affected line in the five variant blocks swaps
  _FL_DEF_INVALID_PIN for the appropriate helper. No other lines are
  touched (EXT_VCC, VBAT, HICHG, ~CHG, QSPI stay invalid).
- README.md in src/platforms/arm/nrf52/ documents both new macros.

The default behaviour is unchanged: without the macros defined, the
same set of pins remains invalid as before this commit.

Closes #2446

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 10, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR introduces two conditional pin-validity macros for nRF52840 boards: _FL_DEFPIN_NFC and _FL_DEFPIN_USR_LED. These allow users to opt-in to treating NFC and onboard LED pins as valid FastLED outputs via compile-time flags, then applies the macros consistently across XIAO, SuperMini, nice!nano, and nRFMicro variants.

Changes

nRF52 Conditional Pin Enablement

Layer / File(s) Summary
Conditional Pin Macros
src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h
Defines _FL_DEFPIN_NFC(ARDUINO_PIN, BOARD_PIN, BOARD_PORT) and _FL_DEFPIN_USR_LED(ARDUINO_PIN, BOARD_PIN, BOARD_PORT) macros that expand to valid pin definitions when compile-time flags are defined, otherwise to _FL_DEF_INVALID_PIN.
Platform Documentation
src/platforms/arm/nrf52/README.md
Documents FASTLED_NRF52_ALLOW_NFC_PINS requirement for CONFIG_NFCT_PINS_AS_GPIOS BSP configuration, warns about LED_BUILTIN conflicts with FASTLED_NRF52_ALLOW_USR_LED, and clarifies that EXT_VCC, VBAT-sense, and QSPI pins remain unconditionally invalid.
XIAO Board Variants
src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h
Updates XIAO nRF52840 and XIAO nRF52840 Sense pin definitions: NFC pins (D30/D31, P0.09/P0.10) now use _FL_DEFPIN_NFC; onboard LED pins (D11–D13) now use _FL_DEFPIN_USR_LED.
Community Board Variants
src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h
Updates SuperMini nRF52840, nice!nano v2, and nRFMicro: NFC pins (D10–D11 or D7–D8, P0.09/P0.10) now use _FL_DEFPIN_NFC; onboard LED pins (D22 or D27) now use _FL_DEFPIN_USR_LED.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • Directly implements the proposal from #2446 to introduce FASTLED_NRF52_ALLOW_NFC_PINS and FASTLED_NRF52_ALLOW_USR_LED opt-in macros for conditional NFC and user LED pin validity across SuperMini, nice!nano, nRFMicro, and XIAO variants.

Possibly related PRs

  • FastLED/FastLED#2445: Adds initial SuperMini, nice!nano v2, and nRFMicro board targets with NFC and onboard pins marked as _FL_DEF_INVALID_PIN; this PR converts those pins to conditional validity.

Poem

🐰 A hop through pins both NFC and LED,
Where users choose which lights are fed!
Conditional macros, compile-time bright,
FastLED options burning just right! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the primary change: adding two compile-time opt-in macros (FASTLED_NRF52_ALLOW_NFC_PINS and FASTLED_NRF52_ALLOW_USR_LED) for nrf52 platforms.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #2446: introduces the two requested opt-in macros (_FL_DEFPIN_NFC and _FL_DEFPIN_USR_LED), applies them uniformly across SuperMini, nice!nano v2, nRFMicro, and XIAO variants, keeps restricted pins invalid, and documents constraints in README.
Out of Scope Changes check ✅ Passed All changes are directly scoped to implementing the opt-in pin macros for nRF52 platforms per issue #2446; no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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/nrf52-pin-optins-2446

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h`:
- Around line 67-69: The comment claiming the NFC pins apply to “every nRF52840
variant in this file” is inaccurate because only the variant blocks guarded by
the build-time switch _FL_DEFPIN_NFC expose P0.09/P0.10 (NFC1/NFC2) as FastLED
pins; update the wording in the comment to explicitly state that P0.09/P0.10
become valid FastLED pins only for the variants controlled by the _FL_DEFPIN_NFC
switch (or similar phrasing naming the macro) so the text matches the
implementation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fa990dc4-716e-4b07-ab8c-6f588fa4a8b8

📥 Commits

Reviewing files that changed from the base of the PR and between 135ec0d and 4d6c11c.

📒 Files selected for processing (2)
  • src/platforms/arm/nrf52/README.md
  • src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h

Comment on lines +67 to +69
// When defined by the user, P0.09 / P0.10 (NFC1 / NFC2) become valid
// FastLED output pins on every nRF52840 variant in this file. The pins
// are gated behind a build-time switch because the Adafruit nRF52 core

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

NFC scope wording is broader than implementation

Line 68 says this applies on “every nRF52840 variant in this file,” but only selected variant blocks were switched to _FL_DEFPIN_NFC. Tightening this wording avoids misleading users about board coverage.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/platforms/arm/nrf52/fastpin_arm_nrf52_variants.h` around lines 67 - 69,
The comment claiming the NFC pins apply to “every nRF52840 variant in this file”
is inaccurate because only the variant blocks guarded by the build-time switch
_FL_DEFPIN_NFC expose P0.09/P0.10 (NFC1/NFC2) as FastLED pins; update the
wording in the comment to explicitly state that P0.09/P0.10 become valid FastLED
pins only for the variants controlled by the _FL_DEFPIN_NFC switch (or similar
phrasing naming the macro) so the text matches the implementation.

@zackees
zackees merged commit 95c4350 into master May 10, 2026
6 of 8 checks passed
@zackees
zackees deleted the feat/nrf52-pin-optins-2446 branch May 10, 2026 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Follow-up: revisit invalidated pins on SuperMini / nice!nano / nRFMicro nRF52840 variants

1 participant