aboutsummaryrefslogtreecommitdiff
path: root/tests/rp/src
diff options
context:
space:
mode:
authorAdam Greig <[email protected]>2023-10-15 00:57:25 +0100
committerAdam Greig <[email protected]>2023-10-15 01:30:12 +0100
commit0621e957a0ddc7010d46b3ea3ddc8b9852bc8333 (patch)
treef6caefe939109e55a73e9141c736d2f6c20f51e8 /tests/rp/src
parent7559f9e5834799b041d899767ef4305dcfdf0181 (diff)
time: Update examples, tests, and other code to use new Timer::after_x convenience methods
Diffstat (limited to 'tests/rp/src')
-rw-r--r--tests/rp/src/bin/bootsel.rs4
-rw-r--r--tests/rp/src/bin/flash.rs4
-rw-r--r--tests/rp/src/bin/float.rs4
-rw-r--r--tests/rp/src/bin/gpio_async.rs12
-rw-r--r--tests/rp/src/bin/pwm.rs44
-rw-r--r--tests/rp/src/bin/uart.rs10
-rw-r--r--tests/rp/src/bin/uart_buffered.rs10
-rw-r--r--tests/rp/src/bin/uart_dma.rs12
8 files changed, 50 insertions, 50 deletions
diff --git a/tests/rp/src/bin/bootsel.rs b/tests/rp/src/bin/bootsel.rs
index df1ed8d2e..4678775eb 100644
--- a/tests/rp/src/bin/bootsel.rs
+++ b/tests/rp/src/bin/bootsel.rs
@@ -5,7 +5,7 @@ teleprobe_meta::target!(b"rpi-pico");
5 5
6use defmt::{assert_eq, *}; 6use defmt::{assert_eq, *};
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_time::{Duration, Timer}; 8use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
10 10
11#[embassy_executor::main] 11#[embassy_executor::main]
@@ -17,7 +17,7 @@ async fn main(_spawner: Spawner) {
17 // defmt RTT header. Reading that header might touch flash memory, which 17 // defmt RTT header. Reading that header might touch flash memory, which
18 // interferes with flash write operations. 18 // interferes with flash write operations.
19 // https://github.com/knurling-rs/defmt/pull/683 19 // https://github.com/knurling-rs/defmt/pull/683
20 Timer::after(Duration::from_millis(10)).await; 20 Timer::after_millis(10).await;
21 21
22 assert_eq!(p.BOOTSEL.is_pressed(), false); 22 assert_eq!(p.BOOTSEL.is_pressed(), false);
23 23
diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs
index 75be2bf06..2d85135de 100644
--- a/tests/rp/src/bin/flash.rs
+++ b/tests/rp/src/bin/flash.rs
@@ -6,7 +6,7 @@ teleprobe_meta::target!(b"rpi-pico");
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE}; 8use embassy_rp::flash::{Async, ERASE_SIZE, FLASH_BASE};
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12const ADDR_OFFSET: u32 = 0x8000; 12const ADDR_OFFSET: u32 = 0x8000;
@@ -20,7 +20,7 @@ async fn main(_spawner: Spawner) {
20 // defmt RTT header. Reading that header might touch flash memory, which 20 // defmt RTT header. Reading that header might touch flash memory, which
21 // interferes with flash write operations. 21 // interferes with flash write operations.
22 // https://github.com/knurling-rs/defmt/pull/683 22 // https://github.com/knurling-rs/defmt/pull/683
23 Timer::after(Duration::from_millis(10)).await; 23 Timer::after_millis(10).await;
24 24
25 let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); 25 let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0);
26 26
diff --git a/tests/rp/src/bin/float.rs b/tests/rp/src/bin/float.rs
index 2874aa910..1e89c10f8 100644
--- a/tests/rp/src/bin/float.rs
+++ b/tests/rp/src/bin/float.rs
@@ -6,7 +6,7 @@ teleprobe_meta::target!(b"rpi-pico");
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::pac; 8use embassy_rp::pac;
9use embassy_time::{Duration, Timer}; 9use embassy_time::Timer;
10use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
11 11
12#[embassy_executor::main] 12#[embassy_executor::main]
@@ -40,7 +40,7 @@ async fn main(_spawner: Spawner) {
40 rad_d + PI_D, 40 rad_d + PI_D,
41 rad_d % PI_D 41 rad_d % PI_D
42 ); 42 );
43 Timer::after(Duration::from_millis(10)).await; 43 Timer::after_millis(10).await;
44 } 44 }
45 45
46 let rom_accesses = pac::BUSCTRL.perfctr(0).read().perfctr(); 46 let rom_accesses = pac::BUSCTRL.perfctr(0).read().perfctr();
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs
index 60c65b7a0..26582f74b 100644
--- a/tests/rp/src/bin/gpio_async.rs
+++ b/tests/rp/src/bin/gpio_async.rs
@@ -27,7 +27,7 @@ async fn main(_spawner: Spawner) {
27 27
28 let set_high_future = async { 28 let set_high_future = async {
29 // Allow time for wait_for_high_future to await wait_for_high(). 29 // Allow time for wait_for_high_future to await wait_for_high().
30 Timer::after(Duration::from_millis(10)).await; 30 Timer::after_millis(10).await;
31 output.set_high(); 31 output.set_high();
32 }; 32 };
33 let wait_for_high_future = async { 33 let wait_for_high_future = async {
@@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) {
47 assert!(input.is_high(), "input was expected to be high"); 47 assert!(input.is_high(), "input was expected to be high");
48 48
49 let set_low_future = async { 49 let set_low_future = async {
50 Timer::after(Duration::from_millis(10)).await; 50 Timer::after_millis(10).await;
51 output.set_low(); 51 output.set_low();
52 }; 52 };
53 let wait_for_low_future = async { 53 let wait_for_low_future = async {
@@ -67,7 +67,7 @@ async fn main(_spawner: Spawner) {
67 assert!(input.is_low(), "input was expected to be low"); 67 assert!(input.is_low(), "input was expected to be low");
68 68
69 let set_high_future = async { 69 let set_high_future = async {
70 Timer::after(Duration::from_millis(10)).await; 70 Timer::after_millis(10).await;
71 output.set_high(); 71 output.set_high();
72 }; 72 };
73 let wait_for_rising_edge_future = async { 73 let wait_for_rising_edge_future = async {
@@ -87,7 +87,7 @@ async fn main(_spawner: Spawner) {
87 assert!(input.is_high(), "input was expected to be high"); 87 assert!(input.is_high(), "input was expected to be high");
88 88
89 let set_low_future = async { 89 let set_low_future = async {
90 Timer::after(Duration::from_millis(10)).await; 90 Timer::after_millis(10).await;
91 output.set_low(); 91 output.set_low();
92 }; 92 };
93 let wait_for_falling_edge_future = async { 93 let wait_for_falling_edge_future = async {
@@ -107,7 +107,7 @@ async fn main(_spawner: Spawner) {
107 assert!(input.is_high(), "input was expected to be high"); 107 assert!(input.is_high(), "input was expected to be high");
108 108
109 let set_low_future = async { 109 let set_low_future = async {
110 Timer::after(Duration::from_millis(10)).await; 110 Timer::after_millis(10).await;
111 output.set_low(); 111 output.set_low();
112 }; 112 };
113 let wait_for_any_edge_future = async { 113 let wait_for_any_edge_future = async {
@@ -127,7 +127,7 @@ async fn main(_spawner: Spawner) {
127 assert!(input.is_low(), "input was expected to be low"); 127 assert!(input.is_low(), "input was expected to be low");
128 128
129 let set_high_future = async { 129 let set_high_future = async {
130 Timer::after(Duration::from_millis(10)).await; 130 Timer::after_millis(10).await;
131 output.set_high(); 131 output.set_high();
132 }; 132 };
133 let wait_for_any_edge_future = async { 133 let wait_for_any_edge_future = async {
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs
index 8c02b8441..8c9db1158 100644
--- a/tests/rp/src/bin/pwm.rs
+++ b/tests/rp/src/bin/pwm.rs
@@ -7,7 +7,7 @@ use defmt::{assert, assert_eq, assert_ne, *};
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::gpio::{Input, Level, Output, Pull}; 8use embassy_rp::gpio::{Input, Level, Output, Pull};
9use embassy_rp::pwm::{Config, InputMode, Pwm}; 9use embassy_rp::pwm::{Config, InputMode, Pwm};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13#[embassy_executor::main] 13#[embassy_executor::main]
@@ -48,13 +48,13 @@ async fn main(_spawner: Spawner) {
48 { 48 {
49 let pin1 = Input::new(&mut p9, Pull::None); 49 let pin1 = Input::new(&mut p9, Pull::None);
50 let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone()); 50 let _pwm = Pwm::new_output_a(&mut p.PWM_CH3, &mut p6, cfg.clone());
51 Timer::after(Duration::from_millis(1)).await; 51 Timer::after_millis(1).await;
52 assert_eq!(pin1.is_low(), invert_a); 52 assert_eq!(pin1.is_low(), invert_a);
53 Timer::after(Duration::from_millis(5)).await; 53 Timer::after_millis(5).await;
54 assert_eq!(pin1.is_high(), invert_a); 54 assert_eq!(pin1.is_high(), invert_a);
55 Timer::after(Duration::from_millis(5)).await; 55 Timer::after_millis(5).await;
56 assert_eq!(pin1.is_low(), invert_a); 56 assert_eq!(pin1.is_low(), invert_a);
57 Timer::after(Duration::from_millis(5)).await; 57 Timer::after_millis(5).await;
58 assert_eq!(pin1.is_high(), invert_a); 58 assert_eq!(pin1.is_high(), invert_a);
59 } 59 }
60 60
@@ -62,13 +62,13 @@ async fn main(_spawner: Spawner) {
62 { 62 {
63 let pin2 = Input::new(&mut p11, Pull::None); 63 let pin2 = Input::new(&mut p11, Pull::None);
64 let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone()); 64 let _pwm = Pwm::new_output_b(&mut p.PWM_CH3, &mut p7, cfg.clone());
65 Timer::after(Duration::from_millis(1)).await; 65 Timer::after_millis(1).await;
66 assert_ne!(pin2.is_low(), invert_a); 66 assert_ne!(pin2.is_low(), invert_a);
67 Timer::after(Duration::from_millis(5)).await; 67 Timer::after_millis(5).await;
68 assert_ne!(pin2.is_high(), invert_a); 68 assert_ne!(pin2.is_high(), invert_a);
69 Timer::after(Duration::from_millis(5)).await; 69 Timer::after_millis(5).await;
70 assert_ne!(pin2.is_low(), invert_a); 70 assert_ne!(pin2.is_low(), invert_a);
71 Timer::after(Duration::from_millis(5)).await; 71 Timer::after_millis(5).await;
72 assert_ne!(pin2.is_high(), invert_a); 72 assert_ne!(pin2.is_high(), invert_a);
73 } 73 }
74 74
@@ -77,16 +77,16 @@ async fn main(_spawner: Spawner) {
77 let pin1 = Input::new(&mut p9, Pull::None); 77 let pin1 = Input::new(&mut p9, Pull::None);
78 let pin2 = Input::new(&mut p11, Pull::None); 78 let pin2 = Input::new(&mut p11, Pull::None);
79 let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone()); 79 let _pwm = Pwm::new_output_ab(&mut p.PWM_CH3, &mut p6, &mut p7, cfg.clone());
80 Timer::after(Duration::from_millis(1)).await; 80 Timer::after_millis(1).await;
81 assert_eq!(pin1.is_low(), invert_a); 81 assert_eq!(pin1.is_low(), invert_a);
82 assert_ne!(pin2.is_low(), invert_a); 82 assert_ne!(pin2.is_low(), invert_a);
83 Timer::after(Duration::from_millis(5)).await; 83 Timer::after_millis(5).await;
84 assert_eq!(pin1.is_high(), invert_a); 84 assert_eq!(pin1.is_high(), invert_a);
85 assert_ne!(pin2.is_high(), invert_a); 85 assert_ne!(pin2.is_high(), invert_a);
86 Timer::after(Duration::from_millis(5)).await; 86 Timer::after_millis(5).await;
87 assert_eq!(pin1.is_low(), invert_a); 87 assert_eq!(pin1.is_low(), invert_a);
88 assert_ne!(pin2.is_low(), invert_a); 88 assert_ne!(pin2.is_low(), invert_a);
89 Timer::after(Duration::from_millis(5)).await; 89 Timer::after_millis(5).await;
90 assert_eq!(pin1.is_high(), invert_a); 90 assert_eq!(pin1.is_high(), invert_a);
91 assert_ne!(pin2.is_high(), invert_a); 91 assert_ne!(pin2.is_high(), invert_a);
92 } 92 }
@@ -97,14 +97,14 @@ async fn main(_spawner: Spawner) {
97 let mut pin2 = Output::new(&mut p11, Level::Low); 97 let mut pin2 = Output::new(&mut p11, Level::Low);
98 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::Level, cfg.clone()); 98 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::Level, cfg.clone());
99 assert_eq!(pwm.counter(), 0); 99 assert_eq!(pwm.counter(), 0);
100 Timer::after(Duration::from_millis(5)).await; 100 Timer::after_millis(5).await;
101 assert_eq!(pwm.counter(), 0); 101 assert_eq!(pwm.counter(), 0);
102 pin2.set_high(); 102 pin2.set_high();
103 Timer::after(Duration::from_millis(1)).await; 103 Timer::after_millis(1).await;
104 pin2.set_low(); 104 pin2.set_low();
105 let ctr = pwm.counter(); 105 let ctr = pwm.counter();
106 assert!(ctr >= 1000); 106 assert!(ctr >= 1000);
107 Timer::after(Duration::from_millis(1)).await; 107 Timer::after_millis(1).await;
108 assert_eq!(pwm.counter(), ctr); 108 assert_eq!(pwm.counter(), ctr);
109 } 109 }
110 110
@@ -113,13 +113,13 @@ async fn main(_spawner: Spawner) {
113 let mut pin2 = Output::new(&mut p11, Level::Low); 113 let mut pin2 = Output::new(&mut p11, Level::Low);
114 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::RisingEdge, cfg.clone()); 114 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::RisingEdge, cfg.clone());
115 assert_eq!(pwm.counter(), 0); 115 assert_eq!(pwm.counter(), 0);
116 Timer::after(Duration::from_millis(5)).await; 116 Timer::after_millis(5).await;
117 assert_eq!(pwm.counter(), 0); 117 assert_eq!(pwm.counter(), 0);
118 pin2.set_high(); 118 pin2.set_high();
119 Timer::after(Duration::from_millis(1)).await; 119 Timer::after_millis(1).await;
120 pin2.set_low(); 120 pin2.set_low();
121 assert_eq!(pwm.counter(), 1); 121 assert_eq!(pwm.counter(), 1);
122 Timer::after(Duration::from_millis(1)).await; 122 Timer::after_millis(1).await;
123 assert_eq!(pwm.counter(), 1); 123 assert_eq!(pwm.counter(), 1);
124 } 124 }
125 125
@@ -128,13 +128,13 @@ async fn main(_spawner: Spawner) {
128 let mut pin2 = Output::new(&mut p11, Level::High); 128 let mut pin2 = Output::new(&mut p11, Level::High);
129 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::FallingEdge, cfg.clone()); 129 let pwm = Pwm::new_input(&mut p.PWM_CH3, &mut p7, InputMode::FallingEdge, cfg.clone());
130 assert_eq!(pwm.counter(), 0); 130 assert_eq!(pwm.counter(), 0);
131 Timer::after(Duration::from_millis(5)).await; 131 Timer::after_millis(5).await;
132 assert_eq!(pwm.counter(), 0); 132 assert_eq!(pwm.counter(), 0);
133 pin2.set_low(); 133 pin2.set_low();
134 Timer::after(Duration::from_millis(1)).await; 134 Timer::after_millis(1).await;
135 pin2.set_high(); 135 pin2.set_high();
136 assert_eq!(pwm.counter(), 1); 136 assert_eq!(pwm.counter(), 1);
137 Timer::after(Duration::from_millis(1)).await; 137 Timer::after_millis(1).await;
138 assert_eq!(pwm.counter(), 1); 138 assert_eq!(pwm.counter(), 1);
139 } 139 }
140 140
diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs
index 00f3e1949..8d351a3a7 100644
--- a/tests/rp/src/bin/uart.rs
+++ b/tests/rp/src/bin/uart.rs
@@ -7,7 +7,7 @@ use defmt::{assert_eq, *};
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_rp::gpio::{Level, Output}; 8use embassy_rp::gpio::{Level, Output};
9use embassy_rp::uart::{Blocking, Config, Error, Instance, Parity, Uart, UartRx}; 9use embassy_rp::uart::{Blocking, Config, Error, Instance, Parity, Uart, UartRx};
10use embassy_time::{Duration, Timer}; 10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
12 12
13fn read<const N: usize>(uart: &mut Uart<'_, impl Instance, Blocking>) -> Result<[u8; N], Error> { 13fn read<const N: usize>(uart: &mut Uart<'_, impl Instance, Blocking>) -> Result<[u8; N], Error> {
@@ -24,14 +24,14 @@ fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Blocking>) -> Resu
24 24
25async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { 25async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
26 pin.set_low(); 26 pin.set_low();
27 Timer::after(Duration::from_millis(1)).await; 27 Timer::after_millis(1).await;
28 for i in 0..8 { 28 for i in 0..8 {
29 if v & (1 << i) == 0 { 29 if v & (1 << i) == 0 {
30 pin.set_low(); 30 pin.set_low();
31 } else { 31 } else {
32 pin.set_high(); 32 pin.set_high();
33 } 33 }
34 Timer::after(Duration::from_millis(1)).await; 34 Timer::after_millis(1).await;
35 } 35 }
36 if let Some(b) = parity { 36 if let Some(b) = parity {
37 if b { 37 if b {
@@ -39,10 +39,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O
39 } else { 39 } else {
40 pin.set_low(); 40 pin.set_low();
41 } 41 }
42 Timer::after(Duration::from_millis(1)).await; 42 Timer::after_millis(1).await;
43 } 43 }
44 pin.set_high(); 44 pin.set_high();
45 Timer::after(Duration::from_millis(1)).await; 45 Timer::after_millis(1).await;
46} 46}
47 47
48#[embassy_executor::main] 48#[embassy_executor::main]
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs
index 6ab7de29e..6a9c910ff 100644
--- a/tests/rp/src/bin/uart_buffered.rs
+++ b/tests/rp/src/bin/uart_buffered.rs
@@ -9,7 +9,7 @@ use embassy_rp::bind_interrupts;
9use embassy_rp::gpio::{Level, Output}; 9use embassy_rp::gpio::{Level, Output};
10use embassy_rp::peripherals::UART0; 10use embassy_rp::peripherals::UART0;
11use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config, Error, Instance, Parity}; 11use embassy_rp::uart::{BufferedInterruptHandler, BufferedUart, BufferedUartRx, Config, Error, Instance, Parity};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use embedded_io_async::{Read, ReadExactError, Write}; 13use embedded_io_async::{Read, ReadExactError, Write};
14use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
15 15
@@ -39,14 +39,14 @@ async fn read1<const N: usize>(uart: &mut BufferedUartRx<'_, impl Instance>) ->
39 39
40async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { 40async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
41 pin.set_low(); 41 pin.set_low();
42 Timer::after(Duration::from_millis(1)).await; 42 Timer::after_millis(1).await;
43 for i in 0..8 { 43 for i in 0..8 {
44 if v & (1 << i) == 0 { 44 if v & (1 << i) == 0 {
45 pin.set_low(); 45 pin.set_low();
46 } else { 46 } else {
47 pin.set_high(); 47 pin.set_high();
48 } 48 }
49 Timer::after(Duration::from_millis(1)).await; 49 Timer::after_millis(1).await;
50 } 50 }
51 if let Some(b) = parity { 51 if let Some(b) = parity {
52 if b { 52 if b {
@@ -54,10 +54,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O
54 } else { 54 } else {
55 pin.set_low(); 55 pin.set_low();
56 } 56 }
57 Timer::after(Duration::from_millis(1)).await; 57 Timer::after_millis(1).await;
58 } 58 }
59 pin.set_high(); 59 pin.set_high();
60 Timer::after(Duration::from_millis(1)).await; 60 Timer::after_millis(1).await;
61} 61}
62 62
63#[embassy_executor::main] 63#[embassy_executor::main]
diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs
index cd4af1ef2..e79fcde60 100644
--- a/tests/rp/src/bin/uart_dma.rs
+++ b/tests/rp/src/bin/uart_dma.rs
@@ -9,7 +9,7 @@ use embassy_rp::bind_interrupts;
9use embassy_rp::gpio::{Level, Output}; 9use embassy_rp::gpio::{Level, Output};
10use embassy_rp::peripherals::UART0; 10use embassy_rp::peripherals::UART0;
11use embassy_rp::uart::{Async, Config, Error, Instance, InterruptHandler, Parity, Uart, UartRx}; 11use embassy_rp::uart::{Async, Config, Error, Instance, InterruptHandler, Parity, Uart, UartRx};
12use embassy_time::{Duration, Timer}; 12use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
14 14
15bind_interrupts!(struct Irqs { 15bind_interrupts!(struct Irqs {
@@ -30,14 +30,14 @@ async fn read1<const N: usize>(uart: &mut UartRx<'_, impl Instance, Async>) -> R
30 30
31async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) { 31async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: Option<bool>) {
32 pin.set_low(); 32 pin.set_low();
33 Timer::after(Duration::from_millis(1)).await; 33 Timer::after_millis(1).await;
34 for i in 0..8 { 34 for i in 0..8 {
35 if v & (1 << i) == 0 { 35 if v & (1 << i) == 0 {
36 pin.set_low(); 36 pin.set_low();
37 } else { 37 } else {
38 pin.set_high(); 38 pin.set_high();
39 } 39 }
40 Timer::after(Duration::from_millis(1)).await; 40 Timer::after_millis(1).await;
41 } 41 }
42 if let Some(b) = parity { 42 if let Some(b) = parity {
43 if b { 43 if b {
@@ -45,10 +45,10 @@ async fn send(pin: &mut Output<'_, impl embassy_rp::gpio::Pin>, v: u8, parity: O
45 } else { 45 } else {
46 pin.set_low(); 46 pin.set_low();
47 } 47 }
48 Timer::after(Duration::from_millis(1)).await; 48 Timer::after_millis(1).await;
49 } 49 }
50 pin.set_high(); 50 pin.set_high();
51 Timer::after(Duration::from_millis(1)).await; 51 Timer::after_millis(1).await;
52} 52}
53 53
54#[embassy_executor::main] 54#[embassy_executor::main]
@@ -105,7 +105,7 @@ async fn main(_spawner: Spawner) {
105 // new data is accepted, latest overrunning byte first 105 // new data is accepted, latest overrunning byte first
106 assert_eq!(read(&mut uart).await, Ok([3])); 106 assert_eq!(read(&mut uart).await, Ok([3]));
107 uart.blocking_write(&[8, 9]).unwrap(); 107 uart.blocking_write(&[8, 9]).unwrap();
108 Timer::after(Duration::from_millis(1)).await; 108 Timer::after_millis(1).await;
109 assert_eq!(read(&mut uart).await, Ok([8, 9])); 109 assert_eq!(read(&mut uart).await, Ok([8, 9]));
110 } 110 }
111 111