aboutsummaryrefslogtreecommitdiff
path: root/tests/rp/src/bin/i2c.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rp/src/bin/i2c.rs')
-rw-r--r--tests/rp/src/bin/i2c.rs25
1 files changed, 8 insertions, 17 deletions
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")]
3teleprobe_meta::target!(b"rpi-pico"); 4teleprobe_meta::target!(b"rpi-pico");
5#[cfg(feature = "rp235xb")]
6teleprobe_meta::target!(b"pimoroni-pico-plus-2");
4 7
5use defmt::{assert_eq, info, panic, unwrap}; 8use defmt::{assert_eq, info, panic};
6use embassy_embedded_hal::SetConfig; 9use embassy_embedded_hal::SetConfig;
7use embassy_executor::{Executor, Spawner}; 10use embassy_executor::Spawner;
8use embassy_rp::clocks::{PllConfig, XoscConfig}; 11use embassy_rp::clocks::{PllConfig, XoscConfig};
9use embassy_rp::config::Config as rpConfig; 12use embassy_rp::config::Config as rpConfig;
10use embassy_rp::multicore::{spawn_core1, Stack};
11use embassy_rp::peripherals::{I2C0, I2C1}; 13use embassy_rp::peripherals::{I2C0, I2C1};
12use embassy_rp::{bind_interrupts, i2c, i2c_slave}; 14use embassy_rp::{bind_interrupts, i2c, i2c_slave};
13use embedded_hal_1::i2c::Operation; 15use embedded_hal_1::i2c::Operation;
14use embedded_hal_async::i2c::I2c; 16use embedded_hal_async::i2c::I2c;
15use static_cell::StaticCell;
16use {defmt_rtt as _, panic_probe as _, panic_probe as _, panic_probe as _}; 17use {defmt_rtt as _, panic_probe as _, panic_probe as _, panic_probe as _};
17 18
18static mut CORE1_STACK: Stack<1024> = Stack::new();
19static EXECUTOR1: StaticCell<Executor> = StaticCell::new();
20
21use crate::i2c::AbortReason; 19use crate::i2c::AbortReason;
22 20
23bind_interrupts!(struct Irqs { 21bind_interrupts!(struct Irqs {
@@ -106,7 +104,7 @@ async fn device_task(mut dev: i2c_slave::I2cSlave<'static, I2C1>) -> ! {
106} 104}
107 105
108async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) { 106async 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;