aboutsummaryrefslogtreecommitdiff
path: root/tests/rp/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-03-26 16:01:37 +0100
committerDario Nieuwenhuis <[email protected]>2025-03-27 15:18:06 +0100
commitd41eeeae79388f219bf6a84e2f7bde9f6b532516 (patch)
tree678b6fc732216e529dc38e6f65b72a309917ac32 /tests/rp/src
parent9edf5b7f049f95742b60b041e4443967d8a6b708 (diff)
Remove Peripheral trait, rename PeripheralRef->Peri.
Diffstat (limited to 'tests/rp/src')
-rw-r--r--tests/rp/src/bin/adc.rs61
-rw-r--r--tests/rp/src/bin/bootsel.rs5
-rw-r--r--tests/rp/src/bin/gpio.rs40
-rw-r--r--tests/rp/src/bin/gpio_async.rs24
-rw-r--r--tests/rp/src/bin/gpio_multicore.rs5
-rw-r--r--tests/rp/src/bin/pwm.rs50
-rw-r--r--tests/rp/src/bin/uart.rs14
-rw-r--r--tests/rp/src/bin/uart_buffered.rs38
-rw-r--r--tests/rp/src/bin/uart_dma.rs38
9 files changed, 161 insertions, 114 deletions
diff --git a/tests/rp/src/bin/adc.rs b/tests/rp/src/bin/adc.rs
index 87e9709cc..c2175bc03 100644
--- a/tests/rp/src/bin/adc.rs
+++ b/tests/rp/src/bin/adc.rs
@@ -30,12 +30,12 @@ async fn main(_spawner: Spawner) {
30 30
31 { 31 {
32 { 32 {
33 let mut p = Channel::new_pin(&mut a, Pull::Down); 33 let mut p = Channel::new_pin(a.reborrow(), Pull::Down);
34 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); 34 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
35 defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000); 35 defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000);
36 } 36 }
37 { 37 {
38 let mut p = Channel::new_pin(&mut a, Pull::Up); 38 let mut p = Channel::new_pin(a.reborrow(), Pull::Up);
39 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); 39 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
40 defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000); 40 defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000);
41 } 41 }
@@ -43,21 +43,21 @@ async fn main(_spawner: Spawner) {
43 // not bothering with async reads from now on 43 // not bothering with async reads from now on
44 { 44 {
45 { 45 {
46 let mut p = Channel::new_pin(&mut b, Pull::Down); 46 let mut p = Channel::new_pin(b.reborrow(), Pull::Down);
47 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); 47 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
48 } 48 }
49 { 49 {
50 let mut p = Channel::new_pin(&mut b, Pull::Up); 50 let mut p = Channel::new_pin(b.reborrow(), Pull::Up);
51 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); 51 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
52 } 52 }
53 } 53 }
54 { 54 {
55 { 55 {
56 let mut p = Channel::new_pin(&mut c, Pull::Down); 56 let mut p = Channel::new_pin(c.reborrow(), Pull::Down);
57 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); 57 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
58 } 58 }
59 { 59 {
60 let mut p = Channel::new_pin(&mut c, Pull::Up); 60 let mut p = Channel::new_pin(c.reborrow(), Pull::Up);
61 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); 61 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
62 } 62 }
63 } 63 }
@@ -65,15 +65,15 @@ async fn main(_spawner: Spawner) {
65 // gp29 is connected to vsys through a 200k/100k divider, 65 // gp29 is connected to vsys through a 200k/100k divider,
66 // adding pulls should change the value 66 // adding pulls should change the value
67 let low = { 67 let low = {
68 let mut p = Channel::new_pin(&mut d, Pull::Down); 68 let mut p = Channel::new_pin(d.reborrow(), Pull::Down);
69 adc.blocking_read(&mut p).unwrap() 69 adc.blocking_read(&mut p).unwrap()
70 }; 70 };
71 let none = { 71 let none = {
72 let mut p = Channel::new_pin(&mut d, Pull::None); 72 let mut p = Channel::new_pin(d.reborrow(), Pull::None);
73 adc.blocking_read(&mut p).unwrap() 73 adc.blocking_read(&mut p).unwrap()
74 }; 74 };
75 let up = { 75 let up = {
76 let mut p = Channel::new_pin(&mut d, Pull::Up); 76 let mut p = Channel::new_pin(d.reborrow(), Pull::Up);
77 adc.blocking_read(&mut p).unwrap() 77 adc.blocking_read(&mut p).unwrap()
78 }; 78 };
79 defmt::assert!(low < none); 79 defmt::assert!(low < none);
@@ -81,7 +81,7 @@ async fn main(_spawner: Spawner) {
81 } 81 }
82 { 82 {
83 let temp = convert_to_celsius( 83 let temp = convert_to_celsius(
84 adc.read(&mut Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR)) 84 adc.read(&mut Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()))
85 .await 85 .await
86 .unwrap(), 86 .unwrap(),
87 ); 87 );
@@ -97,14 +97,29 @@ async fn main(_spawner: Spawner) {
97 let mut low = [0u16; 16]; 97 let mut low = [0u16; 16];
98 let mut none = [0u8; 16]; 98 let mut none = [0u8; 16];
99 let mut up = [Sample::default(); 16]; 99 let mut up = [Sample::default(); 16];
100 adc.read_many(&mut Channel::new_pin(&mut d, Pull::Down), &mut low, 1, &mut p.DMA_CH0) 100 adc.read_many(
101 .await 101 &mut Channel::new_pin(d.reborrow(), Pull::Down),
102 .unwrap(); 102 &mut low,
103 adc.read_many(&mut Channel::new_pin(&mut d, Pull::None), &mut none, 1, &mut p.DMA_CH0) 103 1,
104 .await 104 p.DMA_CH0.reborrow(),
105 .unwrap(); 105 )
106 adc.read_many_raw(&mut Channel::new_pin(&mut d, Pull::Up), &mut up, 1, &mut p.DMA_CH0) 106 .await
107 .await; 107 .unwrap();
108 adc.read_many(
109 &mut Channel::new_pin(d.reborrow(), Pull::None),
110 &mut none,
111 1,
112 p.DMA_CH0.reborrow(),
113 )
114 .await
115 .unwrap();
116 adc.read_many_raw(
117 &mut Channel::new_pin(d.reborrow(), Pull::Up),
118 &mut up,
119 1,
120 p.DMA_CH0.reborrow(),
121 )
122 .await;
108 defmt::assert!(low.iter().zip(none.iter()).all(|(l, n)| *l >> 4 < *n as u16)); 123 defmt::assert!(low.iter().zip(none.iter()).all(|(l, n)| *l >> 4 < *n as u16));
109 defmt::assert!(up.iter().all(|s| s.good())); 124 defmt::assert!(up.iter().all(|s| s.good()));
110 defmt::assert!(none.iter().zip(up.iter()).all(|(n, u)| (*n as u16) < u.value())); 125 defmt::assert!(none.iter().zip(up.iter()).all(|(n, u)| (*n as u16) < u.value()));
@@ -112,10 +127,10 @@ async fn main(_spawner: Spawner) {
112 { 127 {
113 let mut temp = [0u16; 16]; 128 let mut temp = [0u16; 16];
114 adc.read_many( 129 adc.read_many(
115 &mut Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR), 130 &mut Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()),
116 &mut temp, 131 &mut temp,
117 1, 132 1,
118 &mut p.DMA_CH0, 133 p.DMA_CH0.reborrow(),
119 ) 134 )
120 .await 135 .await
121 .unwrap(); 136 .unwrap();
@@ -126,10 +141,10 @@ async fn main(_spawner: Spawner) {
126 { 141 {
127 let mut multi = [0u16; 2]; 142 let mut multi = [0u16; 2];
128 let mut channels = [ 143 let mut channels = [
129 Channel::new_pin(&mut a, Pull::Up), 144 Channel::new_pin(a.reborrow(), Pull::Up),
130 Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR), 145 Channel::new_temp_sensor(p.ADC_TEMP_SENSOR.reborrow()),
131 ]; 146 ];
132 adc.read_many_multichannel(&mut channels, &mut multi, 1, &mut p.DMA_CH0) 147 adc.read_many_multichannel(&mut channels, &mut multi, 1, p.DMA_CH0.reborrow())
133 .await 148 .await
134 .unwrap(); 149 .unwrap();
135 defmt::assert!(multi[0] > 3_000); 150 defmt::assert!(multi[0] > 3_000);
diff --git a/tests/rp/src/bin/bootsel.rs b/tests/rp/src/bin/bootsel.rs
index e88d8bf6c..aa123ab03 100644
--- a/tests/rp/src/bin/bootsel.rs
+++ b/tests/rp/src/bin/bootsel.rs
@@ -4,12 +4,13 @@ teleprobe_meta::target!(b"rpi-pico");
4 4
5use defmt::{assert_eq, *}; 5use defmt::{assert_eq, *};
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_rp::bootsel::is_bootsel_pressed;
7use embassy_time::Timer; 8use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
9 10
10#[embassy_executor::main] 11#[embassy_executor::main]
11async fn main(_spawner: Spawner) { 12async fn main(_spawner: Spawner) {
12 let mut p = embassy_rp::init(Default::default()); 13 let p = embassy_rp::init(Default::default());
13 info!("Hello World!"); 14 info!("Hello World!");
14 15
15 // add some delay to give an attached debug probe time to parse the 16 // add some delay to give an attached debug probe time to parse the
@@ -18,7 +19,7 @@ async fn main(_spawner: Spawner) {
18 // https://github.com/knurling-rs/defmt/pull/683 19 // https://github.com/knurling-rs/defmt/pull/683
19 Timer::after_millis(10).await; 20 Timer::after_millis(10).await;
20 21
21 assert_eq!(p.BOOTSEL.is_pressed(), false); 22 assert_eq!(is_bootsel_pressed(p.BOOTSEL), false);
22 23
23 info!("Test OK"); 24 info!("Test OK");
24 cortex_m::asm::bkpt(); 25 cortex_m::asm::bkpt();
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs
index 6c37ac5be..614b6317a 100644
--- a/tests/rp/src/bin/gpio.rs
+++ b/tests/rp/src/bin/gpio.rs
@@ -21,10 +21,10 @@ async fn main(_spawner: Spawner) {
21 21
22 // Test initial output 22 // Test initial output
23 { 23 {
24 let b = Input::new(&mut b, Pull::None); 24 let b = Input::new(b.reborrow(), Pull::None);
25 25
26 { 26 {
27 let a = Output::new(&mut a, Level::Low); 27 let a = Output::new(a.reborrow(), Level::Low);
28 delay(); 28 delay();
29 assert!(b.is_low()); 29 assert!(b.is_low());
30 assert!(!b.is_high()); 30 assert!(!b.is_high());
@@ -32,7 +32,7 @@ async fn main(_spawner: Spawner) {
32 assert!(!a.is_set_high()); 32 assert!(!a.is_set_high());
33 } 33 }
34 { 34 {
35 let mut a = Output::new(&mut a, Level::High); 35 let mut a = Output::new(a.reborrow(), Level::High);
36 delay(); 36 delay();
37 assert!(!b.is_low()); 37 assert!(!b.is_low());
38 assert!(b.is_high()); 38 assert!(b.is_high());
@@ -69,10 +69,10 @@ async fn main(_spawner: Spawner) {
69 69
70 // Test input no pull 70 // Test input no pull
71 { 71 {
72 let b = Input::new(&mut b, Pull::None); 72 let b = Input::new(b.reborrow(), Pull::None);
73 // no pull, the status is undefined 73 // no pull, the status is undefined
74 74
75 let mut a = Output::new(&mut a, Level::Low); 75 let mut a = Output::new(a.reborrow(), Level::Low);
76 delay(); 76 delay();
77 assert!(b.is_low()); 77 assert!(b.is_low());
78 a.set_high(); 78 a.set_high();
@@ -83,11 +83,11 @@ async fn main(_spawner: Spawner) {
83 // Test input pulldown 83 // Test input pulldown
84 #[cfg(feature = "rp2040")] 84 #[cfg(feature = "rp2040")]
85 { 85 {
86 let b = Input::new(&mut b, Pull::Down); 86 let b = Input::new(b.reborrow(), Pull::Down);
87 delay(); 87 delay();
88 assert!(b.is_low()); 88 assert!(b.is_low());
89 89
90 let mut a = Output::new(&mut a, Level::Low); 90 let mut a = Output::new(a.reborrow(), Level::Low);
91 delay(); 91 delay();
92 assert!(b.is_low()); 92 assert!(b.is_low());
93 a.set_high(); 93 a.set_high();
@@ -97,11 +97,11 @@ async fn main(_spawner: Spawner) {
97 97
98 // Test input pullup 98 // Test input pullup
99 { 99 {
100 let b = Input::new(&mut b, Pull::Up); 100 let b = Input::new(b.reborrow(), Pull::Up);
101 delay(); 101 delay();
102 assert!(b.is_high()); 102 assert!(b.is_high());
103 103
104 let mut a = Output::new(&mut a, Level::Low); 104 let mut a = Output::new(a.reborrow(), Level::Low);
105 delay(); 105 delay();
106 assert!(b.is_low()); 106 assert!(b.is_low());
107 a.set_high(); 107 a.set_high();
@@ -112,8 +112,8 @@ async fn main(_spawner: Spawner) {
112 // OUTPUT OPEN DRAIN 112 // OUTPUT OPEN DRAIN
113 #[cfg(feature = "rp2040")] 113 #[cfg(feature = "rp2040")]
114 { 114 {
115 let mut b = OutputOpenDrain::new(&mut b, Level::High); 115 let mut b = OutputOpenDrain::new(b.reborrow(), Level::High);
116 let mut a = Flex::new(&mut a); 116 let mut a = Flex::new(a.reborrow());
117 a.set_as_input(); 117 a.set_as_input();
118 118
119 // When an OutputOpenDrain is high, it doesn't drive the pin. 119 // When an OutputOpenDrain is high, it doesn't drive the pin.
@@ -170,12 +170,12 @@ async fn main(_spawner: Spawner) {
170 // Test initial output 170 // Test initial output
171 { 171 {
172 //Flex pin configured as input 172 //Flex pin configured as input
173 let mut b = Flex::new(&mut b); 173 let mut b = Flex::new(b.reborrow());
174 b.set_as_input(); 174 b.set_as_input();
175 175
176 { 176 {
177 //Flex pin configured as output 177 //Flex pin configured as output
178 let mut a = Flex::new(&mut a); //Flex pin configured as output 178 let mut a = Flex::new(a.reborrow()); //Flex pin configured as output
179 a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state 179 a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state
180 a.set_as_output(); 180 a.set_as_output();
181 delay(); 181 delay();
@@ -183,7 +183,7 @@ async fn main(_spawner: Spawner) {
183 } 183 }
184 { 184 {
185 //Flex pin configured as output 185 //Flex pin configured as output
186 let mut a = Flex::new(&mut a); 186 let mut a = Flex::new(a.reborrow());
187 a.set_high(); 187 a.set_high();
188 a.set_as_output(); 188 a.set_as_output();
189 189
@@ -194,10 +194,10 @@ async fn main(_spawner: Spawner) {
194 194
195 // Test input no pull 195 // Test input no pull
196 { 196 {
197 let mut b = Flex::new(&mut b); 197 let mut b = Flex::new(b.reborrow());
198 b.set_as_input(); // no pull by default. 198 b.set_as_input(); // no pull by default.
199 199
200 let mut a = Flex::new(&mut a); 200 let mut a = Flex::new(a.reborrow());
201 a.set_low(); 201 a.set_low();
202 a.set_as_output(); 202 a.set_as_output();
203 203
@@ -211,13 +211,13 @@ async fn main(_spawner: Spawner) {
211 // Test input pulldown 211 // Test input pulldown
212 #[cfg(feature = "rp2040")] 212 #[cfg(feature = "rp2040")]
213 { 213 {
214 let mut b = Flex::new(&mut b); 214 let mut b = Flex::new(b.reborrow());
215 b.set_as_input(); 215 b.set_as_input();
216 b.set_pull(Pull::Down); 216 b.set_pull(Pull::Down);
217 delay(); 217 delay();
218 assert!(b.is_low()); 218 assert!(b.is_low());
219 219
220 let mut a = Flex::new(&mut a); 220 let mut a = Flex::new(a.reborrow());
221 a.set_low(); 221 a.set_low();
222 a.set_as_output(); 222 a.set_as_output();
223 delay(); 223 delay();
@@ -229,13 +229,13 @@ async fn main(_spawner: Spawner) {
229 229
230 // Test input pullup 230 // Test input pullup
231 { 231 {
232 let mut b = Flex::new(&mut b); 232 let mut b = Flex::new(b.reborrow());
233 b.set_as_input(); 233 b.set_as_input();
234 b.set_pull(Pull::Up); 234 b.set_pull(Pull::Up);
235 delay(); 235 delay();
236 assert!(b.is_high()); 236 assert!(b.is_high());
237 237
238 let mut a = Flex::new(&mut a); 238 let mut a = Flex::new(a.reborrow());
239 a.set_high(); 239 a.set_high();
240 a.set_as_output(); 240 a.set_as_output();
241 delay(); 241 delay();
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs
index 39e3d6337..72fb0910d 100644
--- a/tests/rp/src/bin/gpio_async.rs
+++ b/tests/rp/src/bin/gpio_async.rs
@@ -22,8 +22,8 @@ async fn main(_spawner: Spawner) {
22 22
23 { 23 {
24 info!("test wait_for_high"); 24 info!("test wait_for_high");
25 let mut output = Output::new(&mut output_pin, Level::Low); 25 let mut output = Output::new(output_pin.reborrow(), Level::Low);
26 let mut input = Input::new(&mut input_pin, Pull::None); 26 let mut input = Input::new(input_pin.reborrow(), Pull::None);
27 27
28 assert!(input.is_low(), "input was expected to be low"); 28 assert!(input.is_low(), "input was expected to be low");
29 29
@@ -43,8 +43,8 @@ async fn main(_spawner: Spawner) {
43 43
44 { 44 {
45 info!("test wait_for_low"); 45 info!("test wait_for_low");
46 let mut output = Output::new(&mut output_pin, Level::High); 46 let mut output = Output::new(output_pin.reborrow(), Level::High);
47 let mut input = Input::new(&mut input_pin, Pull::None); 47 let mut input = Input::new(input_pin.reborrow(), Pull::None);
48 48
49 assert!(input.is_high(), "input was expected to be high"); 49 assert!(input.is_high(), "input was expected to be high");
50 50
@@ -63,8 +63,8 @@ async fn main(_spawner: Spawner) {
63 63
64 { 64 {
65 info!("test wait_for_rising_edge"); 65 info!("test wait_for_rising_edge");
66 let mut output = Output::new(&mut output_pin, Level::Low); 66 let mut output = Output::new(output_pin.reborrow(), Level::Low);
67 let mut input = Input::new(&mut input_pin, Pull::None); 67 let mut input = Input::new(input_pin.reborrow(), Pull::None);
68 68
69 assert!(input.is_low(), "input was expected to be low"); 69 assert!(input.is_low(), "input was expected to be low");
70 70
@@ -83,8 +83,8 @@ async fn main(_spawner: Spawner) {
83 83
84 { 84 {
85 info!("test wait_for_falling_edge"); 85 info!("test wait_for_falling_edge");
86 let mut output = Output::new(&mut output_pin, Level::High); 86 let mut output = Output::new(output_pin.reborrow(), Level::High);
87 let mut input = Input::new(&mut input_pin, Pull::None); 87 let mut input = Input::new(input_pin.reborrow(), Pull::None);
88 88
89 assert!(input.is_high(), "input was expected to be high"); 89 assert!(input.is_high(), "input was expected to be high");
90 90
@@ -103,8 +103,8 @@ async fn main(_spawner: Spawner) {
103 103
104 { 104 {
105 info!("test wait_for_any_edge (falling)"); 105 info!("test wait_for_any_edge (falling)");
106 let mut output = Output::new(&mut output_pin, Level::High); 106 let mut output = Output::new(output_pin.reborrow(), Level::High);
107 let mut input = Input::new(&mut input_pin, Pull::None); 107 let mut input = Input::new(input_pin.reborrow(), Pull::None);
108 108
109 assert!(input.is_high(), "input was expected to be high"); 109 assert!(input.is_high(), "input was expected to be high");
110 110
@@ -123,8 +123,8 @@ async fn main(_spawner: Spawner) {
123 123
124 { 124 {
125 info!("test wait_for_any_edge (rising)"); 125 info!("test wait_for_any_edge (rising)");
126 let mut output = Output::new(&mut output_pin, Level::Low); 126 let mut output = Output::new(output_pin.reborrow(), Level::Low);
127 let mut input = Input::new(&mut input_pin, Pull::None); 127 let mut input = Input::new(input_pin.reborrow(), Pull::None);
128 128
129 assert!(input.is_low(), "input was expected to be low"); 129 assert!(input.is_low(), "input was expected to be low");
130 130
diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs
index 3caa8ef35..857f36975 100644
--- a/tests/rp/src/bin/gpio_multicore.rs
+++ b/tests/rp/src/bin/gpio_multicore.rs
@@ -10,6 +10,7 @@ use embassy_executor::Executor;
10use embassy_rp::gpio::{Input, Level, Output, Pull}; 10use embassy_rp::gpio::{Input, Level, Output, Pull};
11use embassy_rp::multicore::{spawn_core1, Stack}; 11use embassy_rp::multicore::{spawn_core1, Stack};
12use embassy_rp::peripherals::{PIN_0, PIN_1}; 12use embassy_rp::peripherals::{PIN_0, PIN_1};
13use embassy_rp::Peri;
13use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; 14use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
14use embassy_sync::channel::Channel; 15use embassy_sync::channel::Channel;
15use static_cell::StaticCell; 16use static_cell::StaticCell;
@@ -37,7 +38,7 @@ fn main() -> ! {
37} 38}
38 39
39#[embassy_executor::task] 40#[embassy_executor::task]
40async fn core0_task(p: PIN_0) { 41async fn core0_task(p: Peri<'static, PIN_0>) {
41 info!("CORE0 is running"); 42 info!("CORE0 is running");
42 43
43 let mut pin = Output::new(p, Level::Low); 44 let mut pin = Output::new(p, Level::Low);
@@ -54,7 +55,7 @@ async fn core0_task(p: PIN_0) {
54} 55}
55 56
56#[embassy_executor::task] 57#[embassy_executor::task]
57async fn core1_task(p: PIN_1) { 58async fn core1_task(p: Peri<'static, PIN_1>) {
58 info!("CORE1 is running"); 59 info!("CORE1 is running");
59 60
60 CHANNEL0.receive().await; 61 CHANNEL0.receive().await;
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs
index d8ee78dcd..5f890cd50 100644
--- a/tests/rp/src/bin/pwm.rs
+++ b/tests/rp/src/bin/pwm.rs
@@ -33,7 +33,7 @@ async fn main(_spawner: Spawner) {
33 33
34 // Test free-running clock 34 // Test free-running clock
35 { 35 {
36 let pwm = Pwm::new_free(&mut p.PWM_SLICE3, cfg.clone()); 36 let pwm = Pwm::new_free(p.PWM_SLICE3.reborrow(), cfg.clone());
37 cortex_m::asm::delay(125); 37 cortex_m::asm::delay(125);
38 let ctr = pwm.counter(); 38 let ctr = pwm.counter();
39 assert!(ctr > 0); 39 assert!(ctr > 0);
@@ -50,8 +50,8 @@ async fn main(_spawner: Spawner) {
50 50
51 // Test output from A 51 // Test output from A
52 { 52 {
53 let pin1 = Input::new(&mut p9, Pull::None); 53 let pin1 = Input::new(p9.reborrow(), Pull::None);
54 let _pwm = Pwm::new_output_a(&mut p.PWM_SLICE3, &mut p6, cfg.clone()); 54 let _pwm = Pwm::new_output_a(p.PWM_SLICE3.reborrow(), p6.reborrow(), cfg.clone());
55 Timer::after_millis(1).await; 55 Timer::after_millis(1).await;
56 assert_eq!(pin1.is_low(), invert_a); 56 assert_eq!(pin1.is_low(), invert_a);
57 Timer::after_millis(5).await; 57 Timer::after_millis(5).await;
@@ -64,8 +64,8 @@ async fn main(_spawner: Spawner) {
64 64
65 // Test output from B 65 // Test output from B
66 { 66 {
67 let pin2 = Input::new(&mut p11, Pull::None); 67 let pin2 = Input::new(p11.reborrow(), Pull::None);
68 let _pwm = Pwm::new_output_b(&mut p.PWM_SLICE3, &mut p7, cfg.clone()); 68 let _pwm = Pwm::new_output_b(p.PWM_SLICE3.reborrow(), p7.reborrow(), cfg.clone());
69 Timer::after_millis(1).await; 69 Timer::after_millis(1).await;
70 assert_ne!(pin2.is_low(), invert_a); 70 assert_ne!(pin2.is_low(), invert_a);
71 Timer::after_millis(5).await; 71 Timer::after_millis(5).await;
@@ -78,9 +78,9 @@ async fn main(_spawner: Spawner) {
78 78
79 // Test output from A+B 79 // Test output from A+B
80 { 80 {
81 let pin1 = Input::new(&mut p9, Pull::None); 81 let pin1 = Input::new(p9.reborrow(), Pull::None);
82 let pin2 = Input::new(&mut p11, Pull::None); 82 let pin2 = Input::new(p11.reborrow(), Pull::None);
83 let _pwm = Pwm::new_output_ab(&mut p.PWM_SLICE3, &mut p6, &mut p7, cfg.clone()); 83 let _pwm = Pwm::new_output_ab(p.PWM_SLICE3.reborrow(), p6.reborrow(), p7.reborrow(), cfg.clone());
84 Timer::after_millis(1).await; 84 Timer::after_millis(1).await;
85 assert_eq!(pin1.is_low(), invert_a); 85 assert_eq!(pin1.is_low(), invert_a);
86 assert_ne!(pin2.is_low(), invert_a); 86 assert_ne!(pin2.is_low(), invert_a);
@@ -99,8 +99,14 @@ async fn main(_spawner: Spawner) {
99 // Test level-gated 99 // Test level-gated
100 #[cfg(feature = "rp2040")] 100 #[cfg(feature = "rp2040")]
101 { 101 {
102 let mut pin2 = Output::new(&mut p11, Level::Low); 102 let mut pin2 = Output::new(p11.reborrow(), Level::Low);
103 let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, Pull::None, InputMode::Level, cfg.clone()); 103 let pwm = Pwm::new_input(
104 p.PWM_SLICE3.reborrow(),
105 p7.reborrow(),
106 Pull::None,
107 InputMode::Level,
108 cfg.clone(),
109 );
104 assert_eq!(pwm.counter(), 0); 110 assert_eq!(pwm.counter(), 0);
105 Timer::after_millis(5).await; 111 Timer::after_millis(5).await;
106 assert_eq!(pwm.counter(), 0); 112 assert_eq!(pwm.counter(), 0);
@@ -117,10 +123,10 @@ async fn main(_spawner: Spawner) {
117 // Test rising-gated 123 // Test rising-gated
118 #[cfg(feature = "rp2040")] 124 #[cfg(feature = "rp2040")]
119 { 125 {
120 let mut pin2 = Output::new(&mut p11, Level::Low); 126 let mut pin2 = Output::new(p11.reborrow(), Level::Low);
121 let pwm = Pwm::new_input( 127 let pwm = Pwm::new_input(
122 &mut p.PWM_SLICE3, 128 p.PWM_SLICE3.reborrow(),
123 &mut p7, 129 p7.reborrow(),
124 Pull::None, 130 Pull::None,
125 InputMode::RisingEdge, 131 InputMode::RisingEdge,
126 cfg.clone(), 132 cfg.clone(),
@@ -139,10 +145,10 @@ async fn main(_spawner: Spawner) {
139 // Test falling-gated 145 // Test falling-gated
140 #[cfg(feature = "rp2040")] 146 #[cfg(feature = "rp2040")]
141 { 147 {
142 let mut pin2 = Output::new(&mut p11, Level::High); 148 let mut pin2 = Output::new(p11.reborrow(), Level::High);
143 let pwm = Pwm::new_input( 149 let pwm = Pwm::new_input(
144 &mut p.PWM_SLICE3, 150 p.PWM_SLICE3.reborrow(),
145 &mut p7, 151 p7.reborrow(),
146 Pull::None, 152 Pull::None,
147 InputMode::FallingEdge, 153 InputMode::FallingEdge,
148 cfg.clone(), 154 cfg.clone(),
@@ -160,10 +166,10 @@ async fn main(_spawner: Spawner) {
160 166
161 // pull-down 167 // pull-down
162 { 168 {
163 let pin2 = Input::new(&mut p11, Pull::None); 169 let pin2 = Input::new(p11.reborrow(), Pull::None);
164 Pwm::new_input( 170 Pwm::new_input(
165 &mut p.PWM_SLICE3, 171 p.PWM_SLICE3.reborrow(),
166 &mut p7, 172 p7.reborrow(),
167 Pull::Down, 173 Pull::Down,
168 InputMode::FallingEdge, 174 InputMode::FallingEdge,
169 cfg.clone(), 175 cfg.clone(),
@@ -174,10 +180,10 @@ async fn main(_spawner: Spawner) {
174 180
175 // pull-up 181 // pull-up
176 { 182 {
177 let pin2 = Input::new(&mut p11, Pull::None); 183 let pin2 = Input::new(p11.reborrow(), Pull::None);
178 Pwm::new_input( 184 Pwm::new_input(
179 &mut p.PWM_SLICE3, 185 p.PWM_SLICE3.reborrow(),
180 &mut p7, 186 p7.reborrow(),
181 Pull::Up, 187 Pull::Up,
182 InputMode::FallingEdge, 188 InputMode::FallingEdge,
183 cfg.clone(), 189 cfg.clone(),
diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs
index 67cfa6bc8..84744ab77 100644
--- a/tests/rp/src/bin/uart.rs
+++ b/tests/rp/src/bin/uart.rs
@@ -56,7 +56,7 @@ async fn main(_spawner: Spawner) {
56 56
57 { 57 {
58 let config = Config::default(); 58 let config = Config::default();
59 let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config); 59 let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
60 60
61 // We can't send too many bytes, they have to fit in the FIFO. 61 // We can't send too many bytes, they have to fit in the FIFO.
62 // This is because we aren't sending+receiving at the same time. 62 // This is because we aren't sending+receiving at the same time.
@@ -69,7 +69,7 @@ async fn main(_spawner: Spawner) {
69 info!("test overflow detection"); 69 info!("test overflow detection");
70 { 70 {
71 let config = Config::default(); 71 let config = Config::default();
72 let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config); 72 let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
73 73
74 let data = [ 74 let data = [
75 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 75 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -93,7 +93,7 @@ async fn main(_spawner: Spawner) {
93 info!("test break detection"); 93 info!("test break detection");
94 { 94 {
95 let config = Config::default(); 95 let config = Config::default();
96 let mut uart = Uart::new_blocking(&mut uart, &mut tx, &mut rx, config); 96 let mut uart = Uart::new_blocking(uart.reborrow(), tx.reborrow(), rx.reborrow(), config);
97 97
98 // break on empty fifo 98 // break on empty fifo
99 uart.send_break(20).await; 99 uart.send_break(20).await;
@@ -113,11 +113,11 @@ async fn main(_spawner: Spawner) {
113 // parity detection. here we bitbang to not require two uarts. 113 // parity detection. here we bitbang to not require two uarts.
114 info!("test parity error detection"); 114 info!("test parity error detection");
115 { 115 {
116 let mut pin = Output::new(&mut tx, Level::High); 116 let mut pin = Output::new(tx.reborrow(), Level::High);
117 let mut config = Config::default(); 117 let mut config = Config::default();
118 config.baudrate = 1000; 118 config.baudrate = 1000;
119 config.parity = Parity::ParityEven; 119 config.parity = Parity::ParityEven;
120 let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); 120 let mut uart = UartRx::new_blocking(uart.reborrow(), rx.reborrow(), config);
121 121
122 async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) { 122 async fn chr(pin: &mut Output<'_>, v: u8, parity: u8) {
123 send(pin, v, Some(parity != 0)).await; 123 send(pin, v, Some(parity != 0)).await;
@@ -140,10 +140,10 @@ async fn main(_spawner: Spawner) {
140 // framing error detection. here we bitbang because there's no other way. 140 // framing error detection. here we bitbang because there's no other way.
141 info!("test framing error detection"); 141 info!("test framing error detection");
142 { 142 {
143 let mut pin = Output::new(&mut tx, Level::High); 143 let mut pin = Output::new(tx.reborrow(), Level::High);
144 let mut config = Config::default(); 144 let mut config = Config::default();
145 config.baudrate = 1000; 145 config.baudrate = 1000;
146 let mut uart = UartRx::new_blocking(&mut uart, &mut rx, config); 146 let mut uart = UartRx::new_blocking(uart.reborrow(), rx.reborrow(), config);
147 147
148 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { 148 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
149 if good { 149 if good {
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs
index a543320e0..b270a60ce 100644
--- a/tests/rp/src/bin/uart_buffered.rs
+++ b/tests/rp/src/bin/uart_buffered.rs
@@ -73,7 +73,15 @@ async fn main(_spawner: Spawner) {
73 let config = Config::default(); 73 let config = Config::default();
74 let tx_buf = &mut [0u8; 16]; 74 let tx_buf = &mut [0u8; 16];
75 let rx_buf = &mut [0u8; 16]; 75 let rx_buf = &mut [0u8; 16];
76 let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config); 76 let mut uart = BufferedUart::new(
77 uart.reborrow(),
78 Irqs,
79 tx.reborrow(),
80 rx.reborrow(),
81 tx_buf,
82 rx_buf,
83 config,
84 );
77 85
78 // Make sure we send more bytes than fits in the FIFO, to test the actual 86 // Make sure we send more bytes than fits in the FIFO, to test the actual
79 // bufferedUart. 87 // bufferedUart.
@@ -93,7 +101,15 @@ async fn main(_spawner: Spawner) {
93 let config = Config::default(); 101 let config = Config::default();
94 let tx_buf = &mut [0u8; 16]; 102 let tx_buf = &mut [0u8; 16];
95 let rx_buf = &mut [0u8; 16]; 103 let rx_buf = &mut [0u8; 16];
96 let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config); 104 let mut uart = BufferedUart::new(
105 uart.reborrow(),
106 Irqs,
107 tx.reborrow(),
108 rx.reborrow(),
109 tx_buf,
110 rx_buf,
111 config,
112 );
97 113
98 // Make sure we send more bytes than fits in the FIFO, to test the actual 114 // Make sure we send more bytes than fits in the FIFO, to test the actual
99 // bufferedUart. 115 // bufferedUart.
@@ -128,7 +144,15 @@ async fn main(_spawner: Spawner) {
128 config.baudrate = 1000; 144 config.baudrate = 1000;
129 let tx_buf = &mut [0u8; 16]; 145 let tx_buf = &mut [0u8; 16];
130 let rx_buf = &mut [0u8; 16]; 146 let rx_buf = &mut [0u8; 16];
131 let mut uart = BufferedUart::new(&mut uart, Irqs, &mut tx, &mut rx, tx_buf, rx_buf, config); 147 let mut uart = BufferedUart::new(
148 uart.reborrow(),
149 Irqs,
150 tx.reborrow(),
151 rx.reborrow(),
152 tx_buf,
153 rx_buf,
154 config,
155 );
132 156
133 // break on empty buffer 157 // break on empty buffer
134 uart.send_break(20).await; 158 uart.send_break(20).await;
@@ -156,13 +180,13 @@ async fn main(_spawner: Spawner) {
156 // parity detection. here we bitbang to not require two uarts. 180 // parity detection. here we bitbang to not require two uarts.
157 info!("test parity error detection"); 181 info!("test parity error detection");
158 { 182 {
159 let mut pin = Output::new(&mut tx, Level::High); 183 let mut pin = Output::new(tx.reborrow(), Level::High);
160 // choose a very slow baud rate to make tests reliable even with O0 184 // choose a very slow baud rate to make tests reliable even with O0
161 let mut config = Config::default(); 185 let mut config = Config::default();
162 config.baudrate = 1000; 186 config.baudrate = 1000;
163 config.parity = Parity::ParityEven; 187 config.parity = Parity::ParityEven;
164 let rx_buf = &mut [0u8; 16]; 188 let rx_buf = &mut [0u8; 16];
165 let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); 189 let mut uart = BufferedUartRx::new(uart.reborrow(), Irqs, rx.reborrow(), rx_buf, config);
166 190
167 async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { 191 async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
168 send(pin, v, Some(parity != 0)).await; 192 send(pin, v, Some(parity != 0)).await;
@@ -204,12 +228,12 @@ async fn main(_spawner: Spawner) {
204 // framing error detection. here we bitbang because there's no other way. 228 // framing error detection. here we bitbang because there's no other way.
205 info!("test framing error detection"); 229 info!("test framing error detection");
206 { 230 {
207 let mut pin = Output::new(&mut tx, Level::High); 231 let mut pin = Output::new(tx.reborrow(), Level::High);
208 // choose a very slow baud rate to make tests reliable even with O0 232 // choose a very slow baud rate to make tests reliable even with O0
209 let mut config = Config::default(); 233 let mut config = Config::default();
210 config.baudrate = 1000; 234 config.baudrate = 1000;
211 let rx_buf = &mut [0u8; 16]; 235 let rx_buf = &mut [0u8; 16];
212 let mut uart = BufferedUartRx::new(&mut uart, Irqs, &mut rx, rx_buf, config); 236 let mut uart = BufferedUartRx::new(uart.reborrow(), Irqs, rx.reborrow(), rx_buf, config);
213 237
214 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { 238 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
215 if good { 239 if good {
diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs
index bdf94e78c..a09101223 100644
--- a/tests/rp/src/bin/uart_dma.rs
+++ b/tests/rp/src/bin/uart_dma.rs
@@ -65,12 +65,12 @@ async fn main(_spawner: Spawner) {
65 { 65 {
66 let config = Config::default(); 66 let config = Config::default();
67 let mut uart = Uart::new( 67 let mut uart = Uart::new(
68 &mut uart, 68 uart.reborrow(),
69 &mut tx, 69 tx.reborrow(),
70 &mut rx, 70 rx.reborrow(),
71 Irqs, 71 Irqs,
72 &mut p.DMA_CH0, 72 p.DMA_CH0.reborrow(),
73 &mut p.DMA_CH1, 73 p.DMA_CH1.reborrow(),
74 config, 74 config,
75 ); 75 );
76 76
@@ -86,12 +86,12 @@ async fn main(_spawner: Spawner) {
86 { 86 {
87 let config = Config::default(); 87 let config = Config::default();
88 let mut uart = Uart::new( 88 let mut uart = Uart::new(
89 &mut uart, 89 uart.reborrow(),
90 &mut tx, 90 tx.reborrow(),
91 &mut rx, 91 rx.reborrow(),
92 Irqs, 92 Irqs,
93 &mut p.DMA_CH0, 93 p.DMA_CH0.reborrow(),
94 &mut p.DMA_CH1, 94 p.DMA_CH1.reborrow(),
95 config, 95 config,
96 ); 96 );
97 97
@@ -115,12 +115,12 @@ async fn main(_spawner: Spawner) {
115 { 115 {
116 let config = Config::default(); 116 let config = Config::default();
117 let (mut tx, mut rx) = Uart::new( 117 let (mut tx, mut rx) = Uart::new(
118 &mut uart, 118 uart.reborrow(),
119 &mut tx, 119 tx.reborrow(),
120 &mut rx, 120 rx.reborrow(),
121 Irqs, 121 Irqs,
122 &mut p.DMA_CH0, 122 p.DMA_CH0.reborrow(),
123 &mut p.DMA_CH1, 123 p.DMA_CH1.reborrow(),
124 config, 124 config,
125 ) 125 )
126 .split(); 126 .split();
@@ -156,12 +156,12 @@ async fn main(_spawner: Spawner) {
156 // parity detection. here we bitbang to not require two uarts. 156 // parity detection. here we bitbang to not require two uarts.
157 info!("test parity error detection"); 157 info!("test parity error detection");
158 { 158 {
159 let mut pin = Output::new(&mut tx, Level::High); 159 let mut pin = Output::new(tx.reborrow(), Level::High);
160 // choose a very slow baud rate to make tests reliable even with O0 160 // choose a very slow baud rate to make tests reliable even with O0
161 let mut config = Config::default(); 161 let mut config = Config::default();
162 config.baudrate = 1000; 162 config.baudrate = 1000;
163 config.parity = Parity::ParityEven; 163 config.parity = Parity::ParityEven;
164 let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); 164 let mut uart = UartRx::new(uart.reborrow(), rx.reborrow(), Irqs, p.DMA_CH0.reborrow(), config);
165 165
166 async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) { 166 async fn chr(pin: &mut Output<'_>, v: u8, parity: u32) {
167 send(pin, v, Some(parity != 0)).await; 167 send(pin, v, Some(parity != 0)).await;
@@ -202,11 +202,11 @@ async fn main(_spawner: Spawner) {
202 // framing error detection. here we bitbang because there's no other way. 202 // framing error detection. here we bitbang because there's no other way.
203 info!("test framing error detection"); 203 info!("test framing error detection");
204 { 204 {
205 let mut pin = Output::new(&mut tx, Level::High); 205 let mut pin = Output::new(tx.reborrow(), Level::High);
206 // choose a very slow baud rate to make tests reliable even with O0 206 // choose a very slow baud rate to make tests reliable even with O0
207 let mut config = Config::default(); 207 let mut config = Config::default();
208 config.baudrate = 1000; 208 config.baudrate = 1000;
209 let mut uart = UartRx::new(&mut uart, &mut rx, Irqs, &mut p.DMA_CH0, config); 209 let mut uart = UartRx::new(uart.reborrow(), rx.reborrow(), Irqs, p.DMA_CH0.reborrow(), config);
210 210
211 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) { 211 async fn chr(pin: &mut Output<'_>, v: u8, good: bool) {
212 if good { 212 if good {