Skip to content

Commit 011e6a7

Browse files
committed
Require both DTR and RTS pins
1 parent ab5109f commit 011e6a7

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")]
@@ -46,9 +46,11 @@ impl Interface {
4646
let rts_gpio = opts.rts.or(config.rts);
4747
let dtr_gpio = opts.dtr.or(config.dtr);
4848

49-
if port_info.port_type == serialport::SerialPortType::Unknown && dtr_gpio.is_none() {
50-
// Assume internal UART, which has no DTR pin.
51-
return Err(SerialConfigError::MissingDtrForInternalUart);
49+
if port_info.port_type == serialport::SerialPortType::Unknown
50+
&& (dtr_gpio.is_none() || rts_gpio.is_none())
51+
{
52+
// Assume internal UART, which has no DTR pin and usually no RTS either.
53+
return Err(Error::from(SerialConfigError::MissingDtrRtsForInternalUart));
5254
}
5355

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

0 commit comments

Comments
 (0)