Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion esp-hal/src/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@

let rts_pin = PinGuard::new_unconnected(self.uart.info().rts_signal);
let tx_pin = PinGuard::new_unconnected(self.uart.info().tx_signal);
let dtr_pin = PinGuard::new_unconnected(self.uart.info().dtr_signal);

let mut serial = Uart {
rx: UartRx {
Expand All @@ -463,6 +464,7 @@
guard: tx_guard,
rts_pin,
tx_pin,
dtr_pin,
},
};
serial.init(config)?;
Expand Down Expand Up @@ -499,6 +501,7 @@
guard: PeripheralGuard,
rts_pin: PinGuard,
tx_pin: PinGuard,
dtr_pin: PinGuard,
}

/// UART (Receive)
Expand Down Expand Up @@ -641,6 +644,7 @@
guard: self.guard,
rts_pin: self.rts_pin,
tx_pin: self.tx_pin,
dtr_pin: self.dtr_pin,
}
}
}
Expand All @@ -663,6 +667,7 @@
guard: self.guard,
rts_pin: self.rts_pin,
tx_pin: self.tx_pin,
dtr_pin: self.dtr_pin,
}
}

Expand Down Expand Up @@ -746,6 +751,25 @@
self
}

/// Configure DTR pin
#[instability::unstable]
pub fn with_dtr(mut self, dtr: impl PeripheralOutput<'d>) -> Self {
let dtr = dtr.into();

dtr.apply_output_config(&OutputConfig::default());
dtr.set_output_enable(true);

self.dtr_pin = dtr.connect_with_guard(self.uart.info().dtr_signal);

self
}

/// Enable RS485 mode
pub fn with_rs485(self) -> Self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • needs to be unstable (if you keep it)
  • should be called into_rs485 and there is no way to disable it, either (if you keep it).
  • Maybe this function should be turned into a Config struct field? All other configuration is set there.
  • I'm still not sure we want to shoehorn RS485 into the main UART driver. Given that this is pretty minor and also unstable, maybe we can, for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this function should be turned into a Config struct field? All other configuration is set there.

I don't know nearly enough about rs485, but I think I agree here. Especially when you think about how to turn it off. We already have options, like hardware flow control, which have a config setting and require pins to be passed. I think we should follow this pattern.

I'm still not sure we want to shoehorn RS485 into the main UART driver. Given that this is pretty minor and also unstable, maybe we can, for now.

I agree, that we can experiment with this as an unstable API and figure out if it needs to be a separate driver.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay apparently DTR/DSR are not available in the hardware

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All fair points, I'm currently still testing it out after porting #2994. I think putting it in the Uart driver makes sense given the reference manual, but I'm not against something like an Rs485<'a, T: Uart> but either way you need to access the Uart registers.

self.regs().rs485_conf().write(|w| w.rs485_en().set_bit());
self
}

/// Assign the TX pin for UART instance.
///
/// Sets the specified pin to push-pull output and connects it to the UART
Expand Down Expand Up @@ -1609,6 +1633,20 @@
self
}

/// Configure DTR pin
#[instability::unstable]
pub fn with_dtr(mut self, dtr: impl PeripheralOutput<'d>) -> Self {
self.tx = self.tx.with_dtr(dtr);
self
}

/// Enable RS485 mode
#[instability::unstable]
pub fn with_rs485(mut self) -> Self {
self.tx = self.tx.with_rs485();
self
}

fn regs(&self) -> &RegisterBlock {
// `self.tx.uart` and `self.rx.uart` are the same
self.tx.uart.info().regs()
Expand Down Expand Up @@ -2609,6 +2647,9 @@

/// RTS (Request to Send) pin
pub rts_signal: OutputSignal,

/// DTR (Data Terminal Ready) pin
pub dtr_signal: OutputSignal,
}

/// Peripheral state for a UART instance.
Expand Down Expand Up @@ -3347,8 +3388,8 @@

unsafe impl Sync for Info {}

for_each_uart! {

Check failure on line 3391 in esp-hal/src/uart.rs

View workflow job for this annotation

GitHub Actions / esp-hal (esp32)

no variant or associated item named `U2DTR` found for enum `gpio::OutputSignal` in the current scope

Check failure on line 3391 in esp-hal/src/uart.rs

View workflow job for this annotation

GitHub Actions / esp-hal (esp32)

no variant or associated item named `U1DTR` found for enum `gpio::OutputSignal` in the current scope

Check failure on line 3391 in esp-hal/src/uart.rs

View workflow job for this annotation

GitHub Actions / esp-hal (esp32)

no variant or associated item named `U2DTR` found for enum `gpio::OutputSignal` in the current scope

Check failure on line 3391 in esp-hal/src/uart.rs

View workflow job for this annotation

GitHub Actions / esp-hal (esp32)

no variant or associated item named `U1DTR` found for enum `gpio::OutputSignal` in the current scope
($inst:ident, $peri:ident, $rxd:ident, $txd:ident, $cts:ident, $rts:ident) => {
($inst:ident, $peri:ident, $rxd:ident, $txd:ident, $cts:ident, $rts:ident, $dtr:ident) => {
impl Instance for crate::peripherals::$inst<'_> {
fn parts(&self) -> (&'static Info, &'static State) {
#[crate::handler]
Expand All @@ -3371,6 +3412,7 @@
rx_signal: InputSignal::$rxd,
cts_signal: InputSignal::$cts,
rts_signal: OutputSignal::$rts,
dtr_signal: OutputSignal::$dtr,
};
(&PERIPHERAL, &STATE)
}
Expand Down
13 changes: 7 additions & 6 deletions esp-metadata-generated/src/_generated_esp32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,18 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS), (UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS, U2DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR), (UART2, Uart2, U2RXD, U2TXD, U2CTS,
U2RTS, U2DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
10 changes: 5 additions & 5 deletions esp-metadata-generated/src/_generated_esp32c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,16 +196,16 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
10 changes: 5 additions & 5 deletions esp-metadata-generated/src/_generated_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
10 changes: 5 additions & 5 deletions esp-metadata-generated/src/_generated_esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,16 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
10 changes: 5 additions & 5 deletions esp-metadata-generated/src/_generated_esp32h2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,16 +207,16 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
10 changes: 5 additions & 5 deletions esp-metadata-generated/src/_generated_esp32s2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,16 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
13 changes: 7 additions & 6 deletions esp-metadata-generated/src/_generated_esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,17 +210,18 @@ macro_rules! for_each_i2c_master {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#[macro_export]
#[cfg_attr(docsrs, doc(cfg(feature = "_device-selected")))]
macro_rules! for_each_uart {
($($pattern:tt => $code:tt;)*) => {
macro_rules! _for_each_inner { $(($pattern) => $code;)* ($other : tt) => {} }
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS));
_for_each_inner!((UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS), (UART1, Uart1,
U1RXD, U1TXD, U1CTS, U1RTS), (UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS)));
_for_each_inner!((UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR));
_for_each_inner!((UART1, Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR));
_for_each_inner!((UART2, Uart2, U2RXD, U2TXD, U2CTS, U2RTS, U2DTR));
_for_each_inner!((all(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR), (UART1,
Uart1, U1RXD, U1TXD, U1CTS, U1RTS, U1DTR), (UART2, Uart2, U2RXD, U2TXD, U2CTS,
U2RTS, U2DTR)));
};
}
/// This macro can be used to generate code for each peripheral instance of the SPI master driver.
Expand Down
6 changes: 3 additions & 3 deletions esp-metadata/devices/esp32.toml
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart2", sys_instance = "Uart2", tx = "U2TXD", rx = "U2RXD", cts = "U2CTS", rts = "U2RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
{ name = "uart2", sys_instance = "Uart2", tx = "U2TXD", rx = "U2RXD", cts = "U2CTS", rts = "U2RTS", dtr = "U2DTR" },
]

[device.ethernet]
Expand Down
4 changes: 2 additions & 2 deletions esp-metadata/devices/esp32c2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ instances = [{ name = "timg0" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
]

# Other drivers which are partially supported but have no other configuration:
Expand Down
4 changes: 2 additions & 2 deletions esp-metadata/devices/esp32c3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
]

[device.ds]
Expand Down
4 changes: 2 additions & 2 deletions esp-metadata/devices/esp32c6.toml
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
]

[device.ds]
Expand Down
4 changes: 2 additions & 2 deletions esp-metadata/devices/esp32h2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
]

[device.ds]
Expand Down
4 changes: 2 additions & 2 deletions esp-metadata/devices/esp32s2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,8 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
]

[device.rgb_display] # via SPI and I2S
Expand Down
6 changes: 3 additions & 3 deletions esp-metadata/devices/esp32s3.toml
Original file line number Diff line number Diff line change
Expand Up @@ -601,9 +601,9 @@ instances = [{ name = "timg0" }, { name = "timg1" }]
[device.uart]
support_status = "supported"
instances = [
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS" },
{ name = "uart2", sys_instance = "Uart2", tx = "U2TXD", rx = "U2RXD", cts = "U2CTS", rts = "U2RTS" },
{ name = "uart0", sys_instance = "Uart0", tx = "U0TXD", rx = "U0RXD", cts = "U0CTS", rts = "U0RTS", dtr = "U0DTR" },
{ name = "uart1", sys_instance = "Uart1", tx = "U1TXD", rx = "U1RXD", cts = "U1CTS", rts = "U1RTS", dtr = "U1DTR" },
{ name = "uart2", sys_instance = "Uart2", tx = "U2TXD", rx = "U2RXD", cts = "U2CTS", rts = "U2RTS", dtr = "U2DTR" },
]

[device.touch]
Expand Down
8 changes: 6 additions & 2 deletions esp-metadata/src/cfg/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub(crate) struct UartInstanceConfig {

/// IOMUX signal name of the instance's RTS signal.
pub rts: String,

/// IOMUX signal name of the instance's DTR signal.
pub dtr: String,
}

/// Generates `for_each_uart!` which can be used to implement the UART
Expand All @@ -39,11 +42,12 @@ pub(crate) fn generate_uart_peripherals(uart: &UartProperties) -> TokenStream {
let tx = format_ident!("{}", instance_config.tx);
let cts = format_ident!("{}", instance_config.cts);
let rts = format_ident!("{}", instance_config.rts);
let dtr = format_ident!("{}", instance_config.dtr);

// The order and meaning of these tokens must match their use in the
// `for_each_uart!` call.
quote! {
#instance, #sys, #rx, #tx, #cts, #rts
#instance, #sys, #rx, #tx, #cts, #rts, #dtr
}
})
.collect::<Vec<_>>();
Expand All @@ -65,7 +69,7 @@ pub(crate) fn generate_uart_peripherals(uart: &UartProperties) -> TokenStream {
/// - `$sys`: the name of the instance as it is in the `esp_hal::system::Peripheral` enum.
/// - `$rx`, `$tx`, `$cts`, `$rts`: signal names.
///
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS)`
/// Example data: `(UART0, Uart0, U0RXD, U0TXD, U0CTS, U0RTS, U0DTR)`
#for_each
}
}
Loading