diff options
| author | xoviat <[email protected]> | 2023-08-22 16:58:43 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-08-22 16:58:43 -0500 |
| commit | 7d6edd7b15d2209ac0b96ff8814ecefce2964e36 (patch) | |
| tree | 7988a9b46855ac187a92cbfc5f38cbbbff695e8d /tests | |
| parent | 9e3266b74554ea397bdd963ff12a26aa51e77b63 (diff) | |
| parent | 7bff2ebab3b36cc922505e9db961840109c509ed (diff) | |
Merge branch 'main' of https://github.com/embassy-rs/embassy into rtc-lp
Diffstat (limited to 'tests')
30 files changed, 550 insertions, 72 deletions
diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml index 974a9413f..034ed85ea 100644 --- a/tests/nrf/Cargo.toml +++ b/tests/nrf/Cargo.toml | |||
| @@ -15,7 +15,9 @@ embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defm | |||
| 15 | embedded-io-async = { version = "0.5.0" } | 15 | embedded-io-async = { version = "0.5.0" } |
| 16 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } | 16 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } |
| 17 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } | 17 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } |
| 18 | embedded-hal-async = { version = "0.2.0-alpha.2" } | 18 | embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } |
| 19 | embedded-hal-async = { version = "1.0.0-rc.1" } | ||
| 20 | embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] } | ||
| 19 | static_cell = { version = "1.1", features = [ "nightly" ] } | 21 | static_cell = { version = "1.1", features = [ "nightly" ] } |
| 20 | 22 | ||
| 21 | defmt = "0.3" | 23 | defmt = "0.3" |
diff --git a/tests/nrf/src/bin/buffered_uart.rs b/tests/nrf/src/bin/buffered_uart.rs index 72a4cb4ef..932e59264 100644 --- a/tests/nrf/src/bin/buffered_uart.rs +++ b/tests/nrf/src/bin/buffered_uart.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"nrf52840-dk"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/nrf/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs index 50960206f..8abeae6d4 100644 --- a/tests/nrf/src/bin/buffered_uart_spam.rs +++ b/tests/nrf/src/bin/buffered_uart_spam.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"nrf52840-dk"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use core::mem; | 6 | use core::mem; |
| 8 | use core::ptr::NonNull; | 7 | use core::ptr::NonNull; |
diff --git a/tests/nrf/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs new file mode 100644 index 000000000..0446d39ac --- /dev/null +++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs | |||
| @@ -0,0 +1,250 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | teleprobe_meta::target!(b"ak-gwe-r7"); | ||
| 5 | teleprobe_meta::timeout!(120); | ||
| 6 | |||
| 7 | use defmt::{error, info, unwrap}; | ||
| 8 | use embassy_executor::Spawner; | ||
| 9 | use embassy_futures::join::join; | ||
| 10 | use embassy_net::tcp::TcpSocket; | ||
| 11 | use embassy_net::{Ipv4Address, Stack, StackResources}; | ||
| 12 | use embassy_net_enc28j60::Enc28j60; | ||
| 13 | use embassy_nrf::gpio::{Level, Output, OutputDrive}; | ||
| 14 | use embassy_nrf::rng::Rng; | ||
| 15 | use embassy_nrf::spim::{self, Spim}; | ||
| 16 | use embassy_nrf::{bind_interrupts, peripherals}; | ||
| 17 | use embassy_time::{with_timeout, Delay, Duration, Timer}; | ||
| 18 | use embedded_hal_bus::spi::ExclusiveDevice; | ||
| 19 | use static_cell::make_static; | ||
| 20 | use {defmt_rtt as _, panic_probe as _}; | ||
| 21 | |||
| 22 | bind_interrupts!(struct Irqs { | ||
| 23 | SPIM3 => spim::InterruptHandler<peripherals::SPI3>; | ||
| 24 | RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; | ||
| 25 | }); | ||
| 26 | |||
| 27 | type MyDriver = Enc28j60< | ||
| 28 | ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_15>, Delay>, | ||
| 29 | Output<'static, peripherals::P0_13>, | ||
| 30 | >; | ||
| 31 | |||
| 32 | #[embassy_executor::task] | ||
| 33 | async fn net_task(stack: &'static Stack<MyDriver>) -> ! { | ||
| 34 | stack.run().await | ||
| 35 | } | ||
| 36 | |||
| 37 | #[embassy_executor::main] | ||
| 38 | async fn main(spawner: Spawner) { | ||
| 39 | let p = embassy_nrf::init(Default::default()); | ||
| 40 | info!("running!"); | ||
| 41 | |||
| 42 | let eth_sck = p.P0_20; | ||
| 43 | let eth_mosi = p.P0_22; | ||
| 44 | let eth_miso = p.P0_24; | ||
| 45 | let eth_cs = p.P0_15; | ||
| 46 | let eth_rst = p.P0_13; | ||
| 47 | let _eth_irq = p.P0_12; | ||
| 48 | |||
| 49 | let mut config = spim::Config::default(); | ||
| 50 | config.frequency = spim::Frequency::M16; | ||
| 51 | let spi = spim::Spim::new(p.SPI3, Irqs, eth_sck, eth_miso, eth_mosi, config); | ||
| 52 | let cs = Output::new(eth_cs, Level::High, OutputDrive::Standard); | ||
| 53 | let spi = ExclusiveDevice::new(spi, cs, Delay); | ||
| 54 | |||
| 55 | let rst = Output::new(eth_rst, Level::High, OutputDrive::Standard); | ||
| 56 | let mac_addr = [2, 3, 4, 5, 6, 7]; | ||
| 57 | let device = Enc28j60::new(spi, Some(rst), mac_addr); | ||
| 58 | |||
| 59 | let config = embassy_net::Config::dhcpv4(Default::default()); | ||
| 60 | // let config = embassy_net::Config::ipv4_static(embassy_net::StaticConfigV4 { | ||
| 61 | // address: Ipv4Cidr::new(Ipv4Address::new(10, 42, 0, 61), 24), | ||
| 62 | // dns_servers: Vec::new(), | ||
| 63 | // gateway: Some(Ipv4Address::new(10, 42, 0, 1)), | ||
| 64 | // }); | ||
| 65 | |||
| 66 | // Generate random seed | ||
| 67 | let mut rng = Rng::new(p.RNG, Irqs); | ||
| 68 | let mut seed = [0; 8]; | ||
| 69 | rng.blocking_fill_bytes(&mut seed); | ||
| 70 | let seed = u64::from_le_bytes(seed); | ||
| 71 | |||
| 72 | // Init network stack | ||
| 73 | let stack = &*make_static!(Stack::new( | ||
| 74 | device, | ||
| 75 | config, | ||
| 76 | make_static!(StackResources::<2>::new()), | ||
| 77 | seed | ||
| 78 | )); | ||
| 79 | |||
| 80 | unwrap!(spawner.spawn(net_task(stack))); | ||
| 81 | |||
| 82 | info!("Waiting for DHCP up..."); | ||
| 83 | while stack.config_v4().is_none() { | ||
| 84 | Timer::after(Duration::from_millis(100)).await; | ||
| 85 | } | ||
| 86 | info!("IP addressing up!"); | ||
| 87 | |||
| 88 | let down = test_download(stack).await; | ||
| 89 | let up = test_upload(stack).await; | ||
| 90 | let updown = test_upload_download(stack).await; | ||
| 91 | |||
| 92 | assert!(down > TEST_EXPECTED_DOWNLOAD_KBPS); | ||
| 93 | assert!(up > TEST_EXPECTED_UPLOAD_KBPS); | ||
| 94 | assert!(updown > TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS); | ||
| 95 | |||
| 96 | info!("Test OK"); | ||
| 97 | cortex_m::asm::bkpt(); | ||
| 98 | } | ||
| 99 | |||
| 100 | const TEST_DURATION: usize = 10; | ||
| 101 | const TEST_EXPECTED_DOWNLOAD_KBPS: usize = 200; | ||
| 102 | const TEST_EXPECTED_UPLOAD_KBPS: usize = 200; | ||
| 103 | const TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS: usize = 150; | ||
| 104 | const RX_BUFFER_SIZE: usize = 4096; | ||
| 105 | const TX_BUFFER_SIZE: usize = 4096; | ||
| 106 | const SERVER_ADDRESS: Ipv4Address = Ipv4Address::new(192, 168, 2, 2); | ||
| 107 | const DOWNLOAD_PORT: u16 = 4321; | ||
| 108 | const UPLOAD_PORT: u16 = 4322; | ||
| 109 | const UPLOAD_DOWNLOAD_PORT: u16 = 4323; | ||
| 110 | |||
| 111 | async fn test_download(stack: &'static Stack<MyDriver>) -> usize { | ||
| 112 | info!("Testing download..."); | ||
| 113 | |||
| 114 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 115 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 116 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 117 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 118 | |||
| 119 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, DOWNLOAD_PORT); | ||
| 120 | if let Err(e) = socket.connect((SERVER_ADDRESS, DOWNLOAD_PORT)).await { | ||
| 121 | error!("connect error: {:?}", e); | ||
| 122 | return 0; | ||
| 123 | } | ||
| 124 | info!("connected, testing..."); | ||
| 125 | |||
| 126 | let mut rx_buf = [0; 4096]; | ||
| 127 | let mut total: usize = 0; | ||
| 128 | with_timeout(Duration::from_secs(TEST_DURATION as _), async { | ||
| 129 | loop { | ||
| 130 | match socket.read(&mut rx_buf).await { | ||
| 131 | Ok(0) => { | ||
| 132 | error!("read EOF"); | ||
| 133 | return 0; | ||
| 134 | } | ||
| 135 | Ok(n) => total += n, | ||
| 136 | Err(e) => { | ||
| 137 | error!("read error: {:?}", e); | ||
| 138 | return 0; | ||
| 139 | } | ||
| 140 | } | ||
| 141 | } | ||
| 142 | }) | ||
| 143 | .await | ||
| 144 | .ok(); | ||
| 145 | |||
| 146 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 147 | info!("download: {} kB/s", kbps); | ||
| 148 | kbps | ||
| 149 | } | ||
| 150 | |||
| 151 | async fn test_upload(stack: &'static Stack<MyDriver>) -> usize { | ||
| 152 | info!("Testing upload..."); | ||
| 153 | |||
| 154 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 155 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 156 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 157 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 158 | |||
| 159 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, UPLOAD_PORT); | ||
| 160 | if let Err(e) = socket.connect((SERVER_ADDRESS, UPLOAD_PORT)).await { | ||
| 161 | error!("connect error: {:?}", e); | ||
| 162 | return 0; | ||
| 163 | } | ||
| 164 | info!("connected, testing..."); | ||
| 165 | |||
| 166 | let buf = [0; 4096]; | ||
| 167 | let mut total: usize = 0; | ||
| 168 | with_timeout(Duration::from_secs(TEST_DURATION as _), async { | ||
| 169 | loop { | ||
| 170 | match socket.write(&buf).await { | ||
| 171 | Ok(0) => { | ||
| 172 | error!("write zero?!??!?!"); | ||
| 173 | return 0; | ||
| 174 | } | ||
| 175 | Ok(n) => total += n, | ||
| 176 | Err(e) => { | ||
| 177 | error!("write error: {:?}", e); | ||
| 178 | return 0; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | }) | ||
| 183 | .await | ||
| 184 | .ok(); | ||
| 185 | |||
| 186 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 187 | info!("upload: {} kB/s", kbps); | ||
| 188 | kbps | ||
| 189 | } | ||
| 190 | |||
| 191 | async fn test_upload_download(stack: &'static Stack<MyDriver>) -> usize { | ||
| 192 | info!("Testing upload+download..."); | ||
| 193 | |||
| 194 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 195 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 196 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 197 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 198 | |||
| 199 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, UPLOAD_DOWNLOAD_PORT); | ||
| 200 | if let Err(e) = socket.connect((SERVER_ADDRESS, UPLOAD_DOWNLOAD_PORT)).await { | ||
| 201 | error!("connect error: {:?}", e); | ||
| 202 | return 0; | ||
| 203 | } | ||
| 204 | info!("connected, testing..."); | ||
| 205 | |||
| 206 | let (mut reader, mut writer) = socket.split(); | ||
| 207 | |||
| 208 | let tx_buf = [0; 4096]; | ||
| 209 | let mut rx_buf = [0; 4096]; | ||
| 210 | let mut total: usize = 0; | ||
| 211 | let tx_fut = async { | ||
| 212 | loop { | ||
| 213 | match writer.write(&tx_buf).await { | ||
| 214 | Ok(0) => { | ||
| 215 | error!("write zero?!??!?!"); | ||
| 216 | return 0; | ||
| 217 | } | ||
| 218 | Ok(_) => {} | ||
| 219 | Err(e) => { | ||
| 220 | error!("write error: {:?}", e); | ||
| 221 | return 0; | ||
| 222 | } | ||
| 223 | } | ||
| 224 | } | ||
| 225 | }; | ||
| 226 | |||
| 227 | let rx_fut = async { | ||
| 228 | loop { | ||
| 229 | match reader.read(&mut rx_buf).await { | ||
| 230 | Ok(0) => { | ||
| 231 | error!("read EOF"); | ||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | Ok(n) => total += n, | ||
| 235 | Err(e) => { | ||
| 236 | error!("read error: {:?}", e); | ||
| 237 | return 0; | ||
| 238 | } | ||
| 239 | } | ||
| 240 | } | ||
| 241 | }; | ||
| 242 | |||
| 243 | with_timeout(Duration::from_secs(TEST_DURATION as _), join(tx_fut, rx_fut)) | ||
| 244 | .await | ||
| 245 | .ok(); | ||
| 246 | |||
| 247 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 248 | info!("upload+download: {} kB/s", kbps); | ||
| 249 | kbps | ||
| 250 | } | ||
diff --git a/tests/nrf/src/bin/timer.rs b/tests/nrf/src/bin/timer.rs index 607c5bbf1..c00f35fd1 100644 --- a/tests/nrf/src/bin/timer.rs +++ b/tests/nrf/src/bin/timer.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"nrf52840-dk"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert, info}; | 6 | use defmt::{assert, info}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs index e2adfe0be..97ebafec8 100644 --- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs +++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs | |||
| @@ -1,9 +1,8 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | 4 | teleprobe_meta::target!(b"nrf52840-dk"); | |
| 5 | #[path = "../common.rs"] | 5 | teleprobe_meta::timeout!(120); |
| 6 | mod common; | ||
| 7 | 6 | ||
| 8 | use defmt::{error, info, unwrap}; | 7 | use defmt::{error, info, unwrap}; |
| 9 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| @@ -15,12 +14,10 @@ use embassy_nrf::rng::Rng; | |||
| 15 | use embassy_nrf::spim::{self, Spim}; | 14 | use embassy_nrf::spim::{self, Spim}; |
| 16 | use embassy_nrf::{bind_interrupts, peripherals}; | 15 | use embassy_nrf::{bind_interrupts, peripherals}; |
| 17 | use embassy_time::{with_timeout, Delay, Duration, Timer}; | 16 | use embassy_time::{with_timeout, Delay, Duration, Timer}; |
| 18 | use embedded_hal_async::spi::ExclusiveDevice; | 17 | use embedded_hal_bus::spi::ExclusiveDevice; |
| 19 | use static_cell::make_static; | 18 | use static_cell::make_static; |
| 20 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; | 19 | use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; |
| 21 | 20 | ||
| 22 | teleprobe_meta::timeout!(120); | ||
| 23 | |||
| 24 | bind_interrupts!(struct Irqs { | 21 | bind_interrupts!(struct Irqs { |
| 25 | SPIM3 => spim::InterruptHandler<peripherals::SPI3>; | 22 | SPIM3 => spim::InterruptHandler<peripherals::SPI3>; |
| 26 | RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; | 23 | RNG => embassy_nrf::rng::InterruptHandler<peripherals::RNG>; |
| @@ -76,8 +73,8 @@ async fn main(spawner: Spawner) { | |||
| 76 | 73 | ||
| 77 | unwrap!(spawner.spawn(wifi_task(runner))); | 74 | unwrap!(spawner.spawn(wifi_task(runner))); |
| 78 | 75 | ||
| 79 | control.init().await; | 76 | unwrap!(control.init().await); |
| 80 | control.join(WIFI_NETWORK, WIFI_PASSWORD).await; | 77 | unwrap!(control.connect(WIFI_NETWORK, WIFI_PASSWORD).await); |
| 81 | 78 | ||
| 82 | // Generate random seed | 79 | // Generate random seed |
| 83 | let mut rng = Rng::new(p.RNG, Irqs); | 80 | let mut rng = Rng::new(p.RNG, Irqs); |
diff --git a/tests/nrf/src/common.rs b/tests/nrf/src/common.rs deleted file mode 100644 index 1a05ac1c5..000000000 --- a/tests/nrf/src/common.rs +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | teleprobe_meta::target!(b"nrf52840-dk"); | ||
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml index 90a3bd0cf..6a3df4b9c 100644 --- a/tests/rp/Cargo.toml +++ b/tests/rp/Cargo.toml | |||
| @@ -9,10 +9,11 @@ teleprobe-meta = "1.1" | |||
| 9 | 9 | ||
| 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 11 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt"] } | 12 | embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits"] } |
| 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } | 13 | embassy-rp = { version = "0.1.0", path = "../../embassy-rp", features = ["nightly", "defmt", "unstable-pac", "unstable-traits", "time-driver", "critical-section-impl", "intrinsics", "rom-v2-intrinsics", "run-from-ram"] } |
| 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | 14 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } |
| 15 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } | 15 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } |
| 16 | embassy-net-wiznet = { version = "0.1.0", path = "../../embassy-net-wiznet", features = ["defmt"] } | ||
| 16 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } | 17 | cyw43 = { path = "../../cyw43", features = ["defmt", "firmware-logs"] } |
| 17 | cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } | 18 | cyw43-pio = { path = "../../cyw43-pio", features = ["defmt", "overclock"] } |
| 18 | 19 | ||
| @@ -22,8 +23,9 @@ defmt-rtt = "0.4" | |||
| 22 | cortex-m = { version = "0.7.6" } | 23 | cortex-m = { version = "0.7.6" } |
| 23 | cortex-m-rt = "0.7.0" | 24 | cortex-m-rt = "0.7.0" |
| 24 | embedded-hal = "0.2.6" | 25 | embedded-hal = "0.2.6" |
| 25 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } | 26 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } |
| 26 | embedded-hal-async = { version = "=0.2.0-alpha.2" } | 27 | embedded-hal-async = { version = "=1.0.0-rc.1" } |
| 28 | embedded-hal-bus = { version = "=0.1.0-rc.1", features = ["async"] } | ||
| 27 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 29 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 28 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | 30 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } |
| 29 | embedded-io-async = { version = "0.5.0" } | 31 | embedded-io-async = { version = "0.5.0" } |
| @@ -31,6 +33,7 @@ embedded-storage = { version = "0.3" } | |||
| 31 | static_cell = { version = "1.1", features = ["nightly"]} | 33 | static_cell = { version = "1.1", features = ["nightly"]} |
| 32 | pio = "0.2" | 34 | pio = "0.2" |
| 33 | pio-proc = "0.2" | 35 | pio-proc = "0.2" |
| 36 | rand = { version = "0.8.5", default-features = false } | ||
| 34 | 37 | ||
| 35 | [profile.dev] | 38 | [profile.dev] |
| 36 | debug = 2 | 39 | debug = 2 |
diff --git a/tests/rp/src/bin/adc.rs b/tests/rp/src/bin/adc.rs index b29a3a7cb..0250fd5f4 100644 --- a/tests/rp/src/bin/adc.rs +++ b/tests/rp/src/bin/adc.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::*; | 6 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs index fffdabc9b..1c665f95d 100644 --- a/tests/rp/src/bin/cyw43-perf.rs +++ b/tests/rp/src/bin/cyw43-perf.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use cyw43_pio::PioSpi; | 6 | use cyw43_pio::PioSpi; |
| 8 | use defmt::{assert, panic, *}; | 7 | use defmt::{assert, panic, *}; |
diff --git a/tests/rp/src/bin/dma_copy_async.rs b/tests/rp/src/bin/dma_copy_async.rs index 2c0b559a9..b071ed9df 100644 --- a/tests/rp/src/bin/dma_copy_async.rs +++ b/tests/rp/src/bin/dma_copy_async.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/ethernet_w5100s_perf.rs b/tests/rp/src/bin/ethernet_w5100s_perf.rs new file mode 100644 index 000000000..faa8638c0 --- /dev/null +++ b/tests/rp/src/bin/ethernet_w5100s_perf.rs | |||
| @@ -0,0 +1,249 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | teleprobe_meta::target!(b"w5100s-evb-pico"); | ||
| 5 | teleprobe_meta::timeout!(120); | ||
| 6 | |||
| 7 | use defmt::{assert, *}; | ||
| 8 | use embassy_executor::Spawner; | ||
| 9 | use embassy_futures::join::join; | ||
| 10 | use embassy_net::tcp::TcpSocket; | ||
| 11 | use embassy_net::{Ipv4Address, Stack, StackResources}; | ||
| 12 | use embassy_net_wiznet::chip::W5100S; | ||
| 13 | use embassy_net_wiznet::*; | ||
| 14 | use embassy_rp::clocks::RoscRng; | ||
| 15 | use embassy_rp::gpio::{Input, Level, Output, Pull}; | ||
| 16 | use embassy_rp::peripherals::{PIN_17, PIN_20, PIN_21, SPI0}; | ||
| 17 | use embassy_rp::spi::{Async, Config as SpiConfig, Spi}; | ||
| 18 | use embassy_time::{with_timeout, Delay, Duration, Timer}; | ||
| 19 | use embedded_hal_bus::spi::ExclusiveDevice; | ||
| 20 | use rand::RngCore; | ||
| 21 | use static_cell::make_static; | ||
| 22 | use {defmt_rtt as _, panic_probe as _}; | ||
| 23 | |||
| 24 | #[embassy_executor::task] | ||
| 25 | async fn ethernet_task( | ||
| 26 | runner: Runner< | ||
| 27 | 'static, | ||
| 28 | W5100S, | ||
| 29 | ExclusiveDevice<Spi<'static, SPI0, Async>, Output<'static, PIN_17>, Delay>, | ||
| 30 | Input<'static, PIN_21>, | ||
| 31 | Output<'static, PIN_20>, | ||
| 32 | >, | ||
| 33 | ) -> ! { | ||
| 34 | runner.run().await | ||
| 35 | } | ||
| 36 | |||
| 37 | #[embassy_executor::task] | ||
| 38 | async fn net_task(stack: &'static Stack<Device<'static>>) -> ! { | ||
| 39 | stack.run().await | ||
| 40 | } | ||
| 41 | |||
| 42 | #[embassy_executor::main] | ||
| 43 | async fn main(spawner: Spawner) { | ||
| 44 | let p = embassy_rp::init(Default::default()); | ||
| 45 | let mut rng = RoscRng; | ||
| 46 | |||
| 47 | let mut spi_cfg = SpiConfig::default(); | ||
| 48 | spi_cfg.frequency = 50_000_000; | ||
| 49 | let (miso, mosi, clk) = (p.PIN_16, p.PIN_19, p.PIN_18); | ||
| 50 | let spi = Spi::new(p.SPI0, clk, mosi, miso, p.DMA_CH0, p.DMA_CH1, spi_cfg); | ||
| 51 | let cs = Output::new(p.PIN_17, Level::High); | ||
| 52 | let w5500_int = Input::new(p.PIN_21, Pull::Up); | ||
| 53 | let w5500_reset = Output::new(p.PIN_20, Level::High); | ||
| 54 | |||
| 55 | let mac_addr = [0x02, 0x00, 0x00, 0x00, 0x00, 0x00]; | ||
| 56 | let state = make_static!(State::<8, 8>::new()); | ||
| 57 | let (device, runner) = embassy_net_wiznet::new( | ||
| 58 | mac_addr, | ||
| 59 | state, | ||
| 60 | ExclusiveDevice::new(spi, cs, Delay), | ||
| 61 | w5500_int, | ||
| 62 | w5500_reset, | ||
| 63 | ) | ||
| 64 | .await; | ||
| 65 | unwrap!(spawner.spawn(ethernet_task(runner))); | ||
| 66 | |||
| 67 | // Generate random seed | ||
| 68 | let seed = rng.next_u64(); | ||
| 69 | |||
| 70 | // Init network stack | ||
| 71 | let stack = &*make_static!(Stack::new( | ||
| 72 | device, | ||
| 73 | embassy_net::Config::dhcpv4(Default::default()), | ||
| 74 | make_static!(StackResources::<2>::new()), | ||
| 75 | seed | ||
| 76 | )); | ||
| 77 | |||
| 78 | // Launch network task | ||
| 79 | unwrap!(spawner.spawn(net_task(&stack))); | ||
| 80 | |||
| 81 | info!("Waiting for DHCP up..."); | ||
| 82 | while stack.config_v4().is_none() { | ||
| 83 | Timer::after(Duration::from_millis(100)).await; | ||
| 84 | } | ||
| 85 | info!("IP addressing up!"); | ||
| 86 | |||
| 87 | let down = test_download(stack).await; | ||
| 88 | let up = test_upload(stack).await; | ||
| 89 | let updown = test_upload_download(stack).await; | ||
| 90 | |||
| 91 | assert!(down > TEST_EXPECTED_DOWNLOAD_KBPS); | ||
| 92 | assert!(up > TEST_EXPECTED_UPLOAD_KBPS); | ||
| 93 | assert!(updown > TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS); | ||
| 94 | |||
| 95 | info!("Test OK"); | ||
| 96 | cortex_m::asm::bkpt(); | ||
| 97 | } | ||
| 98 | |||
| 99 | const TEST_DURATION: usize = 10; | ||
| 100 | const TEST_EXPECTED_DOWNLOAD_KBPS: usize = 500; | ||
| 101 | const TEST_EXPECTED_UPLOAD_KBPS: usize = 500; | ||
| 102 | const TEST_EXPECTED_UPLOAD_DOWNLOAD_KBPS: usize = 300; | ||
| 103 | const RX_BUFFER_SIZE: usize = 4096; | ||
| 104 | const TX_BUFFER_SIZE: usize = 4096; | ||
| 105 | const SERVER_ADDRESS: Ipv4Address = Ipv4Address::new(192, 168, 2, 2); | ||
| 106 | const DOWNLOAD_PORT: u16 = 4321; | ||
| 107 | const UPLOAD_PORT: u16 = 4322; | ||
| 108 | const UPLOAD_DOWNLOAD_PORT: u16 = 4323; | ||
| 109 | |||
| 110 | async fn test_download(stack: &'static Stack<cyw43::NetDriver<'static>>) -> usize { | ||
| 111 | info!("Testing download..."); | ||
| 112 | |||
| 113 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 114 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 115 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 116 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 117 | |||
| 118 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, DOWNLOAD_PORT); | ||
| 119 | if let Err(e) = socket.connect((SERVER_ADDRESS, DOWNLOAD_PORT)).await { | ||
| 120 | error!("connect error: {:?}", e); | ||
| 121 | return 0; | ||
| 122 | } | ||
| 123 | info!("connected, testing..."); | ||
| 124 | |||
| 125 | let mut rx_buf = [0; 4096]; | ||
| 126 | let mut total: usize = 0; | ||
| 127 | with_timeout(Duration::from_secs(TEST_DURATION as _), async { | ||
| 128 | loop { | ||
| 129 | match socket.read(&mut rx_buf).await { | ||
| 130 | Ok(0) => { | ||
| 131 | error!("read EOF"); | ||
| 132 | return 0; | ||
| 133 | } | ||
| 134 | Ok(n) => total += n, | ||
| 135 | Err(e) => { | ||
| 136 | error!("read error: {:?}", e); | ||
| 137 | return 0; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | } | ||
| 141 | }) | ||
| 142 | .await | ||
| 143 | .ok(); | ||
| 144 | |||
| 145 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 146 | info!("download: {} kB/s", kbps); | ||
| 147 | kbps | ||
| 148 | } | ||
| 149 | |||
| 150 | async fn test_upload(stack: &'static Stack<cyw43::NetDriver<'static>>) -> usize { | ||
| 151 | info!("Testing upload..."); | ||
| 152 | |||
| 153 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 154 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 155 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 156 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 157 | |||
| 158 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, UPLOAD_PORT); | ||
| 159 | if let Err(e) = socket.connect((SERVER_ADDRESS, UPLOAD_PORT)).await { | ||
| 160 | error!("connect error: {:?}", e); | ||
| 161 | return 0; | ||
| 162 | } | ||
| 163 | info!("connected, testing..."); | ||
| 164 | |||
| 165 | let buf = [0; 4096]; | ||
| 166 | let mut total: usize = 0; | ||
| 167 | with_timeout(Duration::from_secs(TEST_DURATION as _), async { | ||
| 168 | loop { | ||
| 169 | match socket.write(&buf).await { | ||
| 170 | Ok(0) => { | ||
| 171 | error!("write zero?!??!?!"); | ||
| 172 | return 0; | ||
| 173 | } | ||
| 174 | Ok(n) => total += n, | ||
| 175 | Err(e) => { | ||
| 176 | error!("write error: {:?}", e); | ||
| 177 | return 0; | ||
| 178 | } | ||
| 179 | } | ||
| 180 | } | ||
| 181 | }) | ||
| 182 | .await | ||
| 183 | .ok(); | ||
| 184 | |||
| 185 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 186 | info!("upload: {} kB/s", kbps); | ||
| 187 | kbps | ||
| 188 | } | ||
| 189 | |||
| 190 | async fn test_upload_download(stack: &'static Stack<cyw43::NetDriver<'static>>) -> usize { | ||
| 191 | info!("Testing upload+download..."); | ||
| 192 | |||
| 193 | let mut rx_buffer = [0; RX_BUFFER_SIZE]; | ||
| 194 | let mut tx_buffer = [0; TX_BUFFER_SIZE]; | ||
| 195 | let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer); | ||
| 196 | socket.set_timeout(Some(Duration::from_secs(10))); | ||
| 197 | |||
| 198 | info!("connecting to {:?}:{}...", SERVER_ADDRESS, UPLOAD_DOWNLOAD_PORT); | ||
| 199 | if let Err(e) = socket.connect((SERVER_ADDRESS, UPLOAD_DOWNLOAD_PORT)).await { | ||
| 200 | error!("connect error: {:?}", e); | ||
| 201 | return 0; | ||
| 202 | } | ||
| 203 | info!("connected, testing..."); | ||
| 204 | |||
| 205 | let (mut reader, mut writer) = socket.split(); | ||
| 206 | |||
| 207 | let tx_buf = [0; 4096]; | ||
| 208 | let mut rx_buf = [0; 4096]; | ||
| 209 | let mut total: usize = 0; | ||
| 210 | let tx_fut = async { | ||
| 211 | loop { | ||
| 212 | match writer.write(&tx_buf).await { | ||
| 213 | Ok(0) => { | ||
| 214 | error!("write zero?!??!?!"); | ||
| 215 | return 0; | ||
| 216 | } | ||
| 217 | Ok(_) => {} | ||
| 218 | Err(e) => { | ||
| 219 | error!("write error: {:?}", e); | ||
| 220 | return 0; | ||
| 221 | } | ||
| 222 | } | ||
| 223 | } | ||
| 224 | }; | ||
| 225 | |||
| 226 | let rx_fut = async { | ||
| 227 | loop { | ||
| 228 | match reader.read(&mut rx_buf).await { | ||
| 229 | Ok(0) => { | ||
| 230 | error!("read EOF"); | ||
| 231 | return 0; | ||
| 232 | } | ||
| 233 | Ok(n) => total += n, | ||
| 234 | Err(e) => { | ||
| 235 | error!("read error: {:?}", e); | ||
| 236 | return 0; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | } | ||
| 240 | }; | ||
| 241 | |||
| 242 | with_timeout(Duration::from_secs(TEST_DURATION as _), join(tx_fut, rx_fut)) | ||
| 243 | .await | ||
| 244 | .ok(); | ||
| 245 | |||
| 246 | let kbps = (total + 512) / 1024 / TEST_DURATION; | ||
| 247 | info!("upload+download: {} kB/s", kbps); | ||
| 248 | kbps | ||
| 249 | } | ||
diff --git a/tests/rp/src/bin/flash.rs b/tests/rp/src/bin/flash.rs index c31d6decf..75be2bf06 100644 --- a/tests/rp/src/bin/flash.rs +++ b/tests/rp/src/bin/flash.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::*; | 6 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
| @@ -26,23 +25,23 @@ async fn main(_spawner: Spawner) { | |||
| 26 | 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); |
| 27 | 26 | ||
| 28 | // Get JEDEC id | 27 | // Get JEDEC id |
| 29 | let jedec = defmt::unwrap!(flash.jedec_id()); | 28 | let jedec = defmt::unwrap!(flash.blocking_jedec_id()); |
| 30 | info!("jedec id: 0x{:x}", jedec); | 29 | info!("jedec id: 0x{:x}", jedec); |
| 31 | 30 | ||
| 32 | // Get unique id | 31 | // Get unique id |
| 33 | let mut uid = [0; 8]; | 32 | let mut uid = [0; 8]; |
| 34 | defmt::unwrap!(flash.unique_id(&mut uid)); | 33 | defmt::unwrap!(flash.blocking_unique_id(&mut uid)); |
| 35 | info!("unique id: {:?}", uid); | 34 | info!("unique id: {:?}", uid); |
| 36 | 35 | ||
| 37 | let mut buf = [0u8; ERASE_SIZE]; | 36 | let mut buf = [0u8; ERASE_SIZE]; |
| 38 | defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); | 37 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf)); |
| 39 | 38 | ||
| 40 | info!("Addr of flash block is {:x}", ADDR_OFFSET + FLASH_BASE as u32); | 39 | info!("Addr of flash block is {:x}", ADDR_OFFSET + FLASH_BASE as u32); |
| 41 | info!("Contents start with {=[u8]}", buf[0..4]); | 40 | info!("Contents start with {=[u8]}", buf[0..4]); |
| 42 | 41 | ||
| 43 | defmt::unwrap!(flash.erase(ADDR_OFFSET, ADDR_OFFSET + ERASE_SIZE as u32)); | 42 | defmt::unwrap!(flash.blocking_erase(ADDR_OFFSET, ADDR_OFFSET + ERASE_SIZE as u32)); |
| 44 | 43 | ||
| 45 | defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); | 44 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf)); |
| 46 | info!("Contents after erase starts with {=[u8]}", buf[0..4]); | 45 | info!("Contents after erase starts with {=[u8]}", buf[0..4]); |
| 47 | if buf.iter().any(|x| *x != 0xFF) { | 46 | if buf.iter().any(|x| *x != 0xFF) { |
| 48 | defmt::panic!("unexpected"); | 47 | defmt::panic!("unexpected"); |
| @@ -52,9 +51,9 @@ async fn main(_spawner: Spawner) { | |||
| 52 | *b = 0xDA; | 51 | *b = 0xDA; |
| 53 | } | 52 | } |
| 54 | 53 | ||
| 55 | defmt::unwrap!(flash.write(ADDR_OFFSET, &mut buf)); | 54 | defmt::unwrap!(flash.blocking_write(ADDR_OFFSET, &mut buf)); |
| 56 | 55 | ||
| 57 | defmt::unwrap!(flash.read(ADDR_OFFSET, &mut buf)); | 56 | defmt::unwrap!(flash.blocking_read(ADDR_OFFSET, &mut buf)); |
| 58 | info!("Contents after write starts with {=[u8]}", buf[0..4]); | 57 | info!("Contents after write starts with {=[u8]}", buf[0..4]); |
| 59 | if buf.iter().any(|x| *x != 0xDA) { | 58 | if buf.iter().any(|x| *x != 0xDA) { |
| 60 | defmt::panic!("unexpected"); | 59 | defmt::panic!("unexpected"); |
diff --git a/tests/rp/src/bin/float.rs b/tests/rp/src/bin/float.rs index 0e0de85fa..2874aa910 100644 --- a/tests/rp/src/bin/float.rs +++ b/tests/rp/src/bin/float.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::*; | 6 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs index 946b7dc88..1a43a9283 100644 --- a/tests/rp/src/bin/gpio.rs +++ b/tests/rp/src/bin/gpio.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert, *}; | 6 | use defmt::{assert, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/gpio_async.rs b/tests/rp/src/bin/gpio_async.rs index 532494de5..60c65b7a0 100644 --- a/tests/rp/src/bin/gpio_async.rs +++ b/tests/rp/src/bin/gpio_async.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert, *}; | 6 | use defmt::{assert, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/gpio_multicore.rs b/tests/rp/src/bin/gpio_multicore.rs index 780112bc1..6ab7f6717 100644 --- a/tests/rp/src/bin/gpio_multicore.rs +++ b/tests/rp/src/bin/gpio_multicore.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{info, unwrap}; | 6 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| @@ -38,11 +37,11 @@ async fn core0_task(p: PIN_0) { | |||
| 38 | let mut pin = Output::new(p, Level::Low); | 37 | let mut pin = Output::new(p, Level::Low); |
| 39 | 38 | ||
| 40 | CHANNEL0.send(()).await; | 39 | CHANNEL0.send(()).await; |
| 41 | CHANNEL1.recv().await; | 40 | CHANNEL1.receive().await; |
| 42 | 41 | ||
| 43 | pin.set_high(); | 42 | pin.set_high(); |
| 44 | 43 | ||
| 45 | CHANNEL1.recv().await; | 44 | CHANNEL1.receive().await; |
| 46 | 45 | ||
| 47 | info!("Test OK"); | 46 | info!("Test OK"); |
| 48 | cortex_m::asm::bkpt(); | 47 | cortex_m::asm::bkpt(); |
| @@ -52,7 +51,7 @@ async fn core0_task(p: PIN_0) { | |||
| 52 | async fn core1_task(p: PIN_1) { | 51 | async fn core1_task(p: PIN_1) { |
| 53 | info!("CORE1 is running"); | 52 | info!("CORE1 is running"); |
| 54 | 53 | ||
| 55 | CHANNEL0.recv().await; | 54 | CHANNEL0.receive().await; |
| 56 | 55 | ||
| 57 | let mut pin = Input::new(p, Pull::Down); | 56 | let mut pin = Input::new(p, Pull::Down); |
| 58 | let wait = pin.wait_for_rising_edge(); | 57 | let wait = pin.wait_for_rising_edge(); |
diff --git a/tests/rp/src/bin/multicore.rs b/tests/rp/src/bin/multicore.rs index 114889dec..f4188135e 100644 --- a/tests/rp/src/bin/multicore.rs +++ b/tests/rp/src/bin/multicore.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{info, unwrap}; | 6 | use defmt::{info, unwrap}; |
| 8 | use embassy_executor::Executor; | 7 | use embassy_executor::Executor; |
| @@ -34,7 +33,7 @@ async fn core0_task() { | |||
| 34 | info!("CORE0 is running"); | 33 | info!("CORE0 is running"); |
| 35 | let ping = true; | 34 | let ping = true; |
| 36 | CHANNEL0.send(ping).await; | 35 | CHANNEL0.send(ping).await; |
| 37 | let pong = CHANNEL1.recv().await; | 36 | let pong = CHANNEL1.receive().await; |
| 38 | assert_eq!(ping, pong); | 37 | assert_eq!(ping, pong); |
| 39 | 38 | ||
| 40 | info!("Test OK"); | 39 | info!("Test OK"); |
| @@ -44,6 +43,6 @@ async fn core0_task() { | |||
| 44 | #[embassy_executor::task] | 43 | #[embassy_executor::task] |
| 45 | async fn core1_task() { | 44 | async fn core1_task() { |
| 46 | info!("CORE1 is running"); | 45 | info!("CORE1 is running"); |
| 47 | let ping = CHANNEL0.recv().await; | 46 | let ping = CHANNEL0.receive().await; |
| 48 | CHANNEL1.send(ping).await; | 47 | CHANNEL1.send(ping).await; |
| 49 | } | 48 | } |
diff --git a/tests/rp/src/bin/pio_irq.rs b/tests/rp/src/bin/pio_irq.rs index bdea63eaa..c71e55d91 100644 --- a/tests/rp/src/bin/pio_irq.rs +++ b/tests/rp/src/bin/pio_irq.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::info; | 6 | use defmt::info; |
| 8 | use embassy_executor::Spawner; | 7 | 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 356f16795..6343ff3a9 100644 --- a/tests/rp/src/bin/pio_multi_load.rs +++ b/tests/rp/src/bin/pio_multi_load.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::info; | 6 | use defmt::info; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/pwm.rs b/tests/rp/src/bin/pwm.rs index c71d21ef9..8c02b8441 100644 --- a/tests/rp/src/bin/pwm.rs +++ b/tests/rp/src/bin/pwm.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert, assert_eq, assert_ne, *}; | 6 | use defmt::{assert, assert_eq, assert_ne, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/spi.rs b/tests/rp/src/bin/spi.rs index 84dfa5a2c..f347b80ca 100644 --- a/tests/rp/src/bin/spi.rs +++ b/tests/rp/src/bin/spi.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/spi_async.rs b/tests/rp/src/bin/spi_async.rs index a4080b03d..80d5a7147 100644 --- a/tests/rp/src/bin/spi_async.rs +++ b/tests/rp/src/bin/spi_async.rs | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | #![no_std] | 4 | #![no_std] |
| 5 | #![no_main] | 5 | #![no_main] |
| 6 | #![feature(type_alias_impl_trait)] | 6 | #![feature(type_alias_impl_trait)] |
| 7 | #[path = "../common.rs"] | 7 | teleprobe_meta::target!(b"rpi-pico"); |
| 8 | mod common; | ||
| 9 | 8 | ||
| 10 | use defmt::{assert_eq, *}; | 9 | use defmt::{assert_eq, *}; |
| 11 | use embassy_executor::Spawner; | 10 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart.rs b/tests/rp/src/bin/uart.rs index 2331c7d36..00f3e1949 100644 --- a/tests/rp/src/bin/uart.rs +++ b/tests/rp/src/bin/uart.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_buffered.rs b/tests/rp/src/bin/uart_buffered.rs index edabf55b7..6ab7de29e 100644 --- a/tests/rp/src/bin/uart_buffered.rs +++ b/tests/rp/src/bin/uart_buffered.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, panic, *}; | 6 | use defmt::{assert_eq, panic, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_dma.rs b/tests/rp/src/bin/uart_dma.rs index fee6c825d..cd4af1ef2 100644 --- a/tests/rp/src/bin/uart_dma.rs +++ b/tests/rp/src/bin/uart_dma.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/bin/uart_upgrade.rs b/tests/rp/src/bin/uart_upgrade.rs index effd0bc49..c07fc08cd 100644 --- a/tests/rp/src/bin/uart_upgrade.rs +++ b/tests/rp/src/bin/uart_upgrade.rs | |||
| @@ -1,8 +1,7 @@ | |||
| 1 | #![no_std] | 1 | #![no_std] |
| 2 | #![no_main] | 2 | #![no_main] |
| 3 | #![feature(type_alias_impl_trait)] | 3 | #![feature(type_alias_impl_trait)] |
| 4 | #[path = "../common.rs"] | 4 | teleprobe_meta::target!(b"rpi-pico"); |
| 5 | mod common; | ||
| 6 | 5 | ||
| 7 | use defmt::{assert_eq, *}; | 6 | use defmt::{assert_eq, *}; |
| 8 | use embassy_executor::Spawner; | 7 | use embassy_executor::Spawner; |
diff --git a/tests/rp/src/common.rs b/tests/rp/src/common.rs deleted file mode 100644 index 955674f27..000000000 --- a/tests/rp/src/common.rs +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | teleprobe_meta::target!(b"rpi-pico"); | ||
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml index 17320649e..e26388976 100644 --- a/tests/stm32/Cargo.toml +++ b/tests/stm32/Cargo.toml | |||
| @@ -41,8 +41,8 @@ defmt-rtt = "0.4" | |||
| 41 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | 41 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } |
| 42 | cortex-m-rt = "0.7.0" | 42 | cortex-m-rt = "0.7.0" |
| 43 | embedded-hal = "0.2.6" | 43 | embedded-hal = "0.2.6" |
| 44 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" } | 44 | embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-rc.1" } |
| 45 | embedded-hal-async = { version = "=0.2.0-alpha.2" } | 45 | embedded-hal-async = { version = "=1.0.0-rc.1" } |
| 46 | micromath = "2.0.0" | 46 | micromath = "2.0.0" |
| 47 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } | 47 | panic-probe = { version = "0.3.0", features = ["print-defmt"] } |
| 48 | rand_core = { version = "0.6", default-features = false } | 48 | rand_core = { version = "0.6", default-features = false } |
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs index 8737ca8ee..acf545216 100644 --- a/tests/stm32/src/bin/can.rs +++ b/tests/stm32/src/bin/can.rs | |||
| @@ -80,8 +80,8 @@ async fn main(_spawner: Spawner) { | |||
| 80 | const MIN_LATENCY: Duration = Duration::from_micros(50); | 80 | const MIN_LATENCY: Duration = Duration::from_micros(50); |
| 81 | const MAX_LATENCY: Duration = Duration::from_micros(150); | 81 | const MAX_LATENCY: Duration = Duration::from_micros(150); |
| 82 | assert!( | 82 | assert!( |
| 83 | MIN_LATENCY < latency && latency < MAX_LATENCY, | 83 | MIN_LATENCY <= latency && latency <= MAX_LATENCY, |
| 84 | "{} < {} < {}", | 84 | "{} <= {} <= {}", |
| 85 | MIN_LATENCY, | 85 | MIN_LATENCY, |
| 86 | latency, | 86 | latency, |
| 87 | MAX_LATENCY | 87 | MAX_LATENCY |
