aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/usart/mod.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index d5828a492..dfa1f3a6a 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -132,6 +132,14 @@ pub struct Config {
132 /// Set this to true to swap the RX and TX pins. 132 /// Set this to true to swap the RX and TX pins.
133 #[cfg(any(usart_v3, usart_v4))] 133 #[cfg(any(usart_v3, usart_v4))]
134 pub swap_rx_tx: bool, 134 pub swap_rx_tx: bool,
135
136 /// Set this to true to invert TX pin signal values (V<sub>DD</sub> =0/mark, Gnd = 1/idle).
137 #[cfg(any(usart_v3, usart_v4))]
138 pub invert_tx: bool,
139
140 /// Set this to true to invert RX pin signal values (V<sub>DD</sub> =0/mark, Gnd = 1/idle).
141 #[cfg(any(usart_v3, usart_v4))]
142 pub invert_rx: bool,
135} 143}
136 144
137impl Default for Config { 145impl Default for Config {
@@ -147,6 +155,10 @@ impl Default for Config {
147 assume_noise_free: false, 155 assume_noise_free: false,
148 #[cfg(any(usart_v3, usart_v4))] 156 #[cfg(any(usart_v3, usart_v4))]
149 swap_rx_tx: false, 157 swap_rx_tx: false,
158 #[cfg(any(usart_v3, usart_v4))]
159 invert_tx: false,
160 #[cfg(any(usart_v3, usart_v4))]
161 invert_rx: false,
150 } 162 }
151 } 163 }
152} 164}
@@ -972,7 +984,11 @@ fn configure(
972 }); 984 });
973 985
974 #[cfg(any(usart_v3, usart_v4))] 986 #[cfg(any(usart_v3, usart_v4))]
975 w.set_swap(config.swap_rx_tx); 987 {
988 w.set_txinv(config.invert_tx);
989 w.set_rxinv(config.invert_rx);
990 w.set_swap(config.swap_rx_tx);
991 }
976 }); 992 });
977 993
978 #[cfg(not(usart_v1))] 994 #[cfg(not(usart_v1))]