diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-06-25 22:27:56 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-06-25 22:29:07 +0200 |
| commit | cab17434d5411558e7fb9f260665ec8da88118a9 (patch) | |
| tree | 4494cfc59064cfa896e3f9ce530d6fd4ccbcfcd9 | |
| parent | 3ae2f140f9c794577b5bc10c43c21b9824dc3b9a (diff) | |
tests/nrf: unify, add nrf52832, nrf52833, nrf5340, nrf9160
| -rwxr-xr-x | ci.sh | 8 | ||||
| -rw-r--r-- | tests/nrf/.cargo/config.toml (renamed from tests/nrf52840/.cargo/config.toml) | 2 | ||||
| -rw-r--r-- | tests/nrf/Cargo.toml | 98 | ||||
| -rw-r--r-- | tests/nrf/build.rs | 37 | ||||
| -rw-r--r-- | tests/nrf/gen_test.py | 44 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf51422.x | 5 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf52832.x | 5 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf52833.x | 5 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf52840.x (renamed from tests/nrf52840/memory.x) | 0 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf5340.x | 5 | ||||
| -rw-r--r-- | tests/nrf/memory-nrf9160.x | 5 | ||||
| -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.rs | 65 | ||||
| -rw-r--r-- | tests/nrf51422/.cargo/config.toml | 9 | ||||
| -rw-r--r-- | tests/nrf51422/Cargo.toml | 23 | ||||
| -rw-r--r-- | tests/nrf51422/build.rs | 17 | ||||
| -rw-r--r-- | tests/nrf51422/memory.x | 5 | ||||
| -rw-r--r-- | tests/nrf52840/Cargo.toml | 29 | ||||
| -rw-r--r-- | tests/nrf52840/build.rs | 17 | ||||
| -rw-r--r-- | tests/nrf52840/src/bin/timer.rs | 24 |
28 files changed, 298 insertions, 135 deletions
| @@ -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 @@ | |||
| 3 | runner = "teleprobe client run" | 3 | runner = "teleprobe client run" |
| 4 | 4 | ||
| 5 | [build] | 5 | [build] |
| 6 | #target = "thumbv6m-none-eabi" | ||
| 6 | target = "thumbv7em-none-eabi" | 7 | target = "thumbv7em-none-eabi" |
| 8 | #target = "thumbv8m.main-none-eabihf" | ||
| 7 | 9 | ||
| 8 | [env] | 10 | [env] |
| 9 | DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info" | 11 | DEFMT_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] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-nrf-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | teleprobe-meta = "1" | ||
| 9 | |||
| 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 11 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] } | ||
| 12 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 14 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] } | ||
| 15 | embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } | ||
| 16 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } | ||
| 17 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } | ||
| 18 | embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } | ||
| 19 | embedded-hal-async = { version = "1.0" } | ||
| 20 | embedded-hal-bus = { version = "0.1", features = ["async"] } | ||
| 21 | static_cell = "2" | ||
| 22 | perf-client = { path = "../perf-client" } | ||
| 23 | |||
| 24 | defmt = "0.3" | ||
| 25 | defmt-rtt = "0.4" | ||
| 26 | |||
| 27 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | ||
| 28 | cortex-m-rt = "0.7.0" | ||
| 29 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 30 | portable-atomic = { version = "1.6.0" } | ||
| 31 | |||
| 32 | [features] | ||
| 33 | nrf51422 = ["embassy-nrf/nrf51", "portable-atomic/unsafe-assume-single-core"] | ||
| 34 | nrf52832 = ["embassy-nrf/nrf52832", "easydma"] | ||
| 35 | nrf52833 = ["embassy-nrf/nrf52833", "easydma"] | ||
| 36 | nrf52840 = ["embassy-nrf/nrf52840", "easydma"] | ||
| 37 | nrf5340 = ["embassy-nrf/nrf5340-app-s", "easydma"] | ||
| 38 | nrf9160 = ["embassy-nrf/nrf9160-s", "easydma"] | ||
| 39 | |||
| 40 | easydma = [] | ||
| 41 | |||
| 42 | [profile.release] | ||
| 43 | codegen-units = 1 | ||
| 44 | debug = 2 | ||
| 45 | debug-assertions = false | ||
| 46 | incremental = false | ||
| 47 | lto = "fat" | ||
| 48 | opt-level = 's' | ||
| 49 | overflow-checks = false | ||
| 50 | |||
| 51 | # BEGIN TESTS | ||
| 52 | # Generated by gen_test.py. DO NOT EDIT. | ||
| 53 | [[bin]] | ||
| 54 | name = "buffered_uart" | ||
| 55 | path = "src/bin/buffered_uart.rs" | ||
| 56 | required-features = [ "nrf52840",] | ||
| 57 | |||
| 58 | [[bin]] | ||
| 59 | name = "buffered_uart_full" | ||
| 60 | path = "src/bin/buffered_uart_full.rs" | ||
| 61 | required-features = [ "nrf52840",] | ||
| 62 | |||
| 63 | [[bin]] | ||
| 64 | name = "buffered_uart_halves" | ||
| 65 | path = "src/bin/buffered_uart_halves.rs" | ||
| 66 | required-features = [ "nrf52840",] | ||
| 67 | |||
| 68 | [[bin]] | ||
| 69 | name = "buffered_uart_spam" | ||
| 70 | path = "src/bin/buffered_uart_spam.rs" | ||
| 71 | required-features = [ "nrf52840",] | ||
| 72 | |||
| 73 | [[bin]] | ||
| 74 | name = "ethernet_enc28j60_perf" | ||
| 75 | path = "src/bin/ethernet_enc28j60_perf.rs" | ||
| 76 | required-features = [ "nrf52840",] | ||
| 77 | |||
| 78 | [[bin]] | ||
| 79 | name = "gpio" | ||
| 80 | path = "src/bin/gpio.rs" | ||
| 81 | required-features = [] | ||
| 82 | |||
| 83 | [[bin]] | ||
| 84 | name = "gpiote" | ||
| 85 | path = "src/bin/gpiote.rs" | ||
| 86 | required-features = [] | ||
| 87 | |||
| 88 | [[bin]] | ||
| 89 | name = "timer" | ||
| 90 | path = "src/bin/timer.rs" | ||
| 91 | required-features = [] | ||
| 92 | |||
| 93 | [[bin]] | ||
| 94 | name = "wifi_esp_hosted_perf" | ||
| 95 | path = "src/bin/wifi_esp_hosted_perf.rs" | ||
| 96 | required-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 @@ | |||
| 1 | use std::error::Error; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | use std::{env, fs}; | ||
| 4 | |||
| 5 | fn 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 @@ | |||
| 1 | import os | ||
| 2 | import toml | ||
| 3 | from glob import glob | ||
| 4 | |||
| 5 | abspath = os.path.abspath(__file__) | ||
| 6 | dname = os.path.dirname(abspath) | ||
| 7 | os.chdir(dname) | ||
| 8 | |||
| 9 | # ======= load test list | ||
| 10 | tests = {} | ||
| 11 | for 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 | |||
| 23 | things = { | ||
| 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 | |||
| 34 | SEPARATOR_START = '# BEGIN TESTS\n' | ||
| 35 | SEPARATOR_END = '# END TESTS\n' | ||
| 36 | HELP = '# Generated by gen_test.py. DO NOT EDIT.\n' | ||
| 37 | with open('Cargo.toml', 'r') as f: | ||
| 38 | data = f.read() | ||
| 39 | before, data = data.split(SEPARATOR_START, maxsplit=1) | ||
| 40 | _, after = data.split(SEPARATOR_END, maxsplit=1) | ||
| 41 | data = before + SEPARATOR_START + HELP + \ | ||
| 42 | toml.dumps(things) + SEPARATOR_END + after | ||
| 43 | with 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 @@ | |||
| 1 | MEMORY | ||
| 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 @@ | |||
| 1 | MEMORY | ||
| 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 @@ | |||
| 1 | MEMORY | ||
| 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 @@ | |||
| 1 | MEMORY | ||
| 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 @@ | |||
| 1 | MEMORY | ||
| 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] |
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | 4 | teleprobe_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] |
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | 4 | teleprobe_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] |
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | 4 | teleprobe_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] |
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | 4 | teleprobe_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] |
| 3 | teleprobe_meta::target!(b"ak-gwe-r7"); | 4 | teleprobe_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] |
| 3 | teleprobe_meta::target!(b"nrf51-dk"); | 3 | |
| 4 | #[path = "../common.rs"] | ||
| 5 | mod common; | ||
| 4 | 6 | ||
| 5 | use defmt::{assert, info}; | 7 | use defmt::{assert, info}; |
| 6 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 7 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 9 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 8 | use embassy_time::Timer; | 10 | use embassy_time::Timer; |
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | 11 | ||
| 11 | #[embassy_executor::main] | 12 | #[embassy_executor::main] |
| 12 | async fn main(_spawner: Spawner) { | 13 | async 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] |
| 3 | teleprobe_meta::target!(b"nrf51-dk"); | 3 | |
| 4 | #[path = "../common.rs"] | ||
| 5 | mod common; | ||
| 4 | 6 | ||
| 5 | use defmt::{assert, info}; | 7 | use defmt::{assert, info}; |
| 6 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 7 | use embassy_futures::join::join; | 9 | use embassy_futures::join::join; |
| 8 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; | 10 | use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull}; |
| 9 | use embassy_time::{Duration, Instant, Timer}; | 11 | use embassy_time::{Duration, Instant, Timer}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | ||
| 11 | 12 | ||
| 12 | #[embassy_executor::main] | 13 | #[embassy_executor::main] |
| 13 | async fn main(_spawner: Spawner) { | 14 | async 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] |
| 3 | teleprobe_meta::target!(b"nrf51-dk"); | 3 | |
| 4 | #[path = "../common.rs"] | ||
| 5 | mod common; | ||
| 4 | 6 | ||
| 5 | use defmt::{assert, info}; | 7 | use defmt::{assert, info}; |
| 6 | use embassy_executor::Spawner; | 8 | use 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] |
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | 4 | teleprobe_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 | |||
| 3 | use {defmt_rtt as _, panic_probe as _}; | ||
| 4 | |||
| 5 | #[cfg(feature = "nrf52832")] | ||
| 6 | teleprobe_meta::target!(b"nrf52832-dk"); | ||
| 7 | #[cfg(feature = "nrf52840")] | ||
| 8 | teleprobe_meta::target!(b"nrf52840-dk"); | ||
| 9 | #[cfg(feature = "nrf52833")] | ||
| 10 | teleprobe_meta::target!(b"nrf52833-dk"); | ||
| 11 | #[cfg(feature = "nrf5340")] | ||
| 12 | teleprobe_meta::target!(b"nrf5340-dk"); | ||
| 13 | #[cfg(feature = "nrf9160")] | ||
| 14 | teleprobe_meta::target!(b"nrf9160-dk"); | ||
| 15 | #[cfg(feature = "nrf51422")] | ||
| 16 | teleprobe_meta::target!(b"nrf51-dk"); | ||
| 17 | |||
| 18 | macro_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")] | ||
| 50 | define_peris!(PIN_A = P0_13, PIN_B = P0_14,); | ||
| 51 | |||
| 52 | #[cfg(feature = "nrf52832")] | ||
| 53 | define_peris!(PIN_A = P0_11, PIN_B = P0_12,); | ||
| 54 | |||
| 55 | #[cfg(feature = "nrf52833")] | ||
| 56 | define_peris!(PIN_A = P1_01, PIN_B = P1_02,); | ||
| 57 | |||
| 58 | #[cfg(feature = "nrf52840")] | ||
| 59 | define_peris!(PIN_A = P1_02, PIN_B = P1_03,); | ||
| 60 | |||
| 61 | #[cfg(feature = "nrf5340")] | ||
| 62 | define_peris!(PIN_A = P1_00, PIN_B = P1_01,); | ||
| 63 | |||
| 64 | #[cfg(feature = "nrf9160")] | ||
| 65 | define_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" | ||
| 3 | runner = "teleprobe client run" | ||
| 4 | |||
| 5 | [build] | ||
| 6 | target = "thumbv6m-none-eabi" | ||
| 7 | |||
| 8 | [env] | ||
| 9 | DEFMT_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] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-nrf51-tests" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | teleprobe-meta = "1" | ||
| 9 | |||
| 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 11 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] } | ||
| 12 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 14 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] } | ||
| 15 | embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } | ||
| 16 | embedded-hal-async = { version = "1.0" } | ||
| 17 | |||
| 18 | defmt = "0.3" | ||
| 19 | defmt-rtt = "0.4" | ||
| 20 | |||
| 21 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | ||
| 22 | cortex-m-rt = "0.7.0" | ||
| 23 | panic-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 @@ | |||
| 1 | use std::error::Error; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | use std::{env, fs}; | ||
| 4 | |||
| 5 | fn 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 @@ | |||
| 1 | MEMORY | ||
| 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] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-nrf-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | teleprobe-meta = "1" | ||
| 9 | |||
| 10 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 11 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] } | ||
| 12 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] } | ||
| 14 | embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } | ||
| 15 | embedded-io-async = { version = "0.6.1", features = ["defmt-03"] } | ||
| 16 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] } | ||
| 17 | embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } | ||
| 18 | embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] } | ||
| 19 | embedded-hal-async = { version = "1.0" } | ||
| 20 | embedded-hal-bus = { version = "0.1", features = ["async"] } | ||
| 21 | static_cell = "2" | ||
| 22 | perf-client = { path = "../perf-client" } | ||
| 23 | |||
| 24 | defmt = "0.3" | ||
| 25 | defmt-rtt = "0.4" | ||
| 26 | |||
| 27 | cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } | ||
| 28 | cortex-m-rt = "0.7.0" | ||
| 29 | panic-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 @@ | |||
| 1 | use std::error::Error; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | use std::{env, fs}; | ||
| 4 | |||
| 5 | fn 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] | ||
| 3 | teleprobe_meta::target!(b"nrf52840-dk"); | ||
| 4 | |||
| 5 | use defmt::{assert, info}; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_time::{Instant, Timer}; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async 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 | } | ||
