aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorqwerty19106 <[email protected]>2024-04-17 18:07:24 +0400
committerРоман Кривенков <[email protected]>2024-04-18 10:34:52 +0400
commitce58cd0f1c8d524b9ca0c274a51722a7bcde2ada (patch)
tree5c91b0d8fe452fbfc707b1f2592b20ad2424a388
parent78ca904e96e44619ceccff7a71caed5b3bc72b0b (diff)
Allow Uart::new_half_duplex for all usart_vx
-rw-r--r--embassy-stm32/src/usart/mod.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index e7fdf4da6..d21e5c47c 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -933,7 +933,6 @@ impl<'d, T: BasicInstance> Uart<'d, T, Async> {
933 /// I/O in idle or in reception. 933 /// I/O in idle or in reception.
934 /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict 934 /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict
935 /// on the line must be managed by software (for instance by using a centralized arbiter). 935 /// on the line must be managed by software (for instance by using a centralized arbiter).
936 #[cfg(not(any(usart_v1, usart_v2)))]
937 #[doc(alias("HDSEL"))] 936 #[doc(alias("HDSEL"))]
938 pub fn new_half_duplex( 937 pub fn new_half_duplex(
939 peri: impl Peripheral<P = T> + 'd, 938 peri: impl Peripheral<P = T> + 'd,
@@ -943,7 +942,10 @@ impl<'d, T: BasicInstance> Uart<'d, T, Async> {
943 rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd, 942 rx_dma: impl Peripheral<P = impl RxDma<T>> + 'd,
944 mut config: Config, 943 mut config: Config,
945 ) -> Result<Self, ConfigError> { 944 ) -> Result<Self, ConfigError> {
946 config.swap_rx_tx = false; 945 #[cfg(not(any(usart_v1, usart_v2)))]
946 {
947 config.swap_rx_tx = false;
948 }
947 config.half_duplex = true; 949 config.half_duplex = true;
948 950
949 Self::new_inner( 951 Self::new_inner(
@@ -1084,14 +1086,16 @@ impl<'d, T: BasicInstance> Uart<'d, T, Blocking> {
1084 /// I/O in idle or in reception. 1086 /// I/O in idle or in reception.
1085 /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict 1087 /// Apart from this, the communication protocol is similar to normal USART mode. Any conflict
1086 /// on the line must be managed by software (for instance by using a centralized arbiter). 1088 /// on the line must be managed by software (for instance by using a centralized arbiter).
1087 #[cfg(not(any(usart_v1, usart_v2)))]
1088 #[doc(alias("HDSEL"))] 1089 #[doc(alias("HDSEL"))]
1089 pub fn new_blocking_half_duplex( 1090 pub fn new_blocking_half_duplex(
1090 peri: impl Peripheral<P = T> + 'd, 1091 peri: impl Peripheral<P = T> + 'd,
1091 tx: impl Peripheral<P = impl TxPin<T>> + 'd, 1092 tx: impl Peripheral<P = impl TxPin<T>> + 'd,
1092 mut config: Config, 1093 mut config: Config,
1093 ) -> Result<Self, ConfigError> { 1094 ) -> Result<Self, ConfigError> {
1094 config.swap_rx_tx = false; 1095 #[cfg(not(any(usart_v1, usart_v2)))]
1096 {
1097 config.swap_rx_tx = false;
1098 }
1095 config.half_duplex = true; 1099 config.half_duplex = true;
1096 1100
1097 Self::new_inner( 1101 Self::new_inner(
@@ -1354,10 +1358,9 @@ fn configure(
1354 } 1358 }
1355 }); 1359 });
1356 1360
1357 #[cfg(not(usart_v1))]
1358 r.cr3().modify(|w| { 1361 r.cr3().modify(|w| {
1362 #[cfg(not(usart_v1))]
1359 w.set_onebit(config.assume_noise_free); 1363 w.set_onebit(config.assume_noise_free);
1360 #[cfg(any(usart_v3, usart_v4))]
1361 w.set_hdsel(config.half_duplex); 1364 w.set_hdsel(config.half_duplex);
1362 }); 1365 });
1363 1366