diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-12-10 23:48:26 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-12-10 23:48:26 +0000 |
| commit | 2d2bd679ee2d3247c94dd66fa8ec40ffa07090ab (patch) | |
| tree | c5e09f1a5b522cff94194a1a2dcd307f0aaf696e | |
| parent | 343be37f397ff82eb9d34161920449cc4b45c31a (diff) | |
| parent | dfba51d3f2a4d6866f6d6de98fde9a620cda20b7 (diff) | |
Merge pull request #2275 from lights0123/stm32-usart-invert
stm32: usart pin inversion
| -rw-r--r-- | embassy-stm32/src/usart/mod.rs | 18 |
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 | ||
| 137 | impl Default for Config { | 145 | impl 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))] |
