aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/usart/buffered.rs4
-rw-r--r--embassy-stm32/src/usart/mod.rs18
2 files changed, 13 insertions, 9 deletions
diff --git a/embassy-stm32/src/usart/buffered.rs b/embassy-stm32/src/usart/buffered.rs
index 86f56eb7c..4fbe33b2e 100644
--- a/embassy-stm32/src/usart/buffered.rs
+++ b/embassy-stm32/src/usart/buffered.rs
@@ -210,7 +210,7 @@ impl<'d> BufferedUart<'d> {
210 ) -> Result<Self, ConfigError> { 210 ) -> Result<Self, ConfigError> {
211 Self::new_inner( 211 Self::new_inner(
212 peri, 212 peri,
213 new_pin!(rx, AfType::input(Pull::None)), 213 new_pin!(rx, AfType::input(config.rx_pull)),
214 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)), 214 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
215 None, 215 None,
216 None, 216 None,
@@ -260,7 +260,7 @@ impl<'d> BufferedUart<'d> {
260 ) -> Result<Self, ConfigError> { 260 ) -> Result<Self, ConfigError> {
261 Self::new_inner( 261 Self::new_inner(
262 peri, 262 peri,
263 new_pin!(rx, AfType::input(Pull::None)), 263 new_pin!(rx, AfType::input(config.rx_pull)),
264 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)), 264 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
265 None, 265 None,
266 None, 266 None,
diff --git a/embassy-stm32/src/usart/mod.rs b/embassy-stm32/src/usart/mod.rs
index e7f2f890a..5c96e202d 100644
--- a/embassy-stm32/src/usart/mod.rs
+++ b/embassy-stm32/src/usart/mod.rs
@@ -167,6 +167,9 @@ pub struct Config {
167 #[cfg(any(usart_v3, usart_v4))] 167 #[cfg(any(usart_v3, usart_v4))]
168 pub invert_rx: bool, 168 pub invert_rx: bool,
169 169
170 /// Set the pull configuration for the RX pin.
171 pub rx_pull: Pull,
172
170 // private: set by new_half_duplex, not by the user. 173 // private: set by new_half_duplex, not by the user.
171 half_duplex: bool, 174 half_duplex: bool,
172} 175}
@@ -175,7 +178,7 @@ impl Config {
175 fn tx_af(&self) -> AfType { 178 fn tx_af(&self) -> AfType {
176 #[cfg(any(usart_v3, usart_v4))] 179 #[cfg(any(usart_v3, usart_v4))]
177 if self.swap_rx_tx { 180 if self.swap_rx_tx {
178 return AfType::input(Pull::None); 181 return AfType::input(self.rx_pull);
179 }; 182 };
180 AfType::output(OutputType::PushPull, Speed::Medium) 183 AfType::output(OutputType::PushPull, Speed::Medium)
181 } 184 }
@@ -185,7 +188,7 @@ impl Config {
185 if self.swap_rx_tx { 188 if self.swap_rx_tx {
186 return AfType::output(OutputType::PushPull, Speed::Medium); 189 return AfType::output(OutputType::PushPull, Speed::Medium);
187 }; 190 };
188 AfType::input(Pull::None) 191 AfType::input(self.rx_pull)
189 } 192 }
190} 193}
191 194
@@ -206,6 +209,7 @@ impl Default for Config {
206 invert_tx: false, 209 invert_tx: false,
207 #[cfg(any(usart_v3, usart_v4))] 210 #[cfg(any(usart_v3, usart_v4))]
208 invert_rx: false, 211 invert_rx: false,
212 rx_pull: Pull::None,
209 half_duplex: false, 213 half_duplex: false,
210 } 214 }
211 } 215 }
@@ -448,7 +452,7 @@ impl<'d> UartTx<'d, Blocking> {
448 Self::new_inner( 452 Self::new_inner(
449 peri, 453 peri,
450 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)), 454 new_pin!(tx, AfType::output(OutputType::PushPull, Speed::Medium)),
451 new_pin!(cts, AfType::input(Pull::None)), 455 new_pin!(cts, AfType::input(config.rx_pull)),
452 None, 456 None,
453 config, 457 config,
454 ) 458 )
@@ -567,7 +571,7 @@ impl<'d> UartRx<'d, Async> {
567 ) -> Result<Self, ConfigError> { 571 ) -> Result<Self, ConfigError> {
568 Self::new_inner( 572 Self::new_inner(
569 peri, 573 peri,
570 new_pin!(rx, AfType::input(Pull::None)), 574 new_pin!(rx, AfType::input(config.rx_pull)),
571 None, 575 None,
572 new_dma!(rx_dma), 576 new_dma!(rx_dma),
573 config, 577 config,
@@ -585,7 +589,7 @@ impl<'d> UartRx<'d, Async> {
585 ) -> Result<Self, ConfigError> { 589 ) -> Result<Self, ConfigError> {
586 Self::new_inner( 590 Self::new_inner(
587 peri, 591 peri,
588 new_pin!(rx, AfType::input(Pull::None)), 592 new_pin!(rx, AfType::input(config.rx_pull)),
589 new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)), 593 new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
590 new_dma!(rx_dma), 594 new_dma!(rx_dma),
591 config, 595 config,
@@ -815,7 +819,7 @@ impl<'d> UartRx<'d, Blocking> {
815 rx: impl Peripheral<P = impl RxPin<T>> + 'd, 819 rx: impl Peripheral<P = impl RxPin<T>> + 'd,
816 config: Config, 820 config: Config,
817 ) -> Result<Self, ConfigError> { 821 ) -> Result<Self, ConfigError> {
818 Self::new_inner(peri, new_pin!(rx, AfType::input(Pull::None)), None, None, config) 822 Self::new_inner(peri, new_pin!(rx, AfType::input(config.rx_pull)), None, None, config)
819 } 823 }
820 824
821 /// Create a new rx-only UART with a request-to-send pin 825 /// Create a new rx-only UART with a request-to-send pin
@@ -827,7 +831,7 @@ impl<'d> UartRx<'d, Blocking> {
827 ) -> Result<Self, ConfigError> { 831 ) -> Result<Self, ConfigError> {
828 Self::new_inner( 832 Self::new_inner(
829 peri, 833 peri,
830 new_pin!(rx, AfType::input(Pull::None)), 834 new_pin!(rx, AfType::input(config.rx_pull)),
831 new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)), 835 new_pin!(rts, AfType::output(OutputType::PushPull, Speed::Medium)),
832 None, 836 None,
833 config, 837 config,