You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(nrf52): forced software FastPin hi()/lo() are non-atomic read-modify-writes of OUT (toggle() already fixed in #5237) #5396
Split from #5070. #5149 fixed forced-pin selection on nRF52. #5237 fixed the toggle() half of the original report: on non-AVR targets it now writes the output latch, and tests/fl/system/fastpin_mapped_toggle.cpp covers it. The non-atomic hi()/lo() remain.
Defect
On nRF52 with FASTLED_FORCE_SOFTWARE_PINS (no FASTLED_NO_PINMAP), FastPin<PIN> is the runtime-port template in src/fl/system/fastpin_base.h:104-163. Its hi() and lo() (:126, :128) are *sPort |= sPinMask / *sPort &= ~sPinMask, a read-modify-write of the whole OUT register. An interrupt that changes another pin on the same port between the load and the store has its write undone. nRF52 has OUTSET/OUTCLR, as already used natively by Nrf52HwPin and by nRF51's FastPin (#5158, src/platforms/arm/nrf51/fastpin_arm_nrf51.h:49-59), so a single-store write is available.
Acceptance criteria
A host test with a modelled port, where another pin changes between the read and the write inside hi()/lo(), fails on current master (the other pin's change is lost).
After the fix, the forced nRF52 path drives single pins with single-store set/clear writes (or a platform-provided atomic equivalent), and the test passes. Behaviour on platforms without set/clear registers is unchanged.
Existing tests/fl/system/fastpin_mapped_toggle.cpp and ci/tests/test_nrf52_pin_table.py stay green, and nRF52 builds pass in normal and forced modes.
Activity
fix(nrf52): drive forced software FastPin hi()/lo()/toggle() through …