diff --git a/flashloader/src/main.rs b/flashloader/src/main.rs index 65185f5..68210dd 100644 --- a/flashloader/src/main.rs +++ b/flashloader/src/main.rs @@ -180,7 +180,7 @@ mod app { &mut cx.device.sysconfig, &clocks, ); - let (tx, mut rx, _) = uart0.split_with_irq(); + let (tx, rx) = uart0.split(); let verif_reporter = VerificationReportCreator::new(0).unwrap(); @@ -193,6 +193,7 @@ mod app { Mono::start(cx.core.SYST, clocks.sysclk().raw()); CLOCKS.set(clocks).unwrap(); + let mut rx = rx.to_rx_with_irq(); let mut rx_context = IrqContextTimeoutOrMaxSize::new(MAX_TC_FRAME_SIZE); rx.read_fixed_len_or_timeout_based_using_irq(&mut rx_context) .expect("initiating UART RX failed"); diff --git a/va416xx-hal/src/uart.rs b/va416xx-hal/src/uart.rs index 31c4f1d..df5d3e6 100644 --- a/va416xx-hal/src/uart.rs +++ b/va416xx-hal/src/uart.rs @@ -569,22 +569,6 @@ impl, RxPinInst: RxPin, UartInstanc self } - /// If the IRQ capabilities of the peripheral are used, the UART needs to be converted - /// with this function. Currently, IRQ abstractions are only implemented for the RX part - /// of the UART, so this function will release a TX and RX handle as well as the pin - /// instances. - pub fn split_with_irq( - self, - ) -> ( - Tx, - RxWithIrq, - (TxPinInst, RxPinInst), - ) { - let (inner, pins) = self.downgrade_internal(); - let (tx, rx) = inner.split(); - (tx, RxWithIrq(rx), pins) - } - delegate::delegate! { to self.inner { #[inline] @@ -611,15 +595,6 @@ impl, RxPinInst: RxPin, UartInstanc } } - fn downgrade_internal(self) -> (UartBase, (TxPinInst, RxPinInst)) { - let base = UartBase { - uart: self.inner.uart, - tx: self.inner.tx, - rx: self.inner.rx, - }; - (base, self.pins) - } - pub fn downgrade(self) -> UartBase { UartBase { uart: self.inner.uart, @@ -658,6 +633,10 @@ impl Rx { self.0.enable().modify(|_, w| w.rxenable().clear_bit()); } + pub fn to_rx_with_irq(self) -> RxWithIrq { + RxWithIrq(self) + } + pub fn release(self) -> Uart { self.0 } @@ -709,7 +688,9 @@ pub enum IrqError { Uart(IrqUartError), } -// Serial receiver, using interrupts to offload reading to the hardware. +/// Serial receiver, using interrupts to offload reading to the hardware. +/// +/// You can use [Rx::to_rx_with_irq] to convert a normal [Rx] structure into this structure. pub struct RxWithIrq(Rx); impl RxWithIrq {