diff options
| author | Mathias <[email protected]> | 2024-07-17 11:25:03 +0200 |
|---|---|---|
| committer | Mathias <[email protected]> | 2024-07-17 11:25:03 +0200 |
| commit | f733071908ced05bc006b43e1383336290faafdc (patch) | |
| tree | 3d930b0de2022fea2eff2f105b67a43f7b18ef3d /embassy-rp/src/uart/buffered.rs | |
| parent | e54c753537b4b12c3d2fd03ad8e8ba9eaaded06e (diff) | |
Add split_ref fn to uart, allowing a mutable reference split into RX & TX handles. Also change order of RX and TX handles in split fn, to streamline with other HALs
Diffstat (limited to 'embassy-rp/src/uart/buffered.rs')
| -rw-r--r-- | embassy-rp/src/uart/buffered.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/embassy-rp/src/uart/buffered.rs b/embassy-rp/src/uart/buffered.rs index cfbd82ccf..152a432c9 100644 --- a/embassy-rp/src/uart/buffered.rs +++ b/embassy-rp/src/uart/buffered.rs | |||
| @@ -163,9 +163,21 @@ impl<'d, T: Instance> BufferedUart<'d, T> { | |||
| 163 | self.tx.send_break(bits).await | 163 | self.tx.send_break(bits).await |
| 164 | } | 164 | } |
| 165 | 165 | ||
| 166 | /// sets baudrate on runtime | ||
| 167 | pub fn set_baudrate(&mut self, baudrate: u32) { | ||
| 168 | super::Uart::<'d, T, Async>::set_baudrate_inner(baudrate); | ||
| 169 | } | ||
| 170 | |||
| 166 | /// Split into separate RX and TX handles. | 171 | /// Split into separate RX and TX handles. |
| 167 | pub fn split(self) -> (BufferedUartRx<'d, T>, BufferedUartTx<'d, T>) { | 172 | pub fn split(self) -> (BufferedUartTx<'d, T>, BufferedUartRx<'d, T>) { |
| 168 | (self.rx, self.tx) | 173 | (self.tx, self.rx) |
| 174 | } | ||
| 175 | |||
| 176 | /// Split the Uart into a transmitter and receiver by mutable reference, | ||
| 177 | /// which is particularly useful when having two tasks correlating to | ||
| 178 | /// transmitting and receiving. | ||
| 179 | pub fn split_ref(&mut self) -> (&mut BufferedUartTx<'d, T>, &mut BufferedUartRx<'d, T>) { | ||
| 180 | (&mut self.tx, &mut self.rx) | ||
| 169 | } | 181 | } |
| 170 | } | 182 | } |
| 171 | 183 | ||
