Conversation
WalkthroughThe RX pin initialization on ESP32 is refactored to use the GPIO driver's Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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 the current code and only fix it if needed.
Inline comments:
In `@wled00/wled.cpp`:
- Around line 378-383: The serial RX timeout is too long on ESP32 causing
Serial.available() to miss short commands; after the existing
Serial.begin(115200) call add a guarded call to Serial.setRxTimeout(1) inside
the preprocessor check for ARDUINO_ARCH_ESP32 and excluding
ARDUINO_USB_CDC_ON_BOOT (i.e. wrap the setRxTimeout call with `#if`
defined(ARDUINO_ARCH_ESP32) && !ARDUINO_USB_CDC_ON_BOOT ... `#endif`) so the IDF
idle-timeout mechanism triggers for short packets without using setRxFIFOFull();
keep the existing gpio_pulldown_en((gpio_num_t)hardwareRX) code as-is.
🪄 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: 86d25caf-0e0d-43d3-a53d-58111982b7fc
📒 Files selected for processing (1)
wled00/wled.cpp
| // Pull down RX pin to suppress noise when floating, without breaking UART0 IOMUX mapping. | ||
| // pinMode() routes GPIO through the GPIO matrix and detaches UART0 RX - use gpio_pulldown_en() instead. | ||
| // See issue #3128. | ||
| gpio_pulldown_en((gpio_num_t)hardwareRX); |
There was a problem hiding this comment.
all that is needed is to replace pinMode(hardwareRX, INPUT_PULLDOWN); with this line, nothing else.
There was a problem hiding this comment.
@DedeHai originally the pinMode() call was located before Serial.Begin(), to avoid side-effects when Serial initializes its pins. 🤔 Do you think gpio_pulldown_en() should happen before Serial.Begin(), or keep it after? I don't have much experience with the under-the-hood pin config tools in esp-idf.
There was a problem hiding this comment.
it should stay where it was, the API calls are very low level and will directly write the GPIO registers, enabling the pulldown with no fuss.
There was a problem hiding this comment.
I can confirm the fix working, all that is needed is this:
replace
pinMode(hardwareRX, INPUT_PULLDOWN);
with
gpio_pulldown_en((gpio_num_t)hardwareRX);
and maybe add a comment that pinMode() sets the gpio mux and breaks UART.
no additional includes, nothing.
Possible fix for #5501
Tested on a real ESP32, and CI passes. It has not been tested on a real ESP8266.
This is my first pull request, so please feel free to reject it if anything is wrong.
Summary by CodeRabbit