Palakis / esphome-native-hdmi-cec

HDMI-CEC implementation for ESPHome
Other
40 stars 11 forks source link

Added pin setup to fix issues with ESP32-C3 #8

Closed segfly closed 3 months ago

segfly commented 3 months ago

Fix for issue #7

On ESP32-C3, pin_->setup() needs to be called, otherwise the pin does not respond to digitalWrite. At least on ESP32-S3, this was not needed, but it is needed on C3.

segfly commented 3 months ago

Unfortunately, I discovered this fix needs more work, as I missed the test case of receiving on the C3. Currently, the C3 will reboot when receiving a frame. Moving the pin_->setup() later in the HDMICEC::setup() prevents that, but it seems the interrupt is disabled because of it. So sending works, just not receiving.

segfly commented 3 months ago

Okay. So I went back to the original code without my patch, and it turns out the C3 was rebooting anyway whenever receiving a frame. The pin->setup() makes no difference. It seems the Watchdog is resetting for some reason:

[14:04:52]ESP-ROM:esp32c3-api1-20210207
[14:04:52]Build:Feb  7 2021
[14:04:52]rst:0x8 (TG1WDT_SYS_RST),boot:0xc (SPI_FAST_FLASH_BOOT)
[14:04:52]Saved PC:0x403801be
WARNING Decoded 0x403801be: _interrupt_handler
[14:04:52]SPIWP:0xee
[14:04:52]mode:DIO, clock div:1
[14:04:52]load:0x3fcd6100,len:0x438
[14:04:52]load:0x403ce000,len:0x918
[14:04:52]load:0x403d0000,len:0x24e4
[14:04:52]entry 0x403ce000
segfly commented 3 months ago

The TG1WDT_SYS_RST seems to only be an issue on Arduino framework with the C3. In any case the pin_->setup() is still needed in this patch in order for the C3 to transmit.

Palakis commented 3 months ago

Thanks for this fix! I’ll add a warning in the README regarding the Arduino framework issue on the C3.

Palakis commented 3 months ago

Closes #7