Skip to content

Commit 97cc8c1

Browse files
author
Veijo Pesonen
committed
Fixes an issue with STM32F4 flow control when RTS&CTS are not connected
With STM32F4 targets UARTSerial.set_flow_control() must be called with both pins(RTS&CTS) enabled. If only one is given assertion will fail. This fix will help to circumvent the issue with STM32F4 when disabling flow control and no pins are given. This won't solve the issue with STM32F4 HAL itself if only one pin is given.
1 parent dea79c6 commit 97cc8c1

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

ESP8266/ESP8266.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ struct ESP8266::fw_at_version ESP8266::at_version()
112112

113113
bool ESP8266::stop_uart_hw_flow_ctrl(void)
114114
{
115-
// Stop board's flow control
116-
_serial.set_flow_control(SerialBase::Disabled, _serial_rts, _serial_cts);
115+
bool done = true;
116+
117+
if (_serial_rts != NC || _serial_cts != NC) {
118+
// Stop board's flow control
119+
_serial.set_flow_control(SerialBase::Disabled, _serial_rts, _serial_cts);
117120

118-
// Stop ESP8266's flow control
119-
bool done = _parser.send("AT+UART_CUR=%u,8,1,0,0", ESP8266_DEFAULT_BAUD_RATE)
120-
&& _parser.recv("OK\n");
121+
// Stop ESP8266's flow control
122+
done = _parser.send("AT+UART_CUR=%u,8,1,0,0", ESP8266_DEFAULT_BAUD_RATE)
123+
&& _parser.recv("OK\n");
124+
}
121125

122126
return done;
123127
}
@@ -137,10 +141,12 @@ bool ESP8266::start_uart_hw_flow_ctrl(void)
137141
} else if (_serial_rts != NC) {
138142
_serial.set_flow_control(SerialBase::RTS, _serial_rts, NC);
139143

144+
// Enable ESP8266's CTS pin
140145
done = _parser.send("AT+UART_CUR=%u,8,1,0,2", ESP8266_DEFAULT_BAUD_RATE)
141146
&& _parser.recv("OK\n");
142147

143148
} else if (_serial_cts != NC) {
149+
// Enable ESP8266's RTS pin
144150
done = _parser.send("AT+UART_CUR=%u,8,1,0,1", ESP8266_DEFAULT_BAUD_RATE)
145151
&& _parser.recv("OK\n");
146152

0 commit comments

Comments
 (0)