aboutsummaryrefslogtreecommitdiff
path: root/tests/rp/src/bin
diff options
context:
space:
mode:
Diffstat (limited to 'tests/rp/src/bin')
-rw-r--r--tests/rp/src/bin/cyw43-perf.rs4
-rw-r--r--tests/rp/src/bin/ethernet_w5100s_perf.rs5
-rw-r--r--tests/rp/src/bin/gpio.rs34
-rw-r--r--tests/rp/src/bin/gpio_multicore.rs4
-rw-r--r--tests/rp/src/bin/i2c.rs2
-rw-r--r--tests/rp/src/bin/multicore.rs4
-rw-r--r--tests/rp/src/bin/overclock.rs49
-rw-r--r--tests/rp/src/bin/spinlock_mutex_multicore.rs4
8 files changed, 69 insertions, 37 deletions
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs
index dba1058a8..555134ffd 100644
--- a/tests/rp/src/bin/cyw43-perf.rs
+++ b/tests/rp/src/bin/cyw43-perf.rs
@@ -70,7 +70,7 @@ async fn main(spawner: Spawner) {
70 static STATE: StaticCell<cyw43::State> = StaticCell::new(); 70 static STATE: StaticCell<cyw43::State> = StaticCell::new();
71 let state = STATE.init(cyw43::State::new()); 71 let state = STATE.init(cyw43::State::new());
72 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await; 72 let (net_device, mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
73 unwrap!(spawner.spawn(wifi_task(runner))); 73 spawner.spawn(unwrap!(wifi_task(runner)));
74 74
75 control.init(clm).await; 75 control.init(clm).await;
76 control 76 control
@@ -89,7 +89,7 @@ async fn main(spawner: Spawner) {
89 seed, 89 seed,
90 ); 90 );
91 91
92 unwrap!(spawner.spawn(net_task(runner))); 92 spawner.spawn(unwrap!(net_task(runner)));
93 93
94 loop { 94 loop {
95 match control 95 match control
diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs
index ae2adfa55..3f2bc728d 100644
--- a/tests/rp/src/bin/ethernet_w5100s_perf.rs
+++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs
@@ -14,7 +14,6 @@ use embassy_rp::peripherals::SPI0;
14use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; 14use embassy_rp::spi::{Async, Config as SpiConfig, Spi};
15use embassy_time::Delay; 15use embassy_time::Delay;
16use embedded_hal_bus::spi::ExclusiveDevice; 16use embedded_hal_bus::spi::ExclusiveDevice;
17use rand::RngCore;
18use static_cell::StaticCell; 17use static_cell::StaticCell;
19use {defmt_rtt as _, panic_probe as _}; 18use {defmt_rtt as _, panic_probe as _};
20 19
@@ -61,7 +60,7 @@ async fn main(spawner: Spawner) {
61 ) 60 )
62 .await 61 .await
63 .unwrap(); 62 .unwrap();
64 unwrap!(spawner.spawn(ethernet_task(runner))); 63 spawner.spawn(unwrap!(ethernet_task(runner)));
65 64
66 // Generate random seed 65 // Generate random seed
67 let seed = rng.next_u64(); 66 let seed = rng.next_u64();
@@ -76,7 +75,7 @@ async fn main(spawner: Spawner) {
76 ); 75 );
77 76
78 // Launch network task 77 // Launch network task
79 unwrap!(spawner.spawn(net_task(runner))); 78 spawner.spawn(unwrap!(net_task(runner)));
80 79
81 perf_client::run( 80 perf_client::run(
82 stack, 81 stack,
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs
index 614b6317a..8bd0df8d8 100644
--- a/tests/rp/src/bin/gpio.rs
+++ b/tests/rp/src/bin/gpio.rs
@@ -67,6 +67,40 @@ async fn main(_spawner: Spawner) {
67 } 67 }
68 } 68 }
69 69
70 // Test input inversion
71 {
72 let mut b = Input::new(b.reborrow(), Pull::None);
73 b.set_inversion(true);
74 // no pull, the status is undefined
75
76 let mut a = Output::new(a.reborrow(), Level::Low);
77 delay();
78 assert!(b.is_high());
79 a.set_high();
80 delay();
81 assert!(b.is_low());
82
83 b.set_inversion(false);
84 a.set_inversion(true);
85
86 a.set_low();
87 delay();
88 assert!(b.is_high());
89
90 a.set_high();
91 delay();
92 assert!(b.is_low());
93
94 b.set_inversion(true);
95 a.set_high();
96 delay();
97 assert!(b.is_high());
98
99 a.set_high();
100 delay();
101 assert!(b.is_high());
102 }
103
70 // Test input no pull 104 // Test input no pull
71 { 105 {
72 let b = Input::new(b.reborrow(), Pull::None); 106 let b = Input::new(b.reborrow(), Pull::None);
diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs
index 857f36975..f48dd207b 100644
--- a/tests/rp/src/bin/gpio_multicore.rs
+++ b/tests/rp/src/bin/gpio_multicore.rs
@@ -30,11 +30,11 @@ fn main() -> ! {
30 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, 30 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) },
31 move || { 31 move || {
32 let executor1 = EXECUTOR1.init(Executor::new()); 32 let executor1 = EXECUTOR1.init(Executor::new());
33 executor1.run(|spawner| unwrap!(spawner.spawn(core1_task(p.PIN_1)))); 33 executor1.run(|spawner| spawner.spawn(unwrap!(core1_task(p.PIN_1))));
34 }, 34 },
35 ); 35 );
36 let executor0 = EXECUTOR0.init(Executor::new()); 36 let executor0 = EXECUTOR0.init(Executor::new());
37 executor0.run(|spawner| unwrap!(spawner.spawn(core0_task(p.PIN_0)))); 37 executor0.run(|spawner| spawner.spawn(unwrap!(core0_task(p.PIN_0))));
38} 38}
39 39
40#[embassy_executor::task] 40#[embassy_executor::task]
diff --git a/tests/rp/src/bin/i2c.rs b/tests/rp/src/bin/i2c.rs
index 2c835bd5a..21761b98b 100644
--- a/tests/rp/src/bin/i2c.rs
+++ b/tests/rp/src/bin/i2c.rs
@@ -208,7 +208,7 @@ async fn controller_task(con: &mut i2c::I2c<'static, I2C0, i2c::Async>) {
208 config.addr = DEV_ADDR as u16; 208 config.addr = DEV_ADDR as u16;
209 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);
210 210
211 spawner.must_spawn(device_task(device)); 211 spawner.spawn(device_task(device).unwrap());
212 212
213 let c_sda = p.PIN_21; 213 let c_sda = p.PIN_21;
214 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 902169c40..11b03cfea 100644
--- a/tests/rp/src/bin/multicore.rs
+++ b/tests/rp/src/bin/multicore.rs
@@ -27,11 +27,11 @@ fn main() -> ! {
27 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, 27 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) },
28 move || { 28 move || {
29 let executor1 = EXECUTOR1.init(Executor::new()); 29 let executor1 = EXECUTOR1.init(Executor::new());
30 executor1.run(|spawner| unwrap!(spawner.spawn(core1_task()))); 30 executor1.run(|spawner| spawner.spawn(unwrap!(core1_task())));
31 }, 31 },
32 ); 32 );
33 let executor0 = EXECUTOR0.init(Executor::new()); 33 let executor0 = EXECUTOR0.init(Executor::new());
34 executor0.run(|spawner| unwrap!(spawner.spawn(core0_task()))); 34 executor0.run(|spawner| spawner.spawn(unwrap!(core0_task())));
35} 35}
36 36
37#[embassy_executor::task] 37#[embassy_executor::task]
diff --git a/tests/rp/src/bin/overclock.rs b/tests/rp/src/bin/overclock.rs
index be8e85a3f..167a26eb2 100644
--- a/tests/rp/src/bin/overclock.rs
+++ b/tests/rp/src/bin/overclock.rs
@@ -7,14 +7,8 @@ teleprobe_meta::target!(b"rpi-pico");
7teleprobe_meta::target!(b"pimoroni-pico-plus-2"); 7teleprobe_meta::target!(b"pimoroni-pico-plus-2");
8 8
9use defmt::info; 9use defmt::info;
10#[cfg(feature = "rp2040")]
11use defmt::{assert, assert_eq};
12use embassy_executor::Spawner; 10use embassy_executor::Spawner;
13use embassy_rp::clocks; 11use embassy_rp::clocks::{clk_sys_freq, core_voltage, ClockConfig, CoreVoltage};
14#[cfg(feature = "rp2040")]
15use embassy_rp::clocks::ClockConfig;
16#[cfg(feature = "rp2040")]
17use embassy_rp::clocks::CoreVoltage;
18use embassy_rp::config::Config; 12use embassy_rp::config::Config;
19use embassy_time::Instant; 13use embassy_time::Instant;
20use {defmt_rtt as _, panic_probe as _}; 14use {defmt_rtt as _, panic_probe as _};
@@ -23,23 +17,26 @@ const COUNT_TO: i64 = 10_000_000;
23 17
24#[embassy_executor::main] 18#[embassy_executor::main]
25async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
26 #[cfg(feature = "rp2040")]
27 let mut config = Config::default(); 20 let mut config = Config::default();
28 #[cfg(not(feature = "rp2040"))]
29 let config = Config::default();
30 21
31 // Initialize with 200MHz clock configuration for RP2040, other chips will use default clock 22 // Initialize with 200MHz clock configuration
32 #[cfg(feature = "rp2040")] 23 config.clocks = ClockConfig::system_freq(200_000_000).unwrap();
24
25 // if we are rp235x, we need to manually set the core voltage. rp2040 should do this automatically
26 #[cfg(feature = "rp235xb")]
33 { 27 {
34 config.clocks = ClockConfig::system_freq(200_000_000); 28 config.clocks.core_voltage = CoreVoltage::V1_15;
35 let voltage = config.clocks.core_voltage;
36 assert!(matches!(voltage, CoreVoltage::V1_15), "Expected voltage scale V1_15");
37 } 29 }
38 30
39 let _p = embassy_rp::init(config); 31 let _p = embassy_rp::init(config);
40 32
33 // We should be at core voltage of 1.15V
34 assert_eq!(core_voltage().unwrap(), CoreVoltage::V1_15, "Core voltage is not 1.15V");
35 // We should be at 200MHz
36 assert_eq!(clk_sys_freq(), 200_000_000, "System clock frequency is not 200MHz");
37
41 // Test the system speed 38 // Test the system speed
42 let (time_elapsed, clk_sys_freq) = { 39 let time_elapsed = {
43 let mut counter = 0; 40 let mut counter = 0;
44 let start = Instant::now(); 41 let start = Instant::now();
45 while counter < COUNT_TO { 42 while counter < COUNT_TO {
@@ -47,24 +44,26 @@ async fn main(_spawner: Spawner) {
47 } 44 }
48 let elapsed = Instant::now() - start; 45 let elapsed = Instant::now() - start;
49 46
50 (elapsed.as_millis(), clocks::clk_sys_freq()) 47 elapsed.as_millis()
51 }; 48 };
52 49
53 // Report the elapsed time, so that the compiler doesn't optimize it away for chips other than RP2040 50 // Tests will fail if unused variables are detected:
51 // Report the elapsed time, so that the compiler doesn't optimize it away for the chip not on test
54 info!( 52 info!(
55 "At {}Mhz: Elapsed time to count to {}: {}ms", 53 "At {}Mhz: Elapsed time to count to {}: {}ms",
56 clk_sys_freq / 1_000_000, 54 clk_sys_freq() / 1_000_000,
57 COUNT_TO, 55 COUNT_TO,
58 time_elapsed 56 time_elapsed
59 ); 57 );
60 58
59 // Check if the elapsed time is within expected limits
60 // for rp2040 we expect about 600ms
61 #[cfg(feature = "rp2040")] 61 #[cfg(feature = "rp2040")]
62 { 62 // allow 1% error
63 // we should be at 200MHz 63 assert!(time_elapsed < 606, "Elapsed time is too long");
64 assert_eq!(clk_sys_freq, 200_000_000, "System clock frequency is not 200MHz"); 64 // for rp235x we expect about 450ms
65 // At 200MHz, the time to count to 10_000_000 should be at 600ms, testing with 1% margin 65 #[cfg(feature = "rp235xb")]
66 assert!(time_elapsed <= 606, "Elapsed time is too long"); 66 assert!(time_elapsed < 455, "Elapsed time is too long");
67 }
68 67
69 cortex_m::asm::bkpt(); 68 cortex_m::asm::bkpt();
70} 69}
diff --git a/tests/rp/src/bin/spinlock_mutex_multicore.rs b/tests/rp/src/bin/spinlock_mutex_multicore.rs
index ebcf1ca32..c56d43ade 100644
--- a/tests/rp/src/bin/spinlock_mutex_multicore.rs
+++ b/tests/rp/src/bin/spinlock_mutex_multicore.rs
@@ -27,11 +27,11 @@ fn main() -> ! {
27 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) }, 27 unsafe { &mut *core::ptr::addr_of_mut!(CORE1_STACK) },
28 move || { 28 move || {
29 let executor1 = EXECUTOR1.init(Executor::new()); 29 let executor1 = EXECUTOR1.init(Executor::new());
30 executor1.run(|spawner| unwrap!(spawner.spawn(core1_task()))); 30 executor1.run(|spawner| spawner.spawn(unwrap!(core1_task())));
31 }, 31 },
32 ); 32 );
33 let executor0 = EXECUTOR0.init(Executor::new()); 33 let executor0 = EXECUTOR0.init(Executor::new());
34 executor0.run(|spawner| unwrap!(spawner.spawn(core0_task()))); 34 executor0.run(|spawner| spawner.spawn(unwrap!(core0_task())));
35} 35}
36 36
37#[embassy_executor::task] 37#[embassy_executor::task]