Repository navigation
fix(objectfled): restore clockless pins' GPR26-29 bank and pad state on deinit (#5395) - #5406
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 33 seconds. View limit details
Note
|
Memory usage (this PR vs. its merge base)Change in
|
…on deinit (#5395) Clockless begin() cleared each pin's IOMUXC_GPR26..29 bit to move it from GPIO6-9 to GPIO1-4, made it a GPIO1-4 output and took its mux and pad control, and nothing gave them back. Teensy pinMode()/FastPin drive GPIO6-9, so ordinary GPIO on those pins stayed disconnected after the driver went away. begin() now snapshots each pad with the ObjectFLEDPadState from #5148 before claiming it; the destructor and both DMA-allocation failure paths restore the snapshots.
375f6df to
a0b71ba
Compare
Closes #5395.
Problem
In clockless mode,
ObjectFLED::begin()takes each output pin over:IOMUXC_GPR_GPR26..29, which moves the pin from GPIO6-9 to GPIO1-4,GDIR,~ObjectFLED()restored none of this. TeensypinMode()/digitalWrite()andFastPindrive GPIO6-9, so once the driver was destroyed or reconfigured, ordinary GPIO on those pins no longer reached the pad. #5148 fixed the same leak for SPI mode.Fix
This reuses
ObjectFLEDPadStatefrom #5148 rather than adding a second copy. New inobjectfled_pad_state.h:objectfled_single_pad_regs()builds anObjectFLEDPadRegsfor one pad: both pad slots name the same mux and pad registers, andgpr26is the pad's own GPR26..29 bank.objectfled_clockless_claim_pad()does the per-pin setup that used to sit inline inbegin(), and takes the snapshot before it. On a repeatedbegin()it keeps the first snapshot.objectfled_clockless_release_pads()restores every captured slot in reverse claim order, so a pin listed twice ends in its pre-driver state.ObjectFLEDholds oneObjectFLEDPadStateperpinlistslot.releasePads()runs in two places:begin().ObjectFLEDPadState::restore()puts the bank select back first and touches only the driven pins' bits in the shared registers.Tests
New case in
tests/platforms/arm/teensy/teensy4_common/drivers/objectfled/objectfled_pad_state.cpp. It runs the clockless begin/destroy sequence against a register model with GPR26..29, GPIO1..4 and two pads:0xBFFFFFF7where0xBFFFFFFFis expected, GPR28 reads0xFFFFFFDFwhere0xFFFFFFFFis expected, GDIR and the mux/pad registers are not restored, and the snapshots are never consumed.bash test objectfled_pad_statepasses (7/7), and so does--debug(ASAN/UBSAN).channel_engine_objectfledpasses.bash lint --cpppasses.bash compile teensy41 --examples Blinkandbash compile teensy40 --examples Blinksucceed.ObjectFLED.cpp.hppis in the library build, so both compiles include the driver change.Limitation
No Teensy 4.x board was attached, so the restore has not run on hardware. Two things have not been tested on a device: the pad going back to GPIO6 after teardown, and a pin re-claimed by a new instance. Coverage is the host register model plus the teensy40/41 compiles. Each instance uses about 36 B ×
NUM_DIGITAL_PINSof extra RAM for the snapshots, roughly 2 KB on a Teensy 4.1.