mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 11:26:39 +00:00
[uart] Delete ESP32 UART driver on shutdown to keep ROM output off the bus (#18684)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
This commit is contained in:
co-authored by
J. Nick Koston
parent
b11a34af5c
commit
b8408e14b9
@@ -393,5 +393,16 @@ void IRAM_ATTR IDFUARTComponent::uart_rx_isr_callback(uart_port_t uart_num, uart
|
||||
}
|
||||
#endif // USE_UART_WAKE_LOOP_ON_RX
|
||||
|
||||
void IDFUARTComponent::on_shutdown() {
|
||||
if (this->uart_num_ == UART_NUM_MAX || !uart_is_driver_installed(this->uart_num_))
|
||||
return;
|
||||
uart_wait_tx_done(this->uart_num_, pdMS_TO_TICKS(100));
|
||||
// Keep the peripheral quiet across a soft reset so ROM output does not reach the attached device (#15472)
|
||||
esp_err_t err = uart_driver_delete(this->uart_num_);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "uart_driver_delete failed: %s", esp_err_to_name(err));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace esphome::uart
|
||||
#endif // USE_ESP32
|
||||
|
||||
@@ -52,9 +52,11 @@ class IDFUARTComponent final : public UARTComponent, public Component {
|
||||
void load_settings(bool dump_config) override;
|
||||
using UARTComponent::load_settings; // also bring in the no-arg overload for convenience
|
||||
|
||||
void on_shutdown() override;
|
||||
|
||||
protected:
|
||||
void check_logger_conflict() override;
|
||||
uart_port_t uart_num_;
|
||||
uart_port_t uart_num_{UART_NUM_MAX};
|
||||
uart_config_t get_config_();
|
||||
|
||||
bool has_peek_{false};
|
||||
|
||||
Reference in New Issue
Block a user