diff options
Diffstat (limited to 'tests/rp/src')
| -rw-r--r-- | tests/rp/src/bin/adc.rs | 59 | ||||
| -rw-r--r-- | tests/rp/src/bin/dma_copy_async.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/flash.rs | 19 | ||||
| -rw-r--r-- | tests/rp/src/bin/gpio.rs | 10 | ||||
| -rw-r--r-- | tests/rp/src/bin/gpio_async.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/gpio_multicore.rs | 5 | ||||
| -rw-r--r-- | tests/rp/src/bin/i2c.rs | 25 | ||||
| -rw-r--r-- | tests/rp/src/bin/multicore.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/pio_irq.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/pio_multi_load.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/pwm.rs | 11 | ||||
| -rw-r--r-- | tests/rp/src/bin/spi.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/spi_async.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/timer.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart_buffered.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart_dma.rs | 3 | ||||
| -rw-r--r-- | tests/rp/src/bin/uart_upgrade.rs | 3 |
18 files changed, 107 insertions, 58 deletions
diff --git a/tests/rp/src/bin/adc.rs b/tests/rp/src/bin/adc.rs index 65c246472..87e9709cc 100644 --- a/tests/rp/src/bin/adc.rs +++ b/tests/rp/src/bin/adc.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::*; | 8 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| @@ -20,14 +23,19 @@ async fn main(_spawner: Spawner) { | |||
| 20 | let _wifi_off = Output::new(p.PIN_25, Level::High); | 23 | let _wifi_off = Output::new(p.PIN_25, Level::High); |
| 21 | let mut adc = Adc::new(p.ADC, Irqs, Config::default()); | 24 | let mut adc = Adc::new(p.ADC, Irqs, Config::default()); |
| 22 | 25 | ||
| 26 | #[cfg(any(feature = "rp2040", feature = "rp235xa"))] | ||
| 27 | let (mut a, mut b, mut c, mut d) = (p.PIN_26, p.PIN_27, p.PIN_28, p.PIN_29); | ||
| 28 | #[cfg(feature = "rp235xb")] | ||
| 29 | let (mut a, mut b, mut c, mut d) = (p.PIN_44, p.PIN_45, p.PIN_46, p.PIN_47); | ||
| 30 | |||
| 23 | { | 31 | { |
| 24 | { | 32 | { |
| 25 | let mut p = Channel::new_pin(&mut p.PIN_26, Pull::Down); | 33 | let mut p = Channel::new_pin(&mut a, Pull::Down); |
| 26 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); | 34 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); |
| 27 | defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000); | 35 | defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000); |
| 28 | } | 36 | } |
| 29 | { | 37 | { |
| 30 | let mut p = Channel::new_pin(&mut p.PIN_26, Pull::Up); | 38 | let mut p = Channel::new_pin(&mut a, Pull::Up); |
| 31 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); | 39 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); |
| 32 | defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000); | 40 | defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000); |
| 33 | } | 41 | } |
| @@ -35,21 +43,21 @@ async fn main(_spawner: Spawner) { | |||
| 35 | // not bothering with async reads from now on | 43 | // not bothering with async reads from now on |
| 36 | { | 44 | { |
| 37 | { | 45 | { |
| 38 | let mut p = Channel::new_pin(&mut p.PIN_27, Pull::Down); | 46 | let mut p = Channel::new_pin(&mut b, Pull::Down); |
| 39 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); | 47 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); |
| 40 | } | 48 | } |
| 41 | { | 49 | { |
| 42 | let mut p = Channel::new_pin(&mut p.PIN_27, Pull::Up); | 50 | let mut p = Channel::new_pin(&mut b, Pull::Up); |
| 43 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); | 51 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); |
| 44 | } | 52 | } |
| 45 | } | 53 | } |
| 46 | { | 54 | { |
| 47 | { | 55 | { |
| 48 | let mut p = Channel::new_pin(&mut p.PIN_28, Pull::Down); | 56 | let mut p = Channel::new_pin(&mut c, Pull::Down); |
| 49 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); | 57 | defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000); |
| 50 | } | 58 | } |
| 51 | { | 59 | { |
| 52 | let mut p = Channel::new_pin(&mut p.PIN_28, Pull::Up); | 60 | let mut p = Channel::new_pin(&mut c, Pull::Up); |
| 53 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); | 61 | defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000); |
| 54 | } | 62 | } |
| 55 | } | 63 | } |
| @@ -57,15 +65,15 @@ async fn main(_spawner: Spawner) { | |||
| 57 | // gp29 is connected to vsys through a 200k/100k divider, | 65 | // gp29 is connected to vsys through a 200k/100k divider, |
| 58 | // adding pulls should change the value | 66 | // adding pulls should change the value |
| 59 | let low = { | 67 | let low = { |
| 60 | let mut p = Channel::new_pin(&mut p.PIN_29, Pull::Down); | 68 | let mut p = Channel::new_pin(&mut d, Pull::Down); |
| 61 | adc.blocking_read(&mut p).unwrap() | 69 | adc.blocking_read(&mut p).unwrap() |
| 62 | }; | 70 | }; |
| 63 | let none = { | 71 | let none = { |
| 64 | let mut p = Channel::new_pin(&mut p.PIN_29, Pull::None); | 72 | let mut p = Channel::new_pin(&mut d, Pull::None); |
| 65 | adc.blocking_read(&mut p).unwrap() | 73 | adc.blocking_read(&mut p).unwrap() |
| 66 | }; | 74 | }; |
| 67 | let up = { | 75 | let up = { |
| 68 | let mut p = Channel::new_pin(&mut p.PIN_29, Pull::Up); | 76 | let mut p = Channel::new_pin(&mut d, Pull::Up); |
| 69 | adc.blocking_read(&mut p).unwrap() | 77 | adc.blocking_read(&mut p).unwrap() |
| 70 | }; | 78 | }; |
| 71 | defmt::assert!(low < none); | 79 | defmt::assert!(low < none); |
| @@ -89,29 +97,14 @@ async fn main(_spawner: Spawner) { | |||
| 89 | let mut low = [0u16; 16]; | 97 | let mut low = [0u16; 16]; |
| 90 | let mut none = [0u8; 16]; | 98 | let mut none = [0u8; 16]; |
| 91 | let mut up = [Sample::default(); 16]; | 99 | let mut up = [Sample::default(); 16]; |
| 92 | adc.read_many( | 100 | adc.read_many(&mut Channel::new_pin(&mut d, Pull::Down), &mut low, 1, &mut p.DMA_CH0) |
| 93 | &mut Channel::new_pin(&mut p.PIN_29, Pull::Down), | 101 | .await |
| 94 | &mut low, | 102 | .unwrap(); |
| 95 | 1, | 103 | adc.read_many(&mut Channel::new_pin(&mut d, Pull::None), &mut none, 1, &mut p.DMA_CH0) |
| 96 | &mut p.DMA_CH0, | 104 | .await |
| 97 | ) | 105 | .unwrap(); |
| 98 | .await | 106 | adc.read_many_raw(&mut Channel::new_pin(&mut d, Pull::Up), &mut up, 1, &mut p.DMA_CH0) |
| 99 | .unwrap(); | 107 | .await; |
| 100 | adc.read_many( | ||
| 101 | &mut Channel::new_pin(&mut p.PIN_29, Pull::None), | ||
| 102 | &mut none, | ||
| 103 | 1, | ||
| 104 | &mut p.DMA_CH0, | ||
| 105 | ) | ||
| 106 | .await | ||
| 107 | .unwrap(); | ||
| 108 | adc.read_many_raw( | ||
| 109 | &mut Channel::new_pin(&mut p.PIN_29, Pull::Up), | ||
| 110 | &mut up, | ||
| 111 | 1, | ||
| 112 | &mut p.DMA_CH0, | ||
| 113 | ) | ||
| 114 | .await; | ||
| 115 | defmt::assert!(low.iter().zip(none.iter()).all(|(l, n)| *l >> 4 < *n as u16)); | 108 | defmt::assert!(low.iter().zip(none.iter()).all(|(l, n)| *l >> 4 < *n as u16)); |
| 116 | defmt::assert!(up.iter().all(|s| s.good())); | 109 | defmt::assert!(up.iter().all(|s| s.good())); |
| 117 | defmt::assert!(none.iter().zip(up.iter()).all(|(n, u)| (*n as u16) < u.value())); | 110 | defmt::assert!(none.iter().zip(up.iter()).all(|(n, u)| (*n as u16) < u.value())); |
| @@ -133,7 +126,7 @@ async fn main(_spawner: Spawner) { | |||
| 133 | { | 126 | { |
| 134 | let mut multi = [0u16; 2]; | 127 | let mut multi = [0u16; 2]; |
| 135 | let mut channels = [ | 128 | let mut channels = [ |
| 136 | Channel::new_pin(&mut p.PIN_26, Pull::Up), | 129 | Channel::new_pin(&mut a, Pull::Up), |
| 137 | Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR), | 130 | Channel::new_temp_sensor(&mut p.ADC_TEMP_SENSOR), |
| 138 | ]; | 131 | ]; |
| 139 | adc.read_many_multichannel(&mut channels, &mut multi, 1, &mut p.DMA_CH0) | 132 | adc.read_many_multichannel(&mut channels, &mut multi, 1, &mut p.DMA_CH0) |
diff --git a/tests/rp/src/bin/dma_copy_async.rs b/tests/rp/src/bin/dma_copy_async.rs index 7c64bc396..3dcf4f4d8 100644 --- a/tests/rp/src/bin/dma_copy_async.rs +++ b/tests/rp/src/bin/dma_copy_async.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, *}; | 8 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs index 310f0d586..548a6ee72 100644 --- a/tests/rp/src/bin/flash.rs +++ b/tests/rp/src/bin/flash.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::*; | 8 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| @@ -24,13 +27,19 @@ async fn main(_spawner: Spawner) { | |||
| 24 | let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); | 27 | let mut flash = embassy_rp::flash::Flash::<_, Async, { 2 * 1024 * 1024 }>::new(p.FLASH, p.DMA_CH0); |
| 25 | 28 | ||
| 26 | // Get JEDEC id | 29 | // Get JEDEC id |
| 27 | let jedec = defmt::unwrap!(flash.blocking_jedec_id()); | 30 | #[cfg(feature = "rp2040")] |
| 28 | info!("jedec id: 0x{:x}", jedec); | 31 | { |
| 32 | let jedec = defmt::unwrap!(flash.blocking_jedec_id()); | ||
| 33 | info!("jedec id: 0x{:x}", jedec); | ||
| 34 | } | ||
| 29 | 35 | ||
| 30 | // Get unique id | 36 | // Get unique id |
| 31 | let mut uid = [0; 8]; | 37 | #[cfg(feature = "rp2040")] |
| 32 | defmt::unwrap!(flash.blocking_unique_id(&mut uid)); | 38 | { |
| 33 | info!("unique id: {:?}", uid); | 39 | let mut uid = [0; 8]; |
| 40 | defmt::unwrap!(flash.blocking_unique_id(&mut uid)); | ||
| 41 | info!("unique id: {:?}", uid); | ||
| 42 | } | ||
| 34 | 43 | ||
| 35 | let mut buf = [0u8; ERASE_SIZE]; | 44 | let mut buf = [0u8; ERASE_SIZE]; |
| 36 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf)); | 45 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf)); |
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index e0c309887..6c37ac5be 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -1,10 +1,15 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert, *}; | 8 | use defmt::{assert, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull}; | 10 | #[cfg(feature = "rp2040")] |
| 11 | use embassy_rp::gpio::OutputOpenDrain; | ||
| 12 | use embassy_rp::gpio::{Flex, Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | 13 | use {defmt_rtt as _, panic_probe as _}; |
| 9 | 14 | ||
| 10 | #[embassy_executor::main] | 15 | #[embassy_executor::main] |
| @@ -76,6 +81,7 @@ async fn main(_spawner: Spawner) { | |||
| 76 | } | 81 | } |
| 77 | 82 | ||
| 78 | // Test input pulldown | 83 | // Test input pulldown |
| 84 | #[cfg(feature = "rp2040")] | ||
| 79 | { | 85 | { |
| 80 | let b = Input::new(&mut b, Pull::Down); | 86 | let b = Input::new(&mut b, Pull::Down); |
| 81 | delay(); | 87 | delay(); |
| @@ -104,6 +110,7 @@ async fn main(_spawner: Spawner) { | |||
| 104 | } | 110 | } |
| 105 | 111 | ||
| 106 | // OUTPUT OPEN DRAIN | 112 | // OUTPUT OPEN DRAIN |
| 113 | #[cfg(feature = "rp2040")] | ||
| 107 | { | 114 | { |
| 108 | let mut b = OutputOpenDrain::new(&mut b, Level::High); | 115 | let mut b = OutputOpenDrain::new(&mut b, Level::High); |
| 109 | let mut a = Flex::new(&mut a); | 116 | let mut a = Flex::new(&mut a); |
| @@ -202,6 +209,7 @@ async fn main(_spawner: Spawner) { | |||
| 202 | } | 209 | } |
| 203 | 210 | ||
| 204 | // Test input pulldown | 211 | // Test input pulldown |
| 212 | #[cfg(feature = "rp2040")] | ||
| 205 | { | 213 | { |
| 206 | let mut b = Flex::new(&mut b); | 214 | let mut b = Flex::new(&mut b); |
| 207 | b.set_as_input(); | 215 | b.set_as_input(); |
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 40a304464..39e3d6337 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert, *}; | 8 | use defmt::{assert, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs index e9c6f3122..3caa8ef35 100644 --- a/tests/rp/src/bin/gpio_multicore.rs +++ b/tests/rp/src/bin/gpio_multicore.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
| @@ -56,7 +59,7 @@ async fn core1_task(p: PIN_1) { | |||
| 56 | 59 | ||
| 57 | CHANNEL0.receive().await; | 60 | CHANNEL0.receive().await; |
| 58 | 61 | ||
| 59 | let mut pin = Input::new(p, Pull::Down); | 62 | let mut pin = Input::new(p, Pull::None); |
| 60 | let wait = pin.wait_for_rising_edge(); | 63 | let wait = pin.wait_for_rising_edge(); |
| 61 | 64 | ||
| 62 | CHANNEL1.send(()).await; | 65 | CHANNEL1.send(()).await; |
diff --git a/tests/rp/src/bin/i2c.rs b/tests/rp/src/bin/i2c.rs index 9615007bd..2c835bd5a 100644 --- a/tests/rp/src/bin/i2c.rs +++ b/tests/rp/src/bin/i2c.rs | |||
| @@ -1,23 +1,21 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, info, panic, unwrap}; | 8 | use defmt::{assert_eq, info, panic}; |
| 6 | use embassy_embedded_hal::SetConfig; | 9 | use embassy_embedded_hal::SetConfig; |
| 7 | use embassy_executor::{Executor, Spawner}; | 10 | use embassy_executor::Spawner; |
| 8 | use embassy_rp::clocks::{PllConfig, XoscConfig}; | 11 | use embassy_rp::clocks::{PllConfig, XoscConfig}; |
| 9 | use embassy_rp::config::Config as rpConfig; | 12 | use embassy_rp::config::Config as rpConfig; |
| 10 | use embassy_rp::multicore::{spawn_core1, Stack}; | ||
| 11 | use embassy_rp::peripherals::{I2C0, I2C1}; | 13 | use embassy_rp::peripherals::{I2C0, I2C1}; |
| 12 | use embassy_rp::{bind_interrupts, i2c, i2c_slave}; | 14 | use embassy_rp::{bind_interrupts, i2c, i2c_slave}; |
| 13 | use embedded_hal_1::i2c::Operation; | 15 | use embedded_hal_1::i2c::Operation; |
| 14 | use embedded_hal_async::i2c::I2c; | 16 | use embedded_hal_async::i2c::I2c; |
| 15 | use static_cell::StaticCell; | ||
| 16 | use {defmt_rtt as _, panic_probe as _, panic_probe as _, panic_probe as _}; | 17 | use {defmt_rtt as _, panic_probe as _, panic_probe as _, panic_probe as _}; |
| 17 | 18 | ||
| 18 | static mut CORE1_STACK: Stack<1024> = Stack::new(); | ||
| 19 | static EXECUTOR1: StaticCell<Executor> = StaticCell::new(); | ||
| 20 | |||
| 21 | use crate::i2c::AbortReason; | 19 | use crate::i2c::AbortReason; |
| 22 | 20 | ||
| 23 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| @@ -106,7 +104,7 @@ async fn device_task(mut dev: i2c_slave::I2cSlave<'static, I2C1>) -> ! { | |||
| 106 | } | 104 | } |
| 107 | 105 | ||
| 108 | async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { | 106 | async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { |
| 109 | info!("Device start"); | 107 | info!("Controller start"); |
| 110 | 108 | ||
| 111 | { | 109 | { |
| 112 | let buf = [0xCA, 0x11]; | 110 | let buf = [0xCA, 0x11]; |
| @@ -180,7 +178,7 @@ async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { | |||
| 180 | } | 178 | } |
| 181 | 179 | ||
| 182 | #[embassy_executor::main] | 180 | #[embassy_executor::main] |
| 183 | async fn main(_core0_spawner: Spawner) { | 181 | async fn main(spawner: Spawner) { |
| 184 | let mut config = rpConfig::default(); | 182 | let mut config = rpConfig::default(); |
| 185 | // Configure clk_sys to 48MHz to support 1kHz scl. | 183 | // Configure clk_sys to 48MHz to support 1kHz scl. |
| 186 | // In theory it can go lower, but we won't bother to test below 1kHz. | 184 | // In theory it can go lower, but we won't bother to test below 1kHz. |
| @@ -210,14 +208,7 @@ async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { | |||
| 210 | config.addr = DEV_ADDR as u16; | 208 | config.addr = DEV_ADDR as u16; |
| 211 | let device = i2c_slave::I2cSlave::new(p.I2C1, d_sda, d_scl, Irqs, config); | 209 | let device = i2c_slave::I2cSlave::new(p.I2C1, d_sda, d_scl, Irqs, config); |
| 212 | 210 | ||
| 213 | spawn_core1( | 211 | spawner.must_spawn(device_task(device)); |
| 214 | p.CORE1, | ||
| 215 | unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, | ||
| 216 | move || { | ||
| 217 | let executor1 = EXECUTOR1.init(Executor::new()); | ||
| 218 | executor1.run(|spawner| unwrap!(spawner.spawn(device_task(device)))); | ||
| 219 | }, | ||
| 220 | ); | ||
| 221 | 212 | ||
| 222 | let c_sda = p.PIN_21; | 213 | let c_sda = p.PIN_21; |
| 223 | let c_scl = p.PIN_20; | 214 | let c_scl = p.PIN_20; |
diff --git a/tests/rp/src/bin/multicore.rs b/tests/rp/src/bin/multicore.rs index 783ea0f27..902169c40 100644 --- a/tests/rp/src/bin/multicore.rs +++ b/tests/rp/src/bin/multicore.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{info, unwrap}; | 8 | use defmt::{info, unwrap}; |
| 6 | use embassy_executor::Executor; | 9 | use embassy_executor::Executor; |
diff --git a/tests/rp/src/bin/pio_irq.rs b/tests/rp/src/bin/pio_irq.rs index 1fee6dc2f..dc37dd83d 100644 --- a/tests/rp/src/bin/pio_irq.rs +++ b/tests/rp/src/bin/pio_irq.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::info; | 8 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/pio_multi_load.rs b/tests/rp/src/bin/pio_multi_load.rs index 71321015b..aca476d56 100644 --- a/tests/rp/src/bin/pio_multi_load.rs +++ b/tests/rp/src/bin/pio_multi_load.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::info; | 8 | use defmt::info; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index c05197000..d8ee78dcd 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs | |||
| @@ -1,10 +1,15 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert, assert_eq, assert_ne, *}; | 8 | use defmt::{assert, assert_eq, assert_ne, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
| 7 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | 10 | use embassy_rp::gpio::{Input, Pull}; |
| 11 | #[cfg(feature = "rp2040")] | ||
| 12 | use embassy_rp::gpio::{Level, Output}; | ||
| 8 | use embassy_rp::pwm::{Config, InputMode, Pwm}; | 13 | use embassy_rp::pwm::{Config, InputMode, Pwm}; |
| 9 | use embassy_time::Timer; | 14 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 15 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -92,6 +97,7 @@ async fn main(_spawner: Spawner) { | |||
| 92 | } | 97 | } |
| 93 | 98 | ||
| 94 | // Test level-gated | 99 | // Test level-gated |
| 100 | #[cfg(feature = "rp2040")] | ||
| 95 | { | 101 | { |
| 96 | let mut pin2 = Output::new(&mut p11, Level::Low); | 102 | let mut pin2 = Output::new(&mut p11, Level::Low); |
| 97 | let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, Pull::None, InputMode::Level, cfg.clone()); | 103 | let pwm = Pwm::new_input(&mut p.PWM_SLICE3, &mut p7, Pull::None, InputMode::Level, cfg.clone()); |
| @@ -102,12 +108,14 @@ async fn main(_spawner: Spawner) { | |||
| 102 | Timer::after_millis(1).await; | 108 | Timer::after_millis(1).await; |
| 103 | pin2.set_low(); | 109 | pin2.set_low(); |
| 104 | let ctr = pwm.counter(); | 110 | let ctr = pwm.counter(); |
| 111 | info!("ctr: {}", ctr); | ||
| 105 | assert!(ctr >= 1000); | 112 | assert!(ctr >= 1000); |
| 106 | Timer::after_millis(1).await; | 113 | Timer::after_millis(1).await; |
| 107 | assert_eq!(pwm.counter(), ctr); | 114 | assert_eq!(pwm.counter(), ctr); |
| 108 | } | 115 | } |
| 109 | 116 | ||
| 110 | // Test rising-gated | 117 | // Test rising-gated |
| 118 | #[cfg(feature = "rp2040")] | ||
| 111 | { | 119 | { |
| 112 | let mut pin2 = Output::new(&mut p11, Level::Low); | 120 | let mut pin2 = Output::new(&mut p11, Level::Low); |
| 113 | let pwm = Pwm::new_input( | 121 | let pwm = Pwm::new_input( |
| @@ -129,6 +137,7 @@ async fn main(_spawner: Spawner) { | |||
| 129 | } | 137 | } |
| 130 | 138 | ||
| 131 | // Test falling-gated | 139 | // Test falling-gated |
| 140 | #[cfg(feature = "rp2040")] | ||
| 132 | { | 141 | { |
| 133 | let mut pin2 = Output::new(&mut p11, Level::High); | 142 | let mut pin2 = Output::new(&mut p11, Level::High); |
| 134 | let pwm = Pwm::new_input( | 143 | let pwm = Pwm::new_input( |
diff --git a/tests/rp/src/bin/spi.rs b/tests/rp/src/bin/spi.rs index 4b02942a7..6802bfc99 100644 --- a/tests/rp/src/bin/spi.rs +++ b/tests/rp/src/bin/spi.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, *}; | 8 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/spi_async.rs b/tests/rp/src/bin/spi_async.rs index efdc80b53..e50667435 100644 --- a/tests/rp/src/bin/spi_async.rs +++ b/tests/rp/src/bin/spi_async.rs | |||
| @@ -3,7 +3,10 @@ | |||
| 3 | //! | 3 | //! |
| 4 | #![no_std] | 4 | #![no_std] |
| 5 | #![no_main] | 5 | #![no_main] |
| 6 | #[cfg(feature = "rp2040")] | ||
| 6 | teleprobe_meta::target!(b"rpi-pico"); | 7 | teleprobe_meta::target!(b"rpi-pico"); |
| 8 | #[cfg(feature = "rp235xb")] | ||
| 9 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 7 | 10 | ||
| 8 | use defmt::{assert_eq, *}; | 11 | use defmt::{assert_eq, *}; |
| 9 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/timer.rs b/tests/rp/src/bin/timer.rs index be9242144..12a4d7daa 100644 --- a/tests/rp/src/bin/timer.rs +++ b/tests/rp/src/bin/timer.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert, *}; | 8 | use defmt::{assert, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs index 6e6e5517b..67cfa6bc8 100644 --- a/tests/rp/src/bin/uart.rs +++ b/tests/rp/src/bin/uart.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, *}; | 8 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index d68c23cbd..a543320e0 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, panic, *}; | 8 | use defmt::{assert_eq, panic, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs index edc87175a..bdf94e78c 100644 --- a/tests/rp/src/bin/uart_dma.rs +++ b/tests/rp/src/bin/uart_dma.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, *}; | 8 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_upgrade.rs b/tests/rp/src/bin/uart_upgrade.rs index 603e20f2f..f658b6b8c 100644 --- a/tests/rp/src/bin/uart_upgrade.rs +++ b/tests/rp/src/bin/uart_upgrade.rs | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #[cfg(feature = "rp2040")] | ||
| 3 | teleprobe_meta::target!(b"rpi-pico"); | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | #[cfg(feature = "rp235xb")] | ||
| 6 | teleprobe_meta::target!(b"pimoroni-pico-plus-2"); | ||
| 4 | 7 | ||
| 5 | use defmt::{assert_eq, *}; | 8 | use defmt::{assert_eq, *}; |
| 6 | use embassy_executor::Spawner; | 9 | use embassy_executor::Spawner; |
