aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMathias <[email protected]>2022-08-18 21:14:57 +0200
committerMathias <[email protected]>2022-08-18 21:20:47 +0200
commitdebff0980d6a4c5527ebdaea6f91f32b63477bc5 (patch)
tree88517f5001f2bbb05f472da2cd19064d3c8200be
parent1d49b3444f2bd3e049f19a72da63804192ee0402 (diff)
Don't increment read address in DMA copy from peripherals
-rw-r--r--embassy-rp/src/dma.rs12
-rw-r--r--embassy-rp/src/uart.rs14
2 files changed, 16 insertions, 10 deletions
diff --git a/embassy-rp/src/dma.rs b/embassy-rp/src/dma.rs
index cfaa6dd34..8cf8c394d 100644
--- a/embassy-rp/src/dma.rs
+++ b/embassy-rp/src/dma.rs
@@ -10,7 +10,11 @@ use pac::dma::vals::DataSize;
10use crate::pac::dma::vals; 10use crate::pac::dma::vals;
11use crate::{pac, peripherals}; 11use crate::{pac, peripherals};
12 12
13pub(crate) fn read<'a, C: Channel, W: Word>(ch: impl Peripheral<P = C> + 'a, from: *const W, to: *mut [W]) -> Transfer<'a, C> { 13pub(crate) fn read<'a, C: Channel, W: Word>(
14 ch: impl Peripheral<P = C> + 'a,
15 from: *const W,
16 to: *mut [W],
17) -> Transfer<'a, C> {
14 let (ptr, len) = crate::dma::slice_ptr_parts_mut(to); 18 let (ptr, len) = crate::dma::slice_ptr_parts_mut(to);
15 copy(ch, from as *const u32, ptr as *mut u32, len, W::size()) 19 copy(ch, from as *const u32, ptr as *mut u32, len, W::size())
16} 20}
@@ -44,7 +48,7 @@ fn copy<'a, C: Channel>(
44 48
45 p.ctrl_trig().write(|w| { 49 p.ctrl_trig().write(|w| {
46 w.set_data_size(data_size); 50 w.set_data_size(data_size);
47 w.set_incr_read(true); 51 w.set_incr_read(false);
48 w.set_incr_write(true); 52 w.set_incr_write(true);
49 w.set_chain_to(ch.number()); 53 w.set_chain_to(ch.number());
50 w.set_en(true); 54 w.set_en(true);
@@ -136,7 +140,9 @@ pub trait Channel: Peripheral<P = Self> + sealed::Channel + Into<AnyChannel> + S
136 STATE.channels[self.number() as usize].waker.register(waker); 140 STATE.channels[self.number() as usize].waker.register(waker);
137 } 141 }
138 142
139 fn on_irq() {} 143 fn on_irq() {
144 // FIXME:
145 }
140 146
141 fn degrade(self) -> AnyChannel { 147 fn degrade(self) -> AnyChannel {
142 AnyChannel { number: self.number() } 148 AnyChannel { number: self.number() }
diff --git a/embassy-rp/src/uart.rs b/embassy-rp/src/uart.rs
index 09cadf030..03623a9f8 100644
--- a/embassy-rp/src/uart.rs
+++ b/embassy-rp/src/uart.rs
@@ -441,15 +441,15 @@ mod eh1 {
441 } 441 }
442 } 442 }
443 443
444 impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for Uart<'d, T> { 444 impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::ErrorType for Uart<'d, T, M> {
445 type Error = Error; 445 type Error = Error;
446 } 446 }
447 447
448 impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UartTx<'d, T> { 448 impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::ErrorType for UartTx<'d, T, M> {
449 type Error = Error; 449 type Error = Error;
450 } 450 }
451 451
452 impl<'d, T: Instance> embedded_hal_1::serial::ErrorType for UartRx<'d, T> { 452 impl<'d, T: Instance, M: Mode> embedded_hal_1::serial::ErrorType for UartRx<'d, T, M> {
453 type Error = Error; 453 type Error = Error;
454 } 454 }
455} 455}
@@ -458,7 +458,7 @@ cfg_if::cfg_if! {
458 if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] { 458 if #[cfg(all(feature = "unstable-traits", feature = "nightly", feature = "_todo_embedded_hal_serial"))] {
459 use core::future::Future; 459 use core::future::Future;
460 460
461 impl<'d, T: Instance> embedded_hal_async::serial::Write for UartTx<'d, T> 461 impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for UartTx<'d, T, M>
462 { 462 {
463 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 463 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
464 464
@@ -473,7 +473,7 @@ cfg_if::cfg_if! {
473 } 473 }
474 } 474 }
475 475
476 impl<'d, T: Instance> embedded_hal_async::serial::Read for UartRx<'d, T> 476 impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for UartRx<'d, T, M>
477 { 477 {
478 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 478 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
479 479
@@ -482,7 +482,7 @@ cfg_if::cfg_if! {
482 } 482 }
483 } 483 }
484 484
485 impl<'d, T: Instance> embedded_hal_async::serial::Write for Uart<'d, T> 485 impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Write for Uart<'d, T, M>
486 { 486 {
487 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 487 type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
488 488
@@ -497,7 +497,7 @@ cfg_if::cfg_if! {
497 } 497 }
498 } 498 }
499 499
500 impl<'d, T: Instance> embedded_hal_async::serial::Read for Uart<'d, T> 500 impl<'d, T: Instance, M: Mode> embedded_hal_async::serial::Read for Uart<'d, T, M>
501 { 501 {
502 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; 502 type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a;
503 503