Skip to content

Commit 01f0ce5

Browse files
committed
Require both DTR and RTS pins
1 parent 5d0a8e0 commit 01f0ce5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

espflash/src/interface.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rppal::gpio::{Gpio, OutputPin};
1010
#[derive(thiserror::Error, Debug)]
1111
pub enum SerialConfigError {
1212
#[cfg(feature = "raspberry")]
13-
#[error("You need to specify DTR when using an internal UART peripheral")]
14-
MissingDtrForInternalUart,
13+
#[error("You need to specify both DTR and RTS pins when using an internal UART peripheral")]
14+
MissingDtrRtsForInternalUart,
1515

1616
#[cfg(feature = "raspberry")]
1717
#[error("GPIO {0} is not available")]
@@ -54,9 +54,11 @@ impl Interface {
5454
let rts_gpio = opts.rts.or(config.rts);
5555
let dtr_gpio = opts.dtr.or(config.dtr);
5656

57-
if port_info.port_type == serialport::SerialPortType::Unknown && dtr_gpio.is_none() {
58-
// Assume internal UART, which has no DTR pin.
59-
return Err(Error::from(SerialConfigError::MissingDtrForInternalUart));
57+
if port_info.port_type == serialport::SerialPortType::Unknown
58+
&& (dtr_gpio.is_none() || rts_gpio.is_none())
59+
{
60+
// Assume internal UART, which has no DTR pin and usually no RTS either.
61+
return Err(Error::from(SerialConfigError::MissingDtrRtsForInternalUart));
6062
}
6163

6264
let mut gpios = Gpio::new().unwrap();

0 commit comments

Comments
 (0)