aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-06-19 22:38:27 +0200
committerDario Nieuwenhuis <[email protected]>2023-06-19 22:38:27 +0200
commit990dd5e5db7134193259fcf350c0928b9a64df97 (patch)
tree7da94d4618b61863b23c4e40d013b5775bf610cf
parent3c70f799a28f5f28d84fa8ee8b4b232f5e9aad82 (diff)
tests/stm32: do multiple transfers to catch more bugs.
-rw-r--r--tests/stm32/src/bin/usart_dma.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/tests/stm32/src/bin/usart_dma.rs b/tests/stm32/src/bin/usart_dma.rs
index 50dd2893e..c34d9574b 100644
--- a/tests/stm32/src/bin/usart_dma.rs
+++ b/tests/stm32/src/bin/usart_dma.rs
@@ -69,24 +69,27 @@ async fn main(_spawner: Spawner) {
69 const LEN: usize = 128; 69 const LEN: usize = 128;
70 let mut tx_buf = [0; LEN]; 70 let mut tx_buf = [0; LEN];
71 let mut rx_buf = [0; LEN]; 71 let mut rx_buf = [0; LEN];
72 for i in 0..LEN {
73 tx_buf[i] = i as u8;
74 }
75 72
76 let (mut tx, mut rx) = usart.split(); 73 let (mut tx, mut rx) = usart.split();
77 74
78 let tx_fut = async { 75 for n in 0..42 {
79 tx.write(&tx_buf).await.unwrap(); 76 for i in 0..LEN {
80 }; 77 tx_buf[i] = (i ^ n) as u8;
81 let rx_fut = async { 78 }
82 rx.read(&mut rx_buf).await.unwrap(); 79
83 }; 80 let tx_fut = async {
81 tx.write(&tx_buf).await.unwrap();
82 };
83 let rx_fut = async {
84 rx.read(&mut rx_buf).await.unwrap();
85 };
84 86
85 // note: rx needs to be polled first, to workaround this bug: 87 // note: rx needs to be polled first, to workaround this bug:
86 // https://github.com/embassy-rs/embassy/issues/1426 88 // https://github.com/embassy-rs/embassy/issues/1426
87 join(rx_fut, tx_fut).await; 89 join(rx_fut, tx_fut).await;
88 90
89 assert_eq!(tx_buf, rx_buf); 91 assert_eq!(tx_buf, rx_buf);
92 }
90 93
91 info!("Test OK"); 94 info!("Test OK");
92 cortex_m::asm::bkpt(); 95 cortex_m::asm::bkpt();