diff options
| author | Jacob Davis-Hansson <[email protected]> | 2023-04-18 17:44:19 +0200 |
|---|---|---|
| committer | Jacob Davis-Hansson <[email protected]> | 2023-04-18 17:44:19 +0200 |
| commit | 21ea98810aed1a4a820ac8cc357d66821f80c3fc (patch) | |
| tree | 056947dc1ae048316938536dd9a5a40f3914435a | |
| parent | 81f10e136a95c33f98f5fa06ac3996bee97e66d3 (diff) | |
Pass rx pin to right init arg
| -rw-r--r-- | embassy-rp/src/uart/mod.rs | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs index f7a4c5a60..f9e30a78b 100644 --- a/embassy-rp/src/uart/mod.rs +++ b/embassy-rp/src/uart/mod.rs | |||
| @@ -5,8 +5,8 @@ use embassy_hal_common::{into_ref, PeripheralRef}; | |||
| 5 | use crate::dma::{AnyChannel, Channel}; | 5 | use crate::dma::{AnyChannel, Channel}; |
| 6 | use crate::gpio::sealed::Pin; | 6 | use crate::gpio::sealed::Pin; |
| 7 | use crate::gpio::AnyPin; | 7 | use crate::gpio::AnyPin; |
| 8 | use crate::{pac, peripherals, Peripheral}; | ||
| 9 | use crate::pac::io::vals::{Inover, Outover}; | 8 | use crate::pac::io::vals::{Inover, Outover}; |
| 9 | use crate::{pac, peripherals, Peripheral}; | ||
| 10 | 10 | ||
| 11 | #[cfg(feature = "nightly")] | 11 | #[cfg(feature = "nightly")] |
| 12 | mod buffered; | 12 | mod buffered; |
| @@ -180,7 +180,7 @@ impl<'d, T: Instance> UartTx<'d, T, Async> { | |||
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | impl<'d, T: Instance, M: Mode> UartRx<'d, T, M> { | 182 | impl<'d, T: Instance, M: Mode> UartRx<'d, T, M> { |
| 183 | /// Create a new DMA-enabled UART which can only send data | 183 | /// Create a new DMA-enabled UART which can only recieve data |
| 184 | pub fn new( | 184 | pub fn new( |
| 185 | _uart: impl Peripheral<P = T> + 'd, | 185 | _uart: impl Peripheral<P = T> + 'd, |
| 186 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, | 186 | rx: impl Peripheral<P = impl RxPin<T>> + 'd, |
| @@ -188,7 +188,7 @@ impl<'d, T: Instance, M: Mode> UartRx<'d, T, M> { | |||
| 188 | config: Config, | 188 | config: Config, |
| 189 | ) -> Self { | 189 | ) -> Self { |
| 190 | into_ref!(rx, rx_dma); | 190 | into_ref!(rx, rx_dma); |
| 191 | Uart::<T, M>::init(Some(rx.map_into()), None, None, None, config); | 191 | Uart::<T, M>::init(None, Some(rx.map_into()), None, None, config); |
| 192 | Self::new_inner(Some(rx_dma.map_into())) | 192 | Self::new_inner(Some(rx_dma.map_into())) |
| 193 | } | 193 | } |
| 194 | 194 | ||
| @@ -396,28 +396,44 @@ impl<'d, T: Instance + 'd, M: Mode> Uart<'d, T, M> { | |||
| 396 | if let Some(pin) = &tx { | 396 | if let Some(pin) = &tx { |
| 397 | pin.io().ctrl().write(|w| { | 397 | pin.io().ctrl().write(|w| { |
| 398 | w.set_funcsel(2); | 398 | w.set_funcsel(2); |
| 399 | w.set_outover(if config.invert_tx { Outover::INVERT } else { Outover::NORMAL }); | 399 | w.set_outover(if config.invert_tx { |
| 400 | Outover::INVERT | ||
| 401 | } else { | ||
| 402 | Outover::NORMAL | ||
| 403 | }); | ||
| 400 | }); | 404 | }); |
| 401 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 405 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 402 | } | 406 | } |
| 403 | if let Some(pin) = &rx { | 407 | if let Some(pin) = &rx { |
| 404 | pin.io().ctrl().write(|w| { | 408 | pin.io().ctrl().write(|w| { |
| 405 | w.set_funcsel(2); | 409 | w.set_funcsel(2); |
| 406 | w.set_inover(if config.invert_rx { Inover::INVERT } else { Inover::NORMAL }); | 410 | w.set_inover(if config.invert_rx { |
| 411 | Inover::INVERT | ||
| 412 | } else { | ||
| 413 | Inover::NORMAL | ||
| 414 | }); | ||
| 407 | }); | 415 | }); |
| 408 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 416 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 409 | } | 417 | } |
| 410 | if let Some(pin) = &cts { | 418 | if let Some(pin) = &cts { |
| 411 | pin.io().ctrl().write(|w| { | 419 | pin.io().ctrl().write(|w| { |
| 412 | w.set_funcsel(2); | 420 | w.set_funcsel(2); |
| 413 | w.set_inover(if config.invert_cts { Inover::INVERT } else { Inover::NORMAL }); | 421 | w.set_inover(if config.invert_cts { |
| 422 | Inover::INVERT | ||
| 423 | } else { | ||
| 424 | Inover::NORMAL | ||
| 425 | }); | ||
| 414 | }); | 426 | }); |
| 415 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 427 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 416 | } | 428 | } |
| 417 | if let Some(pin) = &rts { | 429 | if let Some(pin) = &rts { |
| 418 | pin.io().ctrl().write(|w| { | 430 | pin.io().ctrl().write(|w| { |
| 419 | w.set_funcsel(2); | 431 | w.set_funcsel(2); |
| 420 | w.set_outover(if config.invert_rts { Outover::INVERT } else { Outover::NORMAL }); | 432 | w.set_outover(if config.invert_rts { |
| 433 | Outover::INVERT | ||
| 434 | } else { | ||
| 435 | Outover::NORMAL | ||
| 436 | }); | ||
| 421 | }); | 437 | }); |
| 422 | pin.pad_ctrl().write(|w| w.set_ie(true)); | 438 | pin.pad_ctrl().write(|w| w.set_ie(true)); |
| 423 | } | 439 | } |
