aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2024-06-25 22:27:56 +0200
committerDario Nieuwenhuis <[email protected]>2024-06-25 22:29:07 +0200
commitcab17434d5411558e7fb9f260665ec8da88118a9 (patch)
tree4494cfc59064cfa896e3f9ce530d6fd4ccbcfcd9
parent3ae2f140f9c794577b5bc10c43c21b9824dc3b9a (diff)
tests/nrf: unify, add nrf52832, nrf52833, nrf5340, nrf9160
-rwxr-xr-xci.sh8
-rw-r--r--tests/nrf/.cargo/config.toml (renamed from tests/nrf52840/.cargo/config.toml)2
-rw-r--r--tests/nrf/Cargo.toml98
-rw-r--r--tests/nrf/build.rs37
-rw-r--r--tests/nrf/gen_test.py44
-rw-r--r--tests/nrf/memory-nrf51422.x5
-rw-r--r--tests/nrf/memory-nrf52832.x5
-rw-r--r--tests/nrf/memory-nrf52833.x5
-rw-r--r--tests/nrf/memory-nrf52840.x (renamed from tests/nrf52840/memory.x)0
-rw-r--r--tests/nrf/memory-nrf5340.x5
-rw-r--r--tests/nrf/memory-nrf9160.x5
-rw-r--r--tests/nrf/src/bin/buffered_uart.rs (renamed from tests/nrf52840/src/bin/buffered_uart.rs)1
-rw-r--r--tests/nrf/src/bin/buffered_uart_full.rs (renamed from tests/nrf52840/src/bin/buffered_uart_full.rs)1
-rw-r--r--tests/nrf/src/bin/buffered_uart_halves.rs (renamed from tests/nrf52840/src/bin/buffered_uart_halves.rs)1
-rw-r--r--tests/nrf/src/bin/buffered_uart_spam.rs (renamed from tests/nrf52840/src/bin/buffered_uart_spam.rs)1
-rw-r--r--tests/nrf/src/bin/ethernet_enc28j60_perf.rs (renamed from tests/nrf52840/src/bin/ethernet_enc28j60_perf.rs)1
-rw-r--r--tests/nrf/src/bin/gpio.rs (renamed from tests/nrf51422/src/bin/gpio.rs)9
-rw-r--r--tests/nrf/src/bin/gpiote.rs (renamed from tests/nrf51422/src/bin/gpiote.rs)11
-rw-r--r--tests/nrf/src/bin/timer.rs (renamed from tests/nrf51422/src/bin/timer.rs)4
-rw-r--r--tests/nrf/src/bin/wifi_esp_hosted_perf.rs (renamed from tests/nrf52840/src/bin/wifi_esp_hosted_perf.rs)1
-rw-r--r--tests/nrf/src/common.rs65
-rw-r--r--tests/nrf51422/.cargo/config.toml9
-rw-r--r--tests/nrf51422/Cargo.toml23
-rw-r--r--tests/nrf51422/build.rs17
-rw-r--r--tests/nrf51422/memory.x5
-rw-r--r--tests/nrf52840/Cargo.toml29
-rw-r--r--tests/nrf52840/build.rs17
-rw-r--r--tests/nrf52840/src/bin/timer.rs24
28 files changed, 298 insertions, 135 deletions
diff --git a/ci.sh b/ci.sh
index 36a6dea30..04877dcd3 100755
--- a/ci.sh
+++ b/ci.sh
@@ -258,8 +258,12 @@ cargo batch \
258 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h503rb --out-dir out/tests/stm32h503rb \ 258 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h503rb --out-dir out/tests/stm32h503rb \
259 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u083rc --out-dir out/tests/stm32u083rc \ 259 --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u083rc --out-dir out/tests/stm32u083rc \
260 --- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \ 260 --- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \
261 --- build --release --manifest-path tests/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/nrf52840-dk \ 261 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv6m-none-eabi --features nrf51422 --out-dir out/tests/nrf51422-dk \
262 --- build --release --manifest-path tests/nrf51422/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/nrf51-dk \ 262 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832 --out-dir out/tests/nrf52832-dk \
263 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833 --out-dir out/tests/nrf52833-dk \
264 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840 --out-dir out/tests/nrf52840-dk \
265 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340 --out-dir out/tests/nrf5340-dk \
266 --- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160 --out-dir out/tests/nrf9160-dk \
263 --- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \ 267 --- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \
264 $BUILD_EXTRA 268 $BUILD_EXTRA
265 269
diff --git a/tests/nrf52840/.cargo/config.toml b/tests/nrf/.cargo/config.toml
index 9d6b0313a..8f9bccbc0 100644
--- a/tests/nrf52840/.cargo/config.toml
+++ b/tests/nrf/.cargo/config.toml
@@ -3,7 +3,9 @@
3runner = "teleprobe client run" 3runner = "teleprobe client run"
4 4
5[build] 5[build]
6#target = "thumbv6m-none-eabi"
6target = "thumbv7em-none-eabi" 7target = "thumbv7em-none-eabi"
8#target = "thumbv8m.main-none-eabihf"
7 9
8[env] 10[env]
9DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" 11DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml
new file mode 100644
index 000000000..2faee70e3
--- /dev/null
+++ b/tests/nrf/Cargo.toml
@@ -0,0 +1,98 @@
1[package]
2edition = "2021"
3name = "embassy-nrf-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8teleprobe-meta = "1"
9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] }
13embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] }
15embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
16embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] }
17embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
18embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] }
19embedded-hal-async = { version = "1.0" }
20embedded-hal-bus = { version = "0.1", features = ["async"] }
21static_cell = "2"
22perf-client = { path = "../perf-client" }
23
24defmt = "0.3"
25defmt-rtt = "0.4"
26
27cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
28cortex-m-rt = "0.7.0"
29panic-probe = { version = "0.3", features = ["print-defmt"] }
30portable-atomic = { version = "1.6.0" }
31
32[features]
33nrf51422 = ["embassy-nrf/nrf51", "portable-atomic/unsafe-assume-single-core"]
34nrf52832 = ["embassy-nrf/nrf52832", "easydma"]
35nrf52833 = ["embassy-nrf/nrf52833", "easydma"]
36nrf52840 = ["embassy-nrf/nrf52840", "easydma"]
37nrf5340 = ["embassy-nrf/nrf5340-app-s", "easydma"]
38nrf9160 = ["embassy-nrf/nrf9160-s", "easydma"]
39
40easydma = []
41
42[profile.release]
43codegen-units = 1
44debug = 2
45debug-assertions = false
46incremental = false
47lto = "fat"
48opt-level = 's'
49overflow-checks = false
50
51# BEGIN TESTS
52# Generated by gen_test.py. DO NOT EDIT.
53[[bin]]
54name = "buffered_uart"
55path = "src/bin/buffered_uart.rs"
56required-features = [ "nrf52840",]
57
58[[bin]]
59name = "buffered_uart_full"
60path = "src/bin/buffered_uart_full.rs"
61required-features = [ "nrf52840",]
62
63[[bin]]
64name = "buffered_uart_halves"
65path = "src/bin/buffered_uart_halves.rs"
66required-features = [ "nrf52840",]
67
68[[bin]]
69name = "buffered_uart_spam"
70path = "src/bin/buffered_uart_spam.rs"
71required-features = [ "nrf52840",]
72
73[[bin]]
74name = "ethernet_enc28j60_perf"
75path = "src/bin/ethernet_enc28j60_perf.rs"
76required-features = [ "nrf52840",]
77
78[[bin]]
79name = "gpio"
80path = "src/bin/gpio.rs"
81required-features = []
82
83[[bin]]
84name = "gpiote"
85path = "src/bin/gpiote.rs"
86required-features = []
87
88[[bin]]
89name = "timer"
90path = "src/bin/timer.rs"
91required-features = []
92
93[[bin]]
94name = "wifi_esp_hosted_perf"
95path = "src/bin/wifi_esp_hosted_perf.rs"
96required-features = [ "nrf52840",]
97
98# END TESTS
diff --git a/tests/nrf/build.rs b/tests/nrf/build.rs
new file mode 100644
index 000000000..3c15cf10f
--- /dev/null
+++ b/tests/nrf/build.rs
@@ -0,0 +1,37 @@
1use std::error::Error;
2use std::path::PathBuf;
3use std::{env, fs};
4
5fn main() -> Result<(), Box<dyn Error>> {
6 let out = PathBuf::from(env::var("OUT_DIR").unwrap());
7
8 // copy the right memory.x
9 #[cfg(feature = "nrf51422")]
10 let memory_x = include_bytes!("memory-nrf51422.x");
11 #[cfg(feature = "nrf52832")]
12 let memory_x = include_bytes!("memory-nrf52832.x");
13 #[cfg(feature = "nrf52833")]
14 let memory_x = include_bytes!("memory-nrf52833.x");
15 #[cfg(feature = "nrf52840")]
16 let memory_x = include_bytes!("memory-nrf52840.x");
17 #[cfg(feature = "nrf5340")]
18 let memory_x = include_bytes!("memory-nrf5340.x");
19 #[cfg(feature = "nrf9160")]
20 let memory_x = include_bytes!("memory-nrf9160.x");
21 fs::write(out.join("memory.x"), memory_x).unwrap();
22
23 // copy main linker script.
24 fs::write(out.join("link_ram.x"), include_bytes!("../link_ram_cortex_m.x")).unwrap();
25 println!("cargo:rustc-link-search={}", out.display());
26 println!("cargo:rerun-if-changed=link_ram.x");
27
28 println!("cargo:rustc-link-arg-bins=--nmagic");
29 #[cfg(feature = "nrf51422")]
30 println!("cargo:rustc-link-arg-bins=-Tlink.x");
31 #[cfg(not(feature = "nrf51422"))]
32 println!("cargo:rustc-link-arg-bins=-Tlink_ram.x");
33 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
34 println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
35
36 Ok(())
37}
diff --git a/tests/nrf/gen_test.py b/tests/nrf/gen_test.py
new file mode 100644
index 000000000..daf714376
--- /dev/null
+++ b/tests/nrf/gen_test.py
@@ -0,0 +1,44 @@
1import os
2import toml
3from glob import glob
4
5abspath = os.path.abspath(__file__)
6dname = os.path.dirname(abspath)
7os.chdir(dname)
8
9# ======= load test list
10tests = {}
11for f in sorted(glob('./src/bin/*.rs')):
12 name = os.path.splitext(os.path.basename(f))[0]
13 features = []
14 with open(f, 'r') as f:
15 for line in f:
16 if line.startswith('// required-features:'):
17 features = [feature.strip() for feature in line.split(':', 2)[1].strip().split(',')]
18
19 tests[name] = features
20
21# ========= Update Cargo.toml
22
23things = {
24 'bin': [
25 {
26 'name': f'{name}',
27 'path': f'src/bin/{name}.rs',
28 'required-features': features,
29 }
30 for name, features in tests.items()
31 ]
32}
33
34SEPARATOR_START = '# BEGIN TESTS\n'
35SEPARATOR_END = '# END TESTS\n'
36HELP = '# Generated by gen_test.py. DO NOT EDIT.\n'
37with open('Cargo.toml', 'r') as f:
38 data = f.read()
39before, data = data.split(SEPARATOR_START, maxsplit=1)
40_, after = data.split(SEPARATOR_END, maxsplit=1)
41data = before + SEPARATOR_START + HELP + \
42 toml.dumps(things) + SEPARATOR_END + after
43with open('Cargo.toml', 'w') as f:
44 f.write(data)
diff --git a/tests/nrf/memory-nrf51422.x b/tests/nrf/memory-nrf51422.x
new file mode 100644
index 000000000..c140005ce
--- /dev/null
+++ b/tests/nrf/memory-nrf51422.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 256K
4 RAM : ORIGIN = 0x20000000, LENGTH = 32K
5}
diff --git a/tests/nrf/memory-nrf52832.x b/tests/nrf/memory-nrf52832.x
new file mode 100644
index 000000000..c140005ce
--- /dev/null
+++ b/tests/nrf/memory-nrf52832.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 256K
4 RAM : ORIGIN = 0x20000000, LENGTH = 32K
5}
diff --git a/tests/nrf/memory-nrf52833.x b/tests/nrf/memory-nrf52833.x
new file mode 100644
index 000000000..a4baa2dc4
--- /dev/null
+++ b/tests/nrf/memory-nrf52833.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 512K
4 RAM : ORIGIN = 0x20000000, LENGTH = 64K
5}
diff --git a/tests/nrf52840/memory.x b/tests/nrf/memory-nrf52840.x
index 58900a7bd..58900a7bd 100644
--- a/tests/nrf52840/memory.x
+++ b/tests/nrf/memory-nrf52840.x
diff --git a/tests/nrf/memory-nrf5340.x b/tests/nrf/memory-nrf5340.x
new file mode 100644
index 000000000..58900a7bd
--- /dev/null
+++ b/tests/nrf/memory-nrf5340.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
4 RAM : ORIGIN = 0x20000000, LENGTH = 256K
5}
diff --git a/tests/nrf/memory-nrf9160.x b/tests/nrf/memory-nrf9160.x
new file mode 100644
index 000000000..58900a7bd
--- /dev/null
+++ b/tests/nrf/memory-nrf9160.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
4 RAM : ORIGIN = 0x20000000, LENGTH = 256K
5}
diff --git a/tests/nrf52840/src/bin/buffered_uart.rs b/tests/nrf/src/bin/buffered_uart.rs
index a01d66d85..89314bfc9 100644
--- a/tests/nrf52840/src/bin/buffered_uart.rs
+++ b/tests/nrf/src/bin/buffered_uart.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk"); 4teleprobe_meta::target!(b"nrf52840-dk");
diff --git a/tests/nrf52840/src/bin/buffered_uart_full.rs b/tests/nrf/src/bin/buffered_uart_full.rs
index 62edaed25..a7d9a3717 100644
--- a/tests/nrf52840/src/bin/buffered_uart_full.rs
+++ b/tests/nrf/src/bin/buffered_uart_full.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk"); 4teleprobe_meta::target!(b"nrf52840-dk");
diff --git a/tests/nrf52840/src/bin/buffered_uart_halves.rs b/tests/nrf/src/bin/buffered_uart_halves.rs
index 54a9fef5b..ae1021f04 100644
--- a/tests/nrf52840/src/bin/buffered_uart_halves.rs
+++ b/tests/nrf/src/bin/buffered_uart_halves.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk"); 4teleprobe_meta::target!(b"nrf52840-dk");
diff --git a/tests/nrf52840/src/bin/buffered_uart_spam.rs b/tests/nrf/src/bin/buffered_uart_spam.rs
index 400c0df99..906723229 100644
--- a/tests/nrf52840/src/bin/buffered_uart_spam.rs
+++ b/tests/nrf/src/bin/buffered_uart_spam.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk"); 4teleprobe_meta::target!(b"nrf52840-dk");
diff --git a/tests/nrf52840/src/bin/ethernet_enc28j60_perf.rs b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs
index 33c2f4235..5f4220b1e 100644
--- a/tests/nrf52840/src/bin/ethernet_enc28j60_perf.rs
+++ b/tests/nrf/src/bin/ethernet_enc28j60_perf.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"ak-gwe-r7"); 4teleprobe_meta::target!(b"ak-gwe-r7");
diff --git a/tests/nrf51422/src/bin/gpio.rs b/tests/nrf/src/bin/gpio.rs
index 6d5a87d0a..9e809a694 100644
--- a/tests/nrf51422/src/bin/gpio.rs
+++ b/tests/nrf/src/bin/gpio.rs
@@ -1,19 +1,20 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3teleprobe_meta::target!(b"nrf51-dk"); 3
4#[path = "../common.rs"]
5mod common;
4 6
5use defmt::{assert, info}; 7use defmt::{assert, info};
6use embassy_executor::Spawner; 8use embassy_executor::Spawner;
7use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; 9use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
8use embassy_time::Timer; 10use embassy_time::Timer;
9use {defmt_rtt as _, panic_probe as _};
10 11
11#[embassy_executor::main] 12#[embassy_executor::main]
12async fn main(_spawner: Spawner) { 13async fn main(_spawner: Spawner) {
13 let p = embassy_nrf::init(Default::default()); 14 let p = embassy_nrf::init(Default::default());
14 15
15 let input = Input::new(p.P0_13, Pull::Up); 16 let input = Input::new(peri!(p, PIN_A), Pull::Up);
16 let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard); 17 let mut output = Output::new(peri!(p, PIN_B), Level::Low, OutputDrive::Standard);
17 18
18 output.set_low(); 19 output.set_low();
19 Timer::after_millis(10).await; 20 Timer::after_millis(10).await;
diff --git a/tests/nrf51422/src/bin/gpiote.rs b/tests/nrf/src/bin/gpiote.rs
index 330fe993e..0700016d1 100644
--- a/tests/nrf51422/src/bin/gpiote.rs
+++ b/tests/nrf/src/bin/gpiote.rs
@@ -1,20 +1,21 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3teleprobe_meta::target!(b"nrf51-dk"); 3
4#[path = "../common.rs"]
5mod common;
4 6
5use defmt::{assert, info}; 7use defmt::{assert, info};
6use embassy_executor::Spawner; 8use embassy_executor::Spawner;
7use embassy_futures::join::join; 9use embassy_futures::join::join;
8use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; 10use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
9use embassy_time::{Duration, Instant, Timer}; 11use embassy_time::{Duration, Instant, Timer};
10use {defmt_rtt as _, panic_probe as _};
11 12
12#[embassy_executor::main] 13#[embassy_executor::main]
13async fn main(_spawner: Spawner) { 14async fn main(_spawner: Spawner) {
14 let p = embassy_nrf::init(Default::default()); 15 let p = embassy_nrf::init(Default::default());
15 16
16 let mut input = Input::new(p.P0_13, Pull::Up); 17 let mut input = Input::new(peri!(p, PIN_A), Pull::Up);
17 let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard); 18 let mut output = Output::new(peri!(p, PIN_B), Level::Low, OutputDrive::Standard);
18 19
19 let fut1 = async { 20 let fut1 = async {
20 Timer::after_millis(100).await; 21 Timer::after_millis(100).await;
@@ -24,6 +25,7 @@ async fn main(_spawner: Spawner) {
24 let start = Instant::now(); 25 let start = Instant::now();
25 input.wait_for_high().await; 26 input.wait_for_high().await;
26 let dur = Instant::now() - start; 27 let dur = Instant::now() - start;
28 info!("took {} ms", dur.as_millis());
27 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur)); 29 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
28 }; 30 };
29 31
@@ -37,6 +39,7 @@ async fn main(_spawner: Spawner) {
37 let start = Instant::now(); 39 let start = Instant::now();
38 input.wait_for_low().await; 40 input.wait_for_low().await;
39 let dur = Instant::now() - start; 41 let dur = Instant::now() - start;
42 info!("took {} ms", dur.as_millis());
40 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur)); 43 assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
41 }; 44 };
42 45
diff --git a/tests/nrf51422/src/bin/timer.rs b/tests/nrf/src/bin/timer.rs
index cf9ea41a8..1ae9dd647 100644
--- a/tests/nrf51422/src/bin/timer.rs
+++ b/tests/nrf/src/bin/timer.rs
@@ -1,6 +1,8 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3teleprobe_meta::target!(b"nrf51-dk"); 3
4#[path = "../common.rs"]
5mod common;
4 6
5use defmt::{assert, info}; 7use defmt::{assert, info};
6use embassy_executor::Spawner; 8use embassy_executor::Spawner;
diff --git a/tests/nrf52840/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
index b83edddc4..a6c93c8a6 100644
--- a/tests/nrf52840/src/bin/wifi_esp_hosted_perf.rs
+++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
@@ -1,3 +1,4 @@
1// required-features: nrf52840
1#![no_std] 2#![no_std]
2#![no_main] 3#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk"); 4teleprobe_meta::target!(b"nrf52840-dk");
diff --git a/tests/nrf/src/common.rs b/tests/nrf/src/common.rs
new file mode 100644
index 000000000..79336c5de
--- /dev/null
+++ b/tests/nrf/src/common.rs
@@ -0,0 +1,65 @@
1#![macro_use]
2
3use {defmt_rtt as _, panic_probe as _};
4
5#[cfg(feature = "nrf52832")]
6teleprobe_meta::target!(b"nrf52832-dk");
7#[cfg(feature = "nrf52840")]
8teleprobe_meta::target!(b"nrf52840-dk");
9#[cfg(feature = "nrf52833")]
10teleprobe_meta::target!(b"nrf52833-dk");
11#[cfg(feature = "nrf5340")]
12teleprobe_meta::target!(b"nrf5340-dk");
13#[cfg(feature = "nrf9160")]
14teleprobe_meta::target!(b"nrf9160-dk");
15#[cfg(feature = "nrf51422")]
16teleprobe_meta::target!(b"nrf51-dk");
17
18macro_rules! define_peris {
19 ($($name:ident = $peri:ident,)* $(@irq $irq_name:ident = $irq_code:tt,)*) => {
20 #[allow(unused_macros)]
21 macro_rules! peri {
22 $(
23 ($p:expr, $name) => {
24 $p.$peri
25 };
26 )*
27 }
28 #[allow(unused_macros)]
29 macro_rules! irqs {
30 $(
31 ($irq_name) => {{
32 embassy_nrf::bind_interrupts!(struct Irqs $irq_code);
33 Irqs
34 }};
35 )*
36 ( @ dummy ) => {};
37 }
38
39 #[allow(unused)]
40 #[allow(non_camel_case_types)]
41 pub mod peris {
42 $(
43 pub type $name = embassy_nrf::peripherals::$peri;
44 )*
45 }
46 };
47}
48
49#[cfg(feature = "nrf51422")]
50define_peris!(PIN_A = P0_13, PIN_B = P0_14,);
51
52#[cfg(feature = "nrf52832")]
53define_peris!(PIN_A = P0_11, PIN_B = P0_12,);
54
55#[cfg(feature = "nrf52833")]
56define_peris!(PIN_A = P1_01, PIN_B = P1_02,);
57
58#[cfg(feature = "nrf52840")]
59define_peris!(PIN_A = P1_02, PIN_B = P1_03,);
60
61#[cfg(feature = "nrf5340")]
62define_peris!(PIN_A = P1_00, PIN_B = P1_01,);
63
64#[cfg(feature = "nrf9160")]
65define_peris!(PIN_A = P0_00, PIN_B = P0_01,);
diff --git a/tests/nrf51422/.cargo/config.toml b/tests/nrf51422/.cargo/config.toml
deleted file mode 100644
index 634805633..000000000
--- a/tests/nrf51422/.cargo/config.toml
+++ /dev/null
@@ -1,9 +0,0 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2#runner = "teleprobe local run --chip nRF51422_xxAA --elf"
3runner = "teleprobe client run"
4
5[build]
6target = "thumbv6m-none-eabi"
7
8[env]
9DEFMT_LOG = "trace,embassy_hal_internal=debug"
diff --git a/tests/nrf51422/Cargo.toml b/tests/nrf51422/Cargo.toml
deleted file mode 100644
index 8bfcc2922..000000000
--- a/tests/nrf51422/Cargo.toml
+++ /dev/null
@@ -1,23 +0,0 @@
1[package]
2edition = "2021"
3name = "embassy-nrf51-tests"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8teleprobe-meta = "1"
9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
13embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
15embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
16embedded-hal-async = { version = "1.0" }
17
18defmt = "0.3"
19defmt-rtt = "0.4"
20
21cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
22cortex-m-rt = "0.7.0"
23panic-probe = { version = "0.3", features = ["print-defmt"] }
diff --git a/tests/nrf51422/build.rs b/tests/nrf51422/build.rs
deleted file mode 100644
index 13ebbe4ee..000000000
--- a/tests/nrf51422/build.rs
+++ /dev/null
@@ -1,17 +0,0 @@
1use std::error::Error;
2use std::path::PathBuf;
3use std::{env, fs};
4
5fn main() -> Result<(), Box<dyn Error>> {
6 let out = PathBuf::from(env::var("OUT_DIR").unwrap());
7 fs::write(out.join("memory.x"), include_bytes!("memory.x")).unwrap();
8 println!("cargo:rustc-link-search={}", out.display());
9 println!("cargo:rerun-if-changed=memory.x");
10
11 println!("cargo:rustc-link-arg-bins=--nmagic");
12 println!("cargo:rustc-link-arg-bins=-Tlink.x");
13 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
14 println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
15
16 Ok(())
17}
diff --git a/tests/nrf51422/memory.x b/tests/nrf51422/memory.x
deleted file mode 100644
index a5881e66f..000000000
--- a/tests/nrf51422/memory.x
+++ /dev/null
@@ -1,5 +0,0 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x00000000, LENGTH = 128K
4 RAM : ORIGIN = 0x20000000, LENGTH = 16K
5}
diff --git a/tests/nrf52840/Cargo.toml b/tests/nrf52840/Cargo.toml
deleted file mode 100644
index 1670b92ad..000000000
--- a/tests/nrf52840/Cargo.toml
+++ /dev/null
@@ -1,29 +0,0 @@
1[package]
2edition = "2021"
3name = "embassy-nrf-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8teleprobe-meta = "1"
9
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
12embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] }
13embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
15embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
16embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] }
17embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
18embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] }
19embedded-hal-async = { version = "1.0" }
20embedded-hal-bus = { version = "0.1", features = ["async"] }
21static_cell = "2"
22perf-client = { path = "../perf-client" }
23
24defmt = "0.3"
25defmt-rtt = "0.4"
26
27cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
28cortex-m-rt = "0.7.0"
29panic-probe = { version = "0.3", features = ["print-defmt"] }
diff --git a/tests/nrf52840/build.rs b/tests/nrf52840/build.rs
deleted file mode 100644
index 71c82a70f..000000000
--- a/tests/nrf52840/build.rs
+++ /dev/null
@@ -1,17 +0,0 @@
1use std::error::Error;
2use std::path::PathBuf;
3use std::{env, fs};
4
5fn main() -> Result<(), Box<dyn Error>> {
6 let out = PathBuf::from(env::var("OUT_DIR").unwrap());
7 fs::write(out.join("link_ram.x"), include_bytes!("../link_ram_cortex_m.x")).unwrap();
8 println!("cargo:rustc-link-search={}", out.display());
9 println!("cargo:rerun-if-changed=link_ram.x");
10
11 println!("cargo:rustc-link-arg-bins=--nmagic");
12 println!("cargo:rustc-link-arg-bins=-Tlink_ram.x");
13 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
14 println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
15
16 Ok(())
17}
diff --git a/tests/nrf52840/src/bin/timer.rs b/tests/nrf52840/src/bin/timer.rs
deleted file mode 100644
index 117947a94..000000000
--- a/tests/nrf52840/src/bin/timer.rs
+++ /dev/null
@@ -1,24 +0,0 @@
1#![no_std]
2#![no_main]
3teleprobe_meta::target!(b"nrf52840-dk");
4
5use defmt::{assert, info};
6use embassy_executor::Spawner;
7use embassy_time::{Instant, Timer};
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let _p = embassy_nrf::init(Default::default());
13 info!("Hello World!");
14
15 let start = Instant::now();
16 Timer::after_millis(100).await;
17 let end = Instant::now();
18 let ms = (end - start).as_millis();
19 info!("slept for {} ms", ms);
20 assert!(ms >= 99);
21
22 info!("Test OK");
23 cortex_m::asm::bkpt();
24}