fix(pl18u): Reinit I2C when touch screen not working#7402
Conversation
📝 WalkthroughWalkthroughAdds and zeroes the I2C handle Init after deinit; enables touch driver ChangesSTM32 I2C Driver Cleanup and Touch Reinitialization
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Fix stm32_i2c_deinit() to reset HAL Init struct so deinit→init cycle actually reinitializes the I2C peripheral. On STM32F4, HAL_I2C_Init toggles SWRST which hardware-resets the stuck I2C state machine. Add periodic _i2c_reInit() trigger every 50 polls in touchPanelRead() with TRACE output for debugging.
dee91fc to
d66b80d
Compare
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 `@radio/src/targets/pl18/touch_driver.cpp`:
- Around line 173-180: The TRACE call always reports "I2C reinit: bus reset
complete" even if deinit or re-init failed; update _i2c_reInit() to check the
return value of i2c_deinit(TOUCH_I2C_BUS) and the result of _i2c_init() and only
emit the success TRACE when both succeed, otherwise log an error/TRACE with the
failure reason and propagate/return an error code; specifically modify the block
around i2c_deinit, delay_ms(1), and _i2c_init() (references: i2c_deinit,
_i2c_init, and the surrounding TRACE calls) to conditionally log success or
failure and avoid masking recovery failures.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 4d0c0c70-f4c9-4e23-85a2-a837cb459f13
📒 Files selected for processing (2)
radio/src/targets/common/arm/stm32/stm32_i2c_driver.cppradio/src/targets/pl18/touch_driver.cpp
|
@pfeerick Need to wait for Flysky confirm if this can fix the problem, I can hardly reproduce touch screen dead. |
PL18U can have touch screen unresponsive, and need I2C reinit to make it work again.
This PR will fix all similar symptom in all Flysky radios supported in pl18 target.
A bug is discovered in stm32_i2c_driver that will make reinit i2c bus not working in other color touch screen (opencode + deepseek did this, yeah)
Summary by CodeRabbit
Bug Fixes
Tests