add split_ref for stm32 uart

This commit is contained in:
Kenneth Knudsen 2024-11-04 15:08:57 +01:00
parent 3d8e987bf3
commit aa453caa79
2 changed files with 14 additions and 0 deletions

View File

@ -396,6 +396,13 @@ impl<'d> BufferedUart<'d> {
(self.tx, self.rx)
}
/// Split the Uart into a transmitter and receiver by mutable reference,
/// which is particularly useful when having two tasks correlating to
/// transmitting and receiving.
pub fn split_ref(&mut self) -> (&mut BufferedUartTx<'d>, &mut BufferedUartRx<'d>) {
(&mut self.tx, &mut self.rx)
}
/// Reconfigure the driver
pub fn set_config(&mut self, config: &Config) -> Result<(), ConfigError> {
reconfigure(self.rx.info, self.rx.kernel_clock, config)?;

View File

@ -1440,6 +1440,13 @@ impl<'d, M: Mode> Uart<'d, M> {
(self.tx, self.rx)
}
/// Split the Uart into a transmitter and receiver by mutable reference,
/// which is particularly useful when having two tasks correlating to
/// transmitting and receiving.
pub fn split_ref(&mut self) -> (&mut UartTx<'d, M>, &mut UartRx<'d, M>) {
(&mut self.tx, &mut self.rx)
}
/// Send break character
pub fn send_break(&self) {
self.tx.send_break();