From 168ea40da67121d4f0b95217d2267ef675919f80 Mon Sep 17 00:00:00 2001 From: brambo123 Date: Thu, 14 Mar 2024 13:45:45 +0100 Subject: [PATCH] UART flow control: Fix forgotten change to esp_idf and improve esp32-arduino --- esphome/components/uart/uart_component_esp32_arduino.cpp | 3 +-- esphome/components/uart/uart_component_esp_idf.cpp | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/esphome/components/uart/uart_component_esp32_arduino.cpp b/esphome/components/uart/uart_component_esp32_arduino.cpp index fe5234c2d5..259044ecdc 100644 --- a/esphome/components/uart/uart_component_esp32_arduino.cpp +++ b/esphome/components/uart/uart_component_esp32_arduino.cpp @@ -120,7 +120,6 @@ void ESP32ArduinoUARTComponent::setup() { void ESP32ArduinoUARTComponent::load_settings(bool dump_config) { int8_t tx = this->tx_pin_ != nullptr ? this->tx_pin_->get_pin() : -1; int8_t rx = this->rx_pin_ != nullptr ? this->rx_pin_->get_pin() : -1; - int8_t flow_control = this->flow_control_pin_ != nullptr ? this->flow_control_pin_->get_pin() : -1; bool invert = false; if (tx_pin_ != nullptr && tx_pin_->is_inverted()) invert = true; @@ -131,7 +130,7 @@ void ESP32ArduinoUARTComponent::load_settings(bool dump_config) { this->hw_serial_->begin(this->baud_rate_, get_config(), rx, tx, invert); #ifdef USE_UART_FLOW_CONTROL if (this->flow_control_pin_ != nullptr) { - this->hw_serial_->setPins(-1, -1, -1, flow_control); + this->hw_serial_->setPins(-1, -1, -1, this->flow_control_pin_->get_pin()); this->hw_serial_->setMode(UART_MODE_RS485_HALF_DUPLEX); } #endif diff --git a/esphome/components/uart/uart_component_esp_idf.cpp b/esphome/components/uart/uart_component_esp_idf.cpp index 3e5086abdb..11aefb7c59 100644 --- a/esphome/components/uart/uart_component_esp_idf.cpp +++ b/esphome/components/uart/uart_component_esp_idf.cpp @@ -101,7 +101,7 @@ void IDFUARTComponent::setup() { return; } - err = uart_set_pin(this->uart_num_, tx, rx, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE); + err = uart_set_pin(this->uart_num_, tx, rx, flow_control, UART_PIN_NO_CHANGE); if (err != ESP_OK) { ESP_LOGW(TAG, "uart_set_pin failed: %s", esp_err_to_name(err)); this->mark_failed();