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(spi-bitbang): platform policies bypass hi()/lo() on FastPin subclasses that override them #5122
Raised repeatedly by CodeRabbit on the #5024 children (for example #5115, #5118, #5121). Platform BitbangPin policies detect hardware pins by base class. A downstream FastPin that derives from a hardware pin template and overrides hi()/lo(), for example to invert polarity, has those overrides skipped for data writes.
No in-repo pin does this; found by reading the code. A fix may be possible by comparing member-function pointers, which has not been tried, and should apply to all platform policies at once, ideally through a shared helper in bitbang_pin.h. Part of #5024.
Tried a shared fix. I'm not opening a PR because it breaks the host test fixtures.
What works:
A constexpr == on function addresses is rejected by avr-gcc 7.3, xtensa-lx106 10.3, and arm-none-eabi 9.2 and 11.3.
Partial specialization on function-pointer template arguments is accepted by every toolchain I tried: avr 7.3, lx106 10.3, arm 9.2/11.3/14.2/15.2, xtensa/riscv 13.2/14.2, and host gcc and clang. Pins are compared by identity: template <void(*A)(), void(*B)()> struct Same : false; template <void(*A)()> struct Same<A,A> : true;
With a helper BitbangKeepsBaseWrites<Pin, Base> in bitbang_pin.h, each isXHardwarePin can take Derived and return Keeps<Derived, Base>::value. That covers 15 ARM/AVR policies. ESP32 and ESP8266 are always true and would need their own change.
A RED test, a FastPin derived from _RP2350PIN that inverts hi()/lo(), failed on master and passed with the change.
Why it isn't a PR:bash test --cpp then fails about 10 platform tests (Teensy LC same-port streaming, among others). Their TracedClock fixtures override the clock pin's hi()/lo() to record edges, and they expect the stream path to stay enabled. A tracing override and an inverting override can't be told apart, so landing this means reworking those fixtures, for example tracing at the register level. That is a design decision for this issue.
The maintainer selected the documentation-only scope for this sweep: current limitation plus the existing explicit-policy workaround, keeping this issue open for a concrete downstream case instead of introducing native-method identity metadata across 20 platform policies.
PR #5245 documents that contract. A custom generic-writer pin can provide a full BitbangPin specialization deriving from BitbangPinDefaults with kAtomicWrite=true and kTwoWriteStream=false, visible consistently before instantiation. This is an internal generic-writer workaround, not a new public API, CPU atomicity promise, or runtime-channel/virtual-pin solution.
Automatic override detection remains unimplemented. A downstream reproducer should identify the custom pin, the selected platform policy and the affected writer path before a broader implementation is scoped. Leaving this issue OPEN; no source behavior was changed by the documentation PR.
Status from the issue sweep: this stays open on purpose, following the maintainer's scope call. #5245 (merged) documents the limitation and the workaround, a full BitbangPin specialisation that derives from BitbangPinDefaults. Please restart code work only with a downstream reproducer that names the custom pin, the platform policy selected and the affected writer path. The earlier shared-fix attempt broke about 10 host tests whose tracing fixtures also override hi()/lo(), so a fix needs a design decision first.
Activity
zackees commentedon Nov 8, 2026
Tried a shared fix. I'm not opening a PR because it breaks the host test fixtures.
What works:
==on function addresses is rejected by avr-gcc 7.3, xtensa-lx106 10.3, and arm-none-eabi 9.2 and 11.3.template <void(*A)(), void(*B)()> struct Same : false; template <void(*A)()> struct Same<A,A> : true;BitbangKeepsBaseWrites<Pin, Base>inbitbang_pin.h, eachisXHardwarePincan takeDerivedand returnKeeps<Derived, Base>::value. That covers 15 ARM/AVR policies. ESP32 and ESP8266 are alwaystrueand would need their own change._RP2350PINthat invertshi()/lo(), failed on master and passed with the change.Why it isn't a PR:
bash test --cppthen fails about 10 platform tests (Teensy LC same-port streaming, among others). TheirTracedClockfixtures override the clock pin'shi()/lo()to record edges, and they expect the stream path to stay enabled. A tracing override and an inverting override can't be told apart, so landing this means reworking those fixtures, for example tracing at the register level. That is a design decision for this issue.zackees commentedon Nov 12, 2026
The maintainer selected the documentation-only scope for this sweep: current limitation plus the existing explicit-policy workaround, keeping this issue open for a concrete downstream case instead of introducing native-method identity metadata across 20 platform policies.
PR #5245 documents that contract. A custom generic-writer pin can provide a full BitbangPin specialization deriving from BitbangPinDefaults with kAtomicWrite=true and kTwoWriteStream=false, visible consistently before instantiation. This is an internal generic-writer workaround, not a new public API, CPU atomicity promise, or runtime-channel/virtual-pin solution.
Automatic override detection remains unimplemented. A downstream reproducer should identify the custom pin, the selected platform policy and the affected writer path before a broader implementation is scoped. Leaving this issue OPEN; no source behavior was changed by the documentation PR.
docs(spi-bitbang): note Teensy 4 clock delay bypasses the policy delay()
docs(spi-bitbang): qualify per-pin clock calls for ESP32 legacy writer
zackees commentedon Nov 22, 2026
Status from the issue sweep: this stays open on purpose, following the maintainer's scope call. #5245 (merged) documents the limitation and the workaround, a full
BitbangPinspecialisation that derives fromBitbangPinDefaults. Please restart code work only with a downstream reproducer that names the custom pin, the platform policy selected and the affected writer path. The earlier shared-fix attempt broke about 10 host tests whose tracing fixtures also overridehi()/lo(), so a fix needs a design decision first.docs(spi-bitbang): clarify custom static pin policy limitation (FastL…