diff --git a/src/platforms/esp/32/clockless_rmt_esp32.cpp b/src/platforms/esp/32/clockless_rmt_esp32.cpp index 57c39a71ad..50acf83597 100644 --- a/src/platforms/esp/32/clockless_rmt_esp32.cpp +++ b/src/platforms/esp/32/clockless_rmt_esp32.cpp @@ -343,8 +343,21 @@ void IRAM_ATTR ESP32RMTController::doneOnChannel(rmt_channel_t channel, void * a ESP32RMTController * pController = gOnChannel[channel]; // -- Turn off output on the pin - // SZG: Do I really need to do this? + // Otherwise the pin will stay connected to the RMT controller, + // and if the same RMT controller is used for another output + // pin the RMT output will be routed to both pins. + // Warning: the documentation for gpio_matrix_out is wrong on some + // platforms (https://github.com/espressif/esp-idf/issues/11737), + // and the value to reset the pin to be a GPIO is sometimes different + // than 0x100. Check the TRM for the GPIO_FUNCn_OUT_SEL field to + // find the right value. +#if CONFIG_IDF_TARGET_ESP32C3 + gpio_matrix_out(pController->mPin, 0x80, 0, 0); +#elif CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 gpio_matrix_out(pController->mPin, 0x100, 0, 0); +#else + #error Not yet implemented for unknown ESP32 target +#endif // -- Turn off the interrupts // rmt_set_tx_intr_en(channel, false);