aboutsummaryrefslogtreecommitdiff
path: root/examples/src/bin/dma_wrap_transfer.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/src/bin/dma_wrap_transfer.rs')
-rw-r--r--examples/src/bin/dma_wrap_transfer.rs46
1 files changed, 28 insertions, 18 deletions
diff --git a/examples/src/bin/dma_wrap_transfer.rs b/examples/src/bin/dma_wrap_transfer.rs
index 8e9aedbfb..0babf4c20 100644
--- a/examples/src/bin/dma_wrap_transfer.rs
+++ b/examples/src/bin/dma_wrap_transfer.rs
@@ -12,10 +12,9 @@
12 12
13use embassy_executor::Spawner; 13use embassy_executor::Spawner;
14use embassy_mcxa::clocks::config::Div8; 14use embassy_mcxa::clocks::config::Div8;
15use embassy_mcxa::dma::{DmaChannel, DmaCh0InterruptHandler}; 15use embassy_mcxa::dma::{DmaCh0InterruptHandler, DmaChannel};
16use embassy_mcxa::bind_interrupts;
17use embassy_mcxa::lpuart::{Blocking, Config, Lpuart, LpuartTx}; 16use embassy_mcxa::lpuart::{Blocking, Config, Lpuart, LpuartTx};
18use embassy_mcxa::pac; 17use embassy_mcxa::{bind_interrupts, pac};
19use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _}; 18use {defmt_rtt as _, embassy_mcxa as hal, panic_probe as _};
20 19
21// Bind DMA channel 0 interrupt using Embassy-style macro 20// Bind DMA channel 0 interrupt using Embassy-style macro
@@ -93,8 +92,7 @@ async fn main(_spawner: Spawner) {
93 let lpuart = Lpuart::new_blocking(p.LPUART2, p.P2_2, p.P2_3, config).unwrap(); 92 let lpuart = Lpuart::new_blocking(p.LPUART2, p.P2_2, p.P2_3, config).unwrap();
94 let (mut tx, _rx) = lpuart.split(); 93 let (mut tx, _rx) = lpuart.split();
95 94
96 tx.blocking_write(b"EDMA wrap transfer example begin.\r\n\r\n") 95 tx.blocking_write(b"EDMA wrap transfer example begin.\r\n\r\n").unwrap();
97 .unwrap();
98 96
99 // Initialize buffers 97 // Initialize buffers
100 unsafe { 98 unsafe {
@@ -127,18 +125,25 @@ async fn main(_spawner: Spawner) {
127 125
128 // Reset channel state 126 // Reset channel state
129 t.ch_csr().write(|w| { 127 t.ch_csr().write(|w| {
130 w.erq().disable() 128 w.erq()
131 .earq().disable() 129 .disable()
132 .eei().no_error() 130 .earq()
133 .ebw().disable() 131 .disable()
134 .done().clear_bit_by_one() 132 .eei()
133 .no_error()
134 .ebw()
135 .disable()
136 .done()
137 .clear_bit_by_one()
135 }); 138 });
136 t.ch_es().write(|w| w.bits(0)); 139 t.ch_es().write(|w| w.bits(0));
137 t.ch_int().write(|w| w.int().clear_bit_by_one()); 140 t.ch_int().write(|w| w.int().clear_bit_by_one());
138 141
139 // Source/destination addresses 142 // Source/destination addresses
140 t.tcd_saddr().write(|w| w.saddr().bits(core::ptr::addr_of!(SRC.0) as u32)); 143 t.tcd_saddr()
141 t.tcd_daddr().write(|w| w.daddr().bits(core::ptr::addr_of_mut!(DST) as u32)); 144 .write(|w| w.saddr().bits(core::ptr::addr_of!(SRC.0) as u32));
145 t.tcd_daddr()
146 .write(|w| w.daddr().bits(core::ptr::addr_of_mut!(DST) as u32));
142 147
143 // Offsets: both increment by 4 bytes 148 // Offsets: both increment by 4 bytes
144 t.tcd_soff().write(|w| w.soff().bits(4)); 149 t.tcd_soff().write(|w| w.soff().bits(4));
@@ -147,10 +152,14 @@ async fn main(_spawner: Spawner) {
147 // Attributes: 32-bit transfers (size = 2) 152 // Attributes: 32-bit transfers (size = 2)
148 // SMOD = 4 (2^4 = 16 byte modulo for source), DMOD = 0 (disabled) 153 // SMOD = 4 (2^4 = 16 byte modulo for source), DMOD = 0 (disabled)
149 t.tcd_attr().write(|w| { 154 t.tcd_attr().write(|w| {
150 w.ssize().bits(2) 155 w.ssize()
151 .dsize().bits(2) 156 .bits(2)
152 .smod().bits(4) // Source modulo: 2^4 = 16 bytes 157 .dsize()
153 .dmod().bits(0) // Dest modulo: disabled 158 .bits(2)
159 .smod()
160 .bits(4) // Source modulo: 2^4 = 16 bytes
161 .dmod()
162 .bits(0) // Dest modulo: disabled
154 }); 163 });
155 164
156 // Transfer 32 bytes total in one minor loop 165 // Transfer 32 bytes total in one minor loop
@@ -179,7 +188,9 @@ async fn main(_spawner: Spawner) {
179 while !dma_ch0.is_done() { 188 while !dma_ch0.is_done() {
180 cortex_m::asm::nop(); 189 cortex_m::asm::nop();
181 } 190 }
182 unsafe { dma_ch0.clear_done(); } 191 unsafe {
192 dma_ch0.clear_done();
193 }
183 194
184 tx.blocking_write(b"\r\nEDMA wrap transfer example finish.\r\n\r\n") 195 tx.blocking_write(b"\r\nEDMA wrap transfer example finish.\r\n\r\n")
185 .unwrap(); 196 .unwrap();
@@ -211,4 +222,3 @@ async fn main(_spawner: Spawner) {
211 cortex_m::asm::wfe(); 222 cortex_m::asm::wfe();
212 } 223 }
213} 224}
214