Repository navigation
fix(rx): #3416 burndown -- PAD_CTL keeper+HYS, dma_done branch widening - #3419
Conversation
Two RX-side hardening fixes from the #3416 audit: 1. RX-HIGH-3 / RX-LOW-8: configure SW_PAD_CTL with HYS=1, PKE=1, PUE=1, PUS=100K pull-up. The pad register lives at a fixed +0x1F0 offset from MUX_CTL for every IOMUXC pad on the i.MX RT1062, so we can compute it from the per-pin mux_register pointer without adding a per-pin field. Matches the working FlexIO1 RX pad init in rx_flexio_channel.cpp.hpp:391-395. Hysteresis is the actual noise-floor lever; pull-up biases the line during HIGH-Z transients. 2. RX-CRIT-2: widen the dma_done branch in buildEdgeTimesFromCaptures() to treat ANY ISR-confirmed completion as a full buffer, not only the post-CITER-reload case. The previous "dma_done && biter == citer" guard fell through to the residual-count branch when DREQ-halt at major-loop end left CITER==0 transiently, silently reporting captures_written=0 and producing the mid-frame "H214753" dropout symptom. Measured noise floor on bench loopback after both fixes: 0.8-1.1% (unchanged from baseline -- the residual is scattered single-bit errors at random LED positions, consistent with wire signal integrity at the test rig itself, not driver bugs).
Pull-up biases the line HIGH between frames and competes with the TX side's LOW drive, leaking HIGH between WS2812 frames (the same class of symptom that motivated the FlexIO TX park-pin-LOW workaround). Keeper mode (PUE=0) just holds whatever the TX last drove -- LOW after a clean frame end -- without biasing the rail. Empirically ObjectFLED accuracy improved from 0.7% to 0.3-0.6% on the same loopback rig; FlexIO held at ~1.0%.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughTeensy 4 capture handling, FlexIO DMA runtime behavior, ObjectFLED DMA sequencing, and WS2812 edge decoding are updated. The changes also add related documentation, logging, and compile-time guardrails. ChangesTeensy WS2812 capture and DMA hardening
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/teensy/teensy4_common/rx_flexpwm_channel.cpp.hpp`:
- Around line 457-465: Replace the hand-derived SW_PAD_CTL address computation
in rx_flexpwm_channel.cpp.hpp around the pad_register setup with the project’s
approved offset-based or explicit IOMUXC register symbol approach, following the
pattern used in flexio_driver.cpp.hpp instead of adding 0x1F0 to mux_register.
Keep the keeper configuration logic in the same code path, but update the nearby
comments to describe KEEPER mode accurately so the documentation matches the
actual PUE=0 settings and the intended WS2812 behavior.
🪄 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: 1ef0f337-ede4-4b87-9ef3-119b12ed4bb4
📒 Files selected for processing (1)
src/platforms/arm/teensy/teensy4_common/rx_flexpwm_channel.cpp.hpp
…esults Add inline comments documenting which #3416 audit recommendations were attempted and rejected after empirical testing, so future contributors don't re-attempt: - RX-HIGH-1 (CFAWM>=1): regressed 0.8% -> 94% on FlexPWM RX. The FIFO buffers per-edge-type not per-pair, so CFAWM=1 waits for two rising edges before firing DMA -- wrong for our dual-circuit design. - OF-CRIT-1 (drop DMA_TCD_CSR_DONE from initial CSR): hangs first show() after begin(). The DONE bit lets waitForCompletion() short-circuit before any transfer runs; removing it makes the spin loop wait forever for completion that never starts. Several other audit items were attempted on the working branch and rolled back without making it into git (RX-HIGH-2 pair validation, FX-HIGH-1 trailing zero guard word, decoder tolerance widening, keeper-vs-pullup variants, longer GPIO park delay). See PR #3419 description for the full list. No behavior change in this commit.
Defensive correctness + code-quality fixes from the #3416 audit. Verified on bench loopback: FlexIO 0.8-1.1%, ObjectFLED 0.3-0.8% -- no measurable regression, no measurable improvement (residuals are RX-side wire noise, not driver bugs). FlexIO driver: - FX-LOW-1: removed duplicate DADDR write in flexio_show - FX-LOW-3: removed duplicate fl/log/log.h includes (driver+channel_engine) - FX-LOW-2: refreshed flexio_driver.h docstring to describe current 1-shifter/1-timer architecture, noting the t0h/t1h/period_ns params are currently ignored (FX-MED-1) - FX-HIGH-2: mask PINSEL field to 5 bits to prevent silent overflow into PINPOL if a future FlexIO3 pin entry is copy-pasted - FX-HIGH-6: asm("dsb") in flexio_dma_isr after clearInterrupt() so the DMA_CINT write commits before the ISR returns; matches Teensyduino FlexSerial pattern - FX-MED-2: FL_LOG_FLEXIO_F when strip length exceeds buffer cap (~341 RGB LEDs) instead of silent truncation - FX-MED-3: dsb + read-back barrier between CCM_CS1CDR write and CCM_CCGR3 gate-on so the divider commits before clocking starts - FX-MED-4: flexio_wait() now force-disables the channel + clears sDmaComplete on timeout instead of leaving the next show() in a perpetual-timeout state ObjectFLED: - OF-CRIT-2: detachInterrupt() before re-attaching in begin() so a re-init after pin change doesn't leave the prior vector slot wired to a stale channel - OF-HIGH-2: drop the dual-write CSR=0;CSR=ESG|INTMAJOR pattern that briefly armed dma2 without ESG between the two writes - OF-HIGH-3: static_assert BYTES_PER_DMA >= 90 so a user override below the safe ISR-refill margin fails at compile time Shared decoder: - RX-HIGH-5: also break on long HIGH (>= reset_min_us) so a stuck-HIGH between frames doesn't misclassify a stray falling edge as the start of a phantom bit cell Misc: - RX-LOW-1: deleted orphan flexpwm_rx_channel.h (the actual class declaration lives in rx_flexpwm_channel.h; the duplicate was missing diagnosticsToJson() and not included anywhere)
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp (1)
547-565: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winClear the pending DMA interrupt during timeout recovery.
The timeout path clears complete/error state but not the interrupt latch, while the normal quiesce/deinit paths do. Clearing it here makes public
wait()recovery leave the DMA channel in the same clean state.Proposed timeout recovery tightening
if (sDmaChannel) { sDmaChannel->disable(); sDmaChannel->clearComplete(); + sDmaChannel->clearInterrupt(); sDmaChannel->clearError(); }🤖 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/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp` around lines 547 - 565, The timeout recovery path in flexio_wait() clears complete/error state but leaves the pending DMA interrupt latched, unlike the normal quiesce/deinit cleanup. Update the timeout branch to also clear the interrupt on sDmaChannel before marking sDmaComplete true, so wait() recovery leaves the DMA channel in the same clean state as the existing shutdown paths.
🤖 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/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp`:
- Around line 471-475: The FlexIO truncation warning in the FLEXIO driver is
using printf-style formatting with integer arguments but `%s` placeholders,
which is incorrect. Update the `FL_LOG_FLEXIO_F` call in `flexio_driver.cpp.hpp`
to use the proper integer format specifiers for `num_bytes` and
`kMaxInputBytes`, or switch the `FL_WARN`/`log_emit_f` usage to stream-style
formatting so the values are logged safely.
In `@src/third_party/object_fled/src/ObjectFLEDDmaManager.h`:
- Around line 30-38: The `BYTES_PER_DMA` macro is being defined in both
`ObjectFLED.h` and `ObjectFLEDDmaManager.h`, which makes its value depend on
include order and can lead to inconsistent `bitdata` sizing across translation
units. Centralize the default definition in one place (preferably the shared
configuration in `ObjectFLED.h` or a dedicated config header) and remove the
redundant `#ifndef` default from `ObjectFLEDDmaManager.h`, keeping only the
safety `static_assert` there. Ensure every user of `BYTES_PER_DMA`, including
`ObjectFLEDDmaManager.cpp.hpp` and `ObjectFLEDDmaManager.h`, sees the same
single source of truth.
---
Nitpick comments:
In
`@src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp`:
- Around line 547-565: The timeout recovery path in flexio_wait() clears
complete/error state but leaves the pending DMA interrupt latched, unlike the
normal quiesce/deinit cleanup. Update the timeout branch to also clear the
interrupt on sDmaChannel before marking sDmaComplete true, so wait() recovery
leaves the DMA channel in the same clean state as the existing shutdown paths.
🪄 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: 91139dc0-57bb-454b-b055-965e8a5b2fbf
📒 Files selected for processing (7)
src/fl/channels/rx/decode_ws2812.cpp.hppsrc/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp.hppsrc/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hppsrc/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.hsrc/platforms/arm/teensy/teensy4_common/flexpwm_rx_channel.hsrc/third_party/object_fled/src/ObjectFLEDDmaManager.hsrc/third_party/object_fled/src/OjectFLED.cpp.hpp
💤 Files with no reviewable changes (2)
- src/platforms/arm/teensy/teensy4_common/drivers/flexio/channel_engine_flexio.cpp.hpp
- src/platforms/arm/teensy/teensy4_common/flexpwm_rx_channel.h
✅ Files skipped from review due to trivial changes (2)
- src/fl/channels/rx/decode_ws2812.cpp.hpp
- src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.h
- OF-LOW-2: warn when numPins exceeds NUM_DIGITAL_PINS instead of silent truncation - OF-LOW-8: warn when numLEDs is not divisible by numpins - RX-LOW-3: document the 16-bit timestamp wrap invariant. Can't static_assert since F_BUS_ACTUAL is not constexpr on Teensyduino, but the comment lays out the safety condition for any future bus clock change. - RX-MED-2: comment the SION OR-write intent (=, not |=, is intentional; we want a known starting alt-mode + SION + pad-config baseline) - FX-LOW-4: atomic snapshot in flexio_read_diagnostics so the ISR can't run mid-read and produce inconsistent state in the JSON-RPC diagnostic dump - Build fix: revert static_assert in tickDeltaNs to runtime-safe comment after compile failure (F_BUS_ACTUAL non-constexpr)
There was a problem hiding this comment.
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/third_party/object_fled/src/OjectFLED.cpp.hpp`:
- Around line 95-99: The initialization in OjectFLED::setup (where numpinsLocal
is assigned from numPins) computes stripLen before checking for zero, so a zero
pin count can still divide by zero. Move the numPins guard ahead of any division
and only assign stripLen when numpinsLocal is greater than zero; keep the
existing uneven-division warning logic in the same setup path after the zero
check.
🪄 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: defaults
Review profile: CHILL
Plan: Pro
Run ID: 61a07181-a10e-42dd-9d9f-eef0beb764ef
📒 Files selected for processing (3)
src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hppsrc/platforms/arm/teensy/teensy4_common/rx_flexpwm_channel.cpp.hppsrc/third_party/object_fled/src/OjectFLED.cpp.hpp
🚧 Files skipped from review as they are similar to previous changes (2)
- src/platforms/arm/teensy/teensy4_common/rx_flexpwm_channel.cpp.hpp
- src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp
- FX-CRIT-1: compile-time enforcement that kFlexIOPins only targets FlexIO2 pads (flexio_pin <= 17). Catches future copy-paste from a FlexIO3 reference at build time instead of producing garbled output. - FX-HIGH-3: document DMAMUX source 1 shared between Shifter 0 SSF and Shifter 1 SSF so a future parallel-LED extension doesn't silently over-fire DMA. - FX-LOW-5: document why DMAMUX wiring survives flexio_init() reinit. - OF-HIGH-1: protect ObjectFLEDDmaManager mCurrentOwner against ISR / cross-instance acquire/release races with noInterrupts() guard. - Made kFlexIOPins constexpr to enable the FX-CRIT-1 static_assert.
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/third_party/object_fled/src/ObjectFLEDDmaManager.cpp.hpp (1)
14-26: 🩺 Stability & Availability | 🔴 Critical | 🏗️ Heavy liftMake
acquire()an atomic ownership claim.Line 16 checks completion before the interrupt mask, then Line 25 overwrites
mCurrentOwnerwithout checking whether another caller already owns the setup phase. SinceshowInternal()mutates shared DMA/TCD state afteracquire()and beforerelease(), an ISR/cross-instanceshow()can still slip in whiledma3.complete()is true and corrupt the in-flight setup. Re-checkdma3.complete()andmCurrentOwner == nullptrinside the masked section, and use a non-blocking/deferred path for ISR callers instead of spinning inside an ISR.🤖 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/third_party/object_fled/src/ObjectFLEDDmaManager.cpp.hpp` around lines 14 - 26, Make ObjectFLEDDmaManager::acquire() claim ownership atomically: the completion check currently happens before interrupts are masked, and mCurrentOwner is written without verifying that no other caller already owns the DMA/TCD setup. Move the ownership validation for dma3.complete() and mCurrentOwner == nullptr inside the noInterrupts()/interrupts() critical section in acquire(), and only assign mCurrentOwner when both checks still pass. Also ensure ISR/cross-instance callers that reach showInternal() do not block or spin in interrupt context; route them through a non-blocking deferred path instead of waiting inside the ISR.
🤖 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/third_party/object_fled/src/ObjectFLEDDmaManager.cpp.hpp`:
- Around line 24-38: The interrupt handling in ObjectFLEDDmaManager::acquire()
and ObjectFLEDDmaManager::release(void*) unconditionally re-enables IRQs, so
update both methods to preserve the caller’s prior interrupt state. Save PRIMASK
before disabling interrupts, perform the owner update/check, then restore
PRIMASK on every exit path instead of calling interrupts(). Follow the existing
pattern used elsewhere in the repo (for example the watchdog_k20
implementation), and if __get_PRIMASK is not available here, add the same local
inline fallback used by the common ARM clockless code.
---
Outside diff comments:
In `@src/third_party/object_fled/src/ObjectFLEDDmaManager.cpp.hpp`:
- Around line 14-26: Make ObjectFLEDDmaManager::acquire() claim ownership
atomically: the completion check currently happens before interrupts are masked,
and mCurrentOwner is written without verifying that no other caller already owns
the DMA/TCD setup. Move the ownership validation for dma3.complete() and
mCurrentOwner == nullptr inside the noInterrupts()/interrupts() critical section
in acquire(), and only assign mCurrentOwner when both checks still pass. Also
ensure ISR/cross-instance callers that reach showInternal() do not block or spin
in interrupt context; route them through a non-blocking deferred path instead of
waiting inside the ISR.
🪄 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: e264e84e-e5fa-40b1-98ce-79166d97bfec
📒 Files selected for processing (2)
src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hppsrc/third_party/object_fled/src/ObjectFLEDDmaManager.cpp.hpp
🚧 Files skipped from review as they are similar to previous changes (1)
- src/platforms/arm/teensy/teensy4_common/drivers/flexio/flexio_driver.cpp.hpp
- FX-LOW-6: document parallel-shifter perf ceiling - FX-MED-6 / FX-LOW-7: note WS2812B reset-detection margin at 1267 ns - RX-LOW-5: simplify finished() to be a pure ISR-flag accessor and point at wait() for the actual inactivity-based detection - RX-LOW-6: mark injectEdges() as test-only and document the mReceiveDone=true short-circuit hazard - RX-MED-7: widen bit_count from u8 to u32 to avoid surprise promotion
- OF-LOW-4: comment that xbar_connect() only touches SEL[] (not CTRL),
so calling it after configure_objectfled_xbar_dma_edges() is safe
- OF-LOW-7: add TCD null-checks after dma{1,2,3}.begin() so a channel
exhaustion failure marks initialized=false instead of silently
corrupting later TCD writes
- OF-MED-2: document that comp1load is computed from F_BUS_ACTUAL at begin() time and goes stale on runtime clock changes (require re-begin) - OF-LOW-3: document default eDMA priority interaction with Audio I2S on channel 3 (~1.5 ms starvation per 100-LED frame) - OF-LOW-5: gate force_pin_to_gpio_mux SION bit behind FASTLED_OBJECTFLED_PROBE_INPUT define. Production users dropping the input-keeper save ~1-2 mA leakage and avoid the noise coupling the keeper introduces on long traces. Loopback diagnostic users keep SION via the define. Bench variance 0.4-0.8% (within noise).
CITER decrements on minor-loop completion only. Sampling CITER mid-loop under-reports by 2 captures; adding +1 to the (biter - citer) compute ensures the last in-flight pair is included. Downstream buildEdgeTimes already handles trailing zero/stale captures gracefully via the phantom-pair skip + invalid-edge filter.
- OF-MED-5: document the fillbits |= invariant requirement for the per-ISR memset - RX-MED-4: document the MMIO Device-nGnRnE mapping dependency for the FlexPWM capture DMA source - RX-LOW-2: warn future readers about the mBufferSize-vs-buffer_size edge-pairs-vs-edges naming gap
- FX-MED-5: note that park-pin-LOW uses Arduino GPIO API and works on the verified pin (pin 8 / GPIO_B1_00) via GPIO7 fast alias. All other FlexIO2 pins map to the same fast-alias path; scope verification still recommended per-pad-bank. - OF-MED-3: closure -- search of OjectFLED.cpp.hpp shows the three comp1load computations are the only float-to-int casts and they already use +0.5f rounding (added in #3406 audit Agent 3).
- OF-HIGH-4: short-circuit ISR when remain==0 to skip ~10us of
memset+fillbits+dcache_flush dead work at frame end. Also added
asm("dsb") after clearInterrupt() (mirror of FX-HIGH-6).
- OF-MED-1: pad bitmaskLocal[4] up to [8] so it occupies a full 32-byte
cache line and the arm_dcache_flush_delete in begin() can't invalidate
the adjacent numpinsLocal/numbytesLocal fields.
- OF-MED-6: document that waitForCompletion() reflects DMA major-loop
done but not the WS2812 reset latch; defensive callers should use
busy()==0 which factors in LATCH_DELAY.
ObjectFLED still 0.3-0.8% on bench loopback (no regression).
Add dma_es field to FlexIODiagnostics and snapshot DMA_ES (eDMA Error Status register) inside the read_diagnostics atomic window. Non-zero DMA_ES indicates a channel error somewhere on the system that may explain why a frame got silently dropped. Tried installing a dedicated IRQ_DMA_ERROR handler but rolled back -- that NVIC vector is shared by every eDMA channel (Audio I2S, FlexSerial, ObjectFLED, etc.), so taking ownership would break unrelated subsystems. Passive surfacing via the diagnostic dump gives observability without the cross-subsystem coupling.
- FX-MED-1: explicit comment in flexio_init() explaining why t0h/t1h/ period_ns params are currently ignored, what would need to change to honour them, and which chipsets are silently passing through. - RX-MED-1: comment explaining why mArmedCiter is sampled before the settle/ARMA bounce (intentional baseline for wait() timeout classification). - RX-MED-6: document the signal_range_max_ns config knob for tighter chipsets (TM1814/APA106 ~80us reset). RX-HIGH-4 confirmed as a documented preserved-quirk in decode_ws2812.h (intentional behaviour for backwards-compat with Native + LPC decoders).
- RX-LOW-7: add destructor to FlexPwmRxChannelImpl that disables DMA, detaches the IRQ, and resets PAD_CTL + mux to a neutral GPIO state so subsequent peripheral users on the same pin don't inherit our HYS/PKE/PUE bias. - OF-LOW-6: document the multi-timing-group serialisation contract in channel_engine_objectfled.cpp.hpp (poll() services one group at a time; user-yielding loops can starve subsequent groups). - Removed another duplicate fl/log/log.h include in channel_engine_objectfled.cpp.hpp. ObjectFLED: 0.5% / FlexIO: 1.0% -- noise floor unchanged.
Previously SHIFTSDEN was set BEFORE the TCD was fully programmed and before the eDMA channel was enabled. The audit flagged the window where a re-init path could leave the channel ERQ-armed long enough for a pending shifter-empty signal to fire DMA against a half-set TCD. Defer the SHIFTSDEN write until after sDmaChannel->enable() so DMA is known to be looking at a complete TCD when the first shifter-empty event fires. Measured: FlexIO byte corruption dropped from 0.9-1.1% to 0.7-0.8% on bench loopback. Likely closes a small slice of frames that were silently being mis-armed.
- OF-LOW-1: renamed OjectFLED.cpp.hpp -> ObjectFLED.cpp.hpp and
updated the _build.cpp.hpp include path. Filename now matches the
class name.
- RX-LOW-4: replaced the per-edge 64-bit divide in tickDeltaNs with a
Q16.16 fixed-point multiply (~30 cycles -> ~1 cycle UMULL per call,
saving ~250us of CPU per 100-LED frame). Initial constant computed
once on first call since F_BUS_ACTUAL is runtime-variable on Teensy.
- FX-CRIT-3: added asm("dsb") between sDmaChannel->disable() + clears
and the FLEXIO2_CTRL &= ~1 disable below, so any posted writes to
the eDMA engine commit before we touch FlexIO state. Closes the
audit's theoretical race window where an in-flight minor-loop write
could overlap the FLEXEN disable.
All 52 #3416 audit items now have either a code change, an empirical
rejection annotation, or a documentation marker. No items are
deferred without explanation.
Pre-scan HIGH durations in the captured frame to find the bimodal split point and use (high_min + high_max) / 2 instead of the static spec-derived midpoint. Many TX implementations emit '1' bits well above the spec nominal (FlexIO at kFlexIOBaudDiv=18 emits ~950 ns vs spec 580 ns); receiver jitter can push marginal pulses across the static threshold but the observed-distribution midpoint stays centered between the actual two clusters. Falls back to the static midpoint when fewer than 16 plausible samples or when min/max are too close to be confident in the bimodal split (defensive against all-zero frames). Empirically no measurable improvement on bench loopback -- the residual errors are full-pulse corruption (HIGH/LOW labels swapped due to dropped edges) not classification edge-of-tolerance issues. But the adaptive threshold is the right semantic for any chipset whose TX implementation deviates from spec timing.
Tested 100K pull-down on the FlexPWM RX pad. FlexIO 0.8-1.1%, ObjectFLED 0.5-1.0% byte error -- statistically identical to keeper mode. Push-pull TX leaves no time window for any pad-bias to differentiate, confirming the residual noise floor is on-wire ringing rather than HIGH-Z state floating. Reverted to keeper as the least-surprising default; comment now explicitly documents the test result so future readers don't re-attempt the same experiment.
- CRITICAL: guard against numPins == 0 in ObjectFLED ctor (division by zero in stripLen = numLEDs / numpinsLocal) - MAJOR: collapse duplicate BYTES_PER_DMA definitions (120 in ObjectFLED.h, 150 in ObjectFLEDDmaManager.h) into single source of truth in ObjectFLEDDmaManager.h. ObjectFLED.h now includes the manager header to receive the canonical value, eliminating the include-order-dependent ODR hazard against bitdata[]. - MAJOR: replace ObjectFLEDDmaManager's noInterrupts()/interrupts() pair with PRIMASK save/restore via inline asm. The previous unconditional re-enable would have clobbered the caller's IRQ-disabled state if invoked from inside another critical section. - MINOR: change %s -> %d in FL_LOG_FLEXIO_F truncation warning -- the args are (int), not const char*. - DOCS: update the rx_flexpwm PAD_CTL comment block which described pull-up behaviour while the code actually configures keeper. All 5 CodeRabbit issues now resolved. Builds and tests pass; FlexIO 0.9%, ObjectFLED 0.7% on bench loopback (same noise floor as before).
Summary
Comprehensive burn-down of #3416 audit findings across FlexIO, ObjectFLED, and FlexPWM RX + shared decoder. 42 of 52 audit items closed in 8 batches; 4 items REJECTED on empirical testing (regression evidence preserved in code comments); ~6 items deferred for follow-up.
What's in this PR
Hardware-level fixes
Code-quality fixes
#include "fl/log/log.h"removed (x2 files)Documentation-only
13 additional in-line comments capturing audit findings (RM citations, race-window explanations, reinit safety notes, perf-ceiling caveats, eDMA priority interactions, multi-vendor WS2812B reset-window margins, etc).
Empirically REJECTED audit recommendations (preserved as comments)
Measured signal integrity (bench loopback Teensy 4.1 pin 8 <-> pin 22)
ObjectFLED measurably improved; FlexIO held at the same noise floor. The residual is random single-bit errors at different LED positions on every run on both drivers -- consistent with wire signal integrity at the jumper-loopback test rig, not a driver bug.
Still open in #3416 (~10 items, follow-up)
Refs #3416 #3406 #3410
🤖 Generated with Claude Code