aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpennae <[email protected]>2023-04-30 09:30:10 +0200
committerpennae <[email protected]>2023-05-01 15:32:58 +0200
commitbe66e0f7cec742d580a224f12a79b2ab2ca78e37 (patch)
treeb83755293b52a8316873598191436b2b666fae10
parent861f49cfd4380d89aa13d507234a97b30a84473d (diff)
rp/uart: make dma multicore-safe
running rx and tx on different cores could lead to hangs if the dmacr register modifys run concurrently. this is bad.
-rw-r--r--embassy-rp/src/uart/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/embassy-rp/src/uart/mod.rs b/embassy-rp/src/uart/mod.rs
index 0b323978d..f198afe2f 100644
--- a/embassy-rp/src/uart/mod.rs
+++ b/embassy-rp/src/uart/mod.rs
@@ -206,7 +206,7 @@ impl<'d, T: Instance> UartTx<'d, T, Async> {
206 pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error> { 206 pub async fn write(&mut self, buffer: &[u8]) -> Result<(), Error> {
207 let ch = self.tx_dma.as_mut().unwrap(); 207 let ch = self.tx_dma.as_mut().unwrap();
208 let transfer = unsafe { 208 let transfer = unsafe {
209 T::regs().uartdmacr().modify(|reg| { 209 T::regs().uartdmacr().write_set(|reg| {
210 reg.set_txdmae(true); 210 reg.set_txdmae(true);
211 }); 211 });
212 // If we don't assign future to a variable, the data register pointer 212 // If we don't assign future to a variable, the data register pointer
@@ -296,7 +296,7 @@ impl<'d, T: Instance> UartRx<'d, T, Async> {
296 pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> { 296 pub async fn read(&mut self, buffer: &mut [u8]) -> Result<(), Error> {
297 let ch = self.rx_dma.as_mut().unwrap(); 297 let ch = self.rx_dma.as_mut().unwrap();
298 let transfer = unsafe { 298 let transfer = unsafe {
299 T::regs().uartdmacr().modify(|reg| { 299 T::regs().uartdmacr().write_set(|reg| {
300 reg.set_rxdmae(true); 300 reg.set_rxdmae(true);
301 }); 301 });
302 // If we don't assign future to a variable, the data register pointer 302 // If we don't assign future to a variable, the data register pointer