mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-11-28 17:52:28 +00:00
tests/nrf: unify, add nrf52832, nrf52833, nrf5340, nrf9160
This commit is contained in:
parent
3ae2f140f9
commit
cab17434d5
8
ci.sh
8
ci.sh
@ -258,8 +258,12 @@ cargo batch \
|
|||||||
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h503rb --out-dir out/tests/stm32h503rb \
|
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32h503rb --out-dir out/tests/stm32h503rb \
|
||||||
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u083rc --out-dir out/tests/stm32u083rc \
|
--- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv6m-none-eabi --features stm32u083rc --out-dir out/tests/stm32u083rc \
|
||||||
--- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \
|
--- build --release --manifest-path tests/rp/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/rpi-pico \
|
||||||
--- build --release --manifest-path tests/nrf52840/Cargo.toml --target thumbv7em-none-eabi --out-dir out/tests/nrf52840-dk \
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv6m-none-eabi --features nrf51422 --out-dir out/tests/nrf51422-dk \
|
||||||
--- build --release --manifest-path tests/nrf51422/Cargo.toml --target thumbv6m-none-eabi --out-dir out/tests/nrf51-dk \
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52832 --out-dir out/tests/nrf52832-dk \
|
||||||
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52833 --out-dir out/tests/nrf52833-dk \
|
||||||
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv7em-none-eabi --features nrf52840 --out-dir out/tests/nrf52840-dk \
|
||||||
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf5340 --out-dir out/tests/nrf5340-dk \
|
||||||
|
--- build --release --manifest-path tests/nrf/Cargo.toml --target thumbv8m.main-none-eabihf --features nrf9160 --out-dir out/tests/nrf9160-dk \
|
||||||
--- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \
|
--- build --release --manifest-path tests/riscv32/Cargo.toml --target riscv32imac-unknown-none-elf \
|
||||||
$BUILD_EXTRA
|
$BUILD_EXTRA
|
||||||
|
|
||||||
|
@ -3,7 +3,9 @@
|
|||||||
runner = "teleprobe client run"
|
runner = "teleprobe client run"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
|
#target = "thumbv6m-none-eabi"
|
||||||
target = "thumbv7em-none-eabi"
|
target = "thumbv7em-none-eabi"
|
||||||
|
#target = "thumbv8m.main-none-eabihf"
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
|
DEFMT_LOG = "trace,embassy_hal_internal=debug,embassy_net_esp_hosted=debug,smoltcp=info"
|
98
tests/nrf/Cargo.toml
Normal file
98
tests/nrf/Cargo.toml
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
[package]
|
||||||
|
edition = "2021"
|
||||||
|
name = "embassy-nrf-examples"
|
||||||
|
version = "0.1.0"
|
||||||
|
license = "MIT OR Apache-2.0"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
teleprobe-meta = "1"
|
||||||
|
|
||||||
|
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
||||||
|
embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
|
||||||
|
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] }
|
||||||
|
embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
||||||
|
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "time-driver-rtc1", "gpiote", "unstable-pac"] }
|
||||||
|
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
||||||
|
embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] }
|
||||||
|
embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
|
||||||
|
embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] }
|
||||||
|
embedded-hal-async = { version = "1.0" }
|
||||||
|
embedded-hal-bus = { version = "0.1", features = ["async"] }
|
||||||
|
static_cell = "2"
|
||||||
|
perf-client = { path = "../perf-client" }
|
||||||
|
|
||||||
|
defmt = "0.3"
|
||||||
|
defmt-rtt = "0.4"
|
||||||
|
|
||||||
|
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||||
|
cortex-m-rt = "0.7.0"
|
||||||
|
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
||||||
|
portable-atomic = { version = "1.6.0" }
|
||||||
|
|
||||||
|
[features]
|
||||||
|
nrf51422 = ["embassy-nrf/nrf51", "portable-atomic/unsafe-assume-single-core"]
|
||||||
|
nrf52832 = ["embassy-nrf/nrf52832", "easydma"]
|
||||||
|
nrf52833 = ["embassy-nrf/nrf52833", "easydma"]
|
||||||
|
nrf52840 = ["embassy-nrf/nrf52840", "easydma"]
|
||||||
|
nrf5340 = ["embassy-nrf/nrf5340-app-s", "easydma"]
|
||||||
|
nrf9160 = ["embassy-nrf/nrf9160-s", "easydma"]
|
||||||
|
|
||||||
|
easydma = []
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
codegen-units = 1
|
||||||
|
debug = 2
|
||||||
|
debug-assertions = false
|
||||||
|
incremental = false
|
||||||
|
lto = "fat"
|
||||||
|
opt-level = 's'
|
||||||
|
overflow-checks = false
|
||||||
|
|
||||||
|
# BEGIN TESTS
|
||||||
|
# Generated by gen_test.py. DO NOT EDIT.
|
||||||
|
[[bin]]
|
||||||
|
name = "buffered_uart"
|
||||||
|
path = "src/bin/buffered_uart.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "buffered_uart_full"
|
||||||
|
path = "src/bin/buffered_uart_full.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "buffered_uart_halves"
|
||||||
|
path = "src/bin/buffered_uart_halves.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "buffered_uart_spam"
|
||||||
|
path = "src/bin/buffered_uart_spam.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "ethernet_enc28j60_perf"
|
||||||
|
path = "src/bin/ethernet_enc28j60_perf.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "gpio"
|
||||||
|
path = "src/bin/gpio.rs"
|
||||||
|
required-features = []
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "gpiote"
|
||||||
|
path = "src/bin/gpiote.rs"
|
||||||
|
required-features = []
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "timer"
|
||||||
|
path = "src/bin/timer.rs"
|
||||||
|
required-features = []
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "wifi_esp_hosted_perf"
|
||||||
|
path = "src/bin/wifi_esp_hosted_perf.rs"
|
||||||
|
required-features = [ "nrf52840",]
|
||||||
|
|
||||||
|
# END TESTS
|
37
tests/nrf/build.rs
Normal file
37
tests/nrf/build.rs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
use std::error::Error;
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::{env, fs};
|
||||||
|
|
||||||
|
fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||||
|
|
||||||
|
// copy the right memory.x
|
||||||
|
#[cfg(feature = "nrf51422")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf51422.x");
|
||||||
|
#[cfg(feature = "nrf52832")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf52832.x");
|
||||||
|
#[cfg(feature = "nrf52833")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf52833.x");
|
||||||
|
#[cfg(feature = "nrf52840")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf52840.x");
|
||||||
|
#[cfg(feature = "nrf5340")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf5340.x");
|
||||||
|
#[cfg(feature = "nrf9160")]
|
||||||
|
let memory_x = include_bytes!("memory-nrf9160.x");
|
||||||
|
fs::write(out.join("memory.x"), memory_x).unwrap();
|
||||||
|
|
||||||
|
// copy main linker script.
|
||||||
|
fs::write(out.join("link_ram.x"), include_bytes!("../link_ram_cortex_m.x")).unwrap();
|
||||||
|
println!("cargo:rustc-link-search={}", out.display());
|
||||||
|
println!("cargo:rerun-if-changed=link_ram.x");
|
||||||
|
|
||||||
|
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||||
|
#[cfg(feature = "nrf51422")]
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||||
|
#[cfg(not(feature = "nrf51422"))]
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tlink_ram.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||||
|
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
44
tests/nrf/gen_test.py
Normal file
44
tests/nrf/gen_test.py
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
import os
|
||||||
|
import toml
|
||||||
|
from glob import glob
|
||||||
|
|
||||||
|
abspath = os.path.abspath(__file__)
|
||||||
|
dname = os.path.dirname(abspath)
|
||||||
|
os.chdir(dname)
|
||||||
|
|
||||||
|
# ======= load test list
|
||||||
|
tests = {}
|
||||||
|
for f in sorted(glob('./src/bin/*.rs')):
|
||||||
|
name = os.path.splitext(os.path.basename(f))[0]
|
||||||
|
features = []
|
||||||
|
with open(f, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
if line.startswith('// required-features:'):
|
||||||
|
features = [feature.strip() for feature in line.split(':', 2)[1].strip().split(',')]
|
||||||
|
|
||||||
|
tests[name] = features
|
||||||
|
|
||||||
|
# ========= Update Cargo.toml
|
||||||
|
|
||||||
|
things = {
|
||||||
|
'bin': [
|
||||||
|
{
|
||||||
|
'name': f'{name}',
|
||||||
|
'path': f'src/bin/{name}.rs',
|
||||||
|
'required-features': features,
|
||||||
|
}
|
||||||
|
for name, features in tests.items()
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
SEPARATOR_START = '# BEGIN TESTS\n'
|
||||||
|
SEPARATOR_END = '# END TESTS\n'
|
||||||
|
HELP = '# Generated by gen_test.py. DO NOT EDIT.\n'
|
||||||
|
with open('Cargo.toml', 'r') as f:
|
||||||
|
data = f.read()
|
||||||
|
before, data = data.split(SEPARATOR_START, maxsplit=1)
|
||||||
|
_, after = data.split(SEPARATOR_END, maxsplit=1)
|
||||||
|
data = before + SEPARATOR_START + HELP + \
|
||||||
|
toml.dumps(things) + SEPARATOR_END + after
|
||||||
|
with open('Cargo.toml', 'w') as f:
|
||||||
|
f.write(data)
|
5
tests/nrf/memory-nrf51422.x
Normal file
5
tests/nrf/memory-nrf51422.x
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 32K
|
||||||
|
}
|
5
tests/nrf/memory-nrf52832.x
Normal file
5
tests/nrf/memory-nrf52832.x
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 32K
|
||||||
|
}
|
5
tests/nrf/memory-nrf52833.x
Normal file
5
tests/nrf/memory-nrf52833.x
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x00000000, LENGTH = 512K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 64K
|
||||||
|
}
|
5
tests/nrf/memory-nrf5340.x
Normal file
5
tests/nrf/memory-nrf5340.x
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 256K
|
||||||
|
}
|
5
tests/nrf/memory-nrf9160.x
Normal file
5
tests/nrf/memory-nrf9160.x
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
|
||||||
|
RAM : ORIGIN = 0x20000000, LENGTH = 256K
|
||||||
|
}
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
teleprobe_meta::target!(b"nrf52840-dk");
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
teleprobe_meta::target!(b"nrf52840-dk");
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
teleprobe_meta::target!(b"nrf52840-dk");
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
teleprobe_meta::target!(b"nrf52840-dk");
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"ak-gwe-r7");
|
teleprobe_meta::target!(b"ak-gwe-r7");
|
@ -1,19 +1,20 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf51-dk");
|
|
||||||
|
#[path = "../common.rs"]
|
||||||
|
mod common;
|
||||||
|
|
||||||
use defmt::{assert, info};
|
use defmt::{assert, info};
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner) {
|
async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_nrf::init(Default::default());
|
let p = embassy_nrf::init(Default::default());
|
||||||
|
|
||||||
let input = Input::new(p.P0_13, Pull::Up);
|
let input = Input::new(peri!(p, PIN_A), Pull::Up);
|
||||||
let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
|
let mut output = Output::new(peri!(p, PIN_B), Level::Low, OutputDrive::Standard);
|
||||||
|
|
||||||
output.set_low();
|
output.set_low();
|
||||||
Timer::after_millis(10).await;
|
Timer::after_millis(10).await;
|
@ -1,20 +1,21 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf51-dk");
|
|
||||||
|
#[path = "../common.rs"]
|
||||||
|
mod common;
|
||||||
|
|
||||||
use defmt::{assert, info};
|
use defmt::{assert, info};
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_futures::join::join;
|
use embassy_futures::join::join;
|
||||||
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
use embassy_nrf::gpio::{Input, Level, Output, OutputDrive, Pull};
|
||||||
use embassy_time::{Duration, Instant, Timer};
|
use embassy_time::{Duration, Instant, Timer};
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
|
||||||
|
|
||||||
#[embassy_executor::main]
|
#[embassy_executor::main]
|
||||||
async fn main(_spawner: Spawner) {
|
async fn main(_spawner: Spawner) {
|
||||||
let p = embassy_nrf::init(Default::default());
|
let p = embassy_nrf::init(Default::default());
|
||||||
|
|
||||||
let mut input = Input::new(p.P0_13, Pull::Up);
|
let mut input = Input::new(peri!(p, PIN_A), Pull::Up);
|
||||||
let mut output = Output::new(p.P0_14, Level::Low, OutputDrive::Standard);
|
let mut output = Output::new(peri!(p, PIN_B), Level::Low, OutputDrive::Standard);
|
||||||
|
|
||||||
let fut1 = async {
|
let fut1 = async {
|
||||||
Timer::after_millis(100).await;
|
Timer::after_millis(100).await;
|
||||||
@ -24,6 +25,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
input.wait_for_high().await;
|
input.wait_for_high().await;
|
||||||
let dur = Instant::now() - start;
|
let dur = Instant::now() - start;
|
||||||
|
info!("took {} ms", dur.as_millis());
|
||||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
input.wait_for_low().await;
|
input.wait_for_low().await;
|
||||||
let dur = Instant::now() - start;
|
let dur = Instant::now() - start;
|
||||||
|
info!("took {} ms", dur.as_millis());
|
||||||
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
assert!((Duration::from_millis(90)..Duration::from_millis(110)).contains(&dur));
|
||||||
};
|
};
|
||||||
|
|
@ -1,6 +1,8 @@
|
|||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf51-dk");
|
|
||||||
|
#[path = "../common.rs"]
|
||||||
|
mod common;
|
||||||
|
|
||||||
use defmt::{assert, info};
|
use defmt::{assert, info};
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
@ -1,3 +1,4 @@
|
|||||||
|
// required-features: nrf52840
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
teleprobe_meta::target!(b"nrf52840-dk");
|
65
tests/nrf/src/common.rs
Normal file
65
tests/nrf/src/common.rs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
#![macro_use]
|
||||||
|
|
||||||
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf52832")]
|
||||||
|
teleprobe_meta::target!(b"nrf52832-dk");
|
||||||
|
#[cfg(feature = "nrf52840")]
|
||||||
|
teleprobe_meta::target!(b"nrf52840-dk");
|
||||||
|
#[cfg(feature = "nrf52833")]
|
||||||
|
teleprobe_meta::target!(b"nrf52833-dk");
|
||||||
|
#[cfg(feature = "nrf5340")]
|
||||||
|
teleprobe_meta::target!(b"nrf5340-dk");
|
||||||
|
#[cfg(feature = "nrf9160")]
|
||||||
|
teleprobe_meta::target!(b"nrf9160-dk");
|
||||||
|
#[cfg(feature = "nrf51422")]
|
||||||
|
teleprobe_meta::target!(b"nrf51-dk");
|
||||||
|
|
||||||
|
macro_rules! define_peris {
|
||||||
|
($($name:ident = $peri:ident,)* $(@irq $irq_name:ident = $irq_code:tt,)*) => {
|
||||||
|
#[allow(unused_macros)]
|
||||||
|
macro_rules! peri {
|
||||||
|
$(
|
||||||
|
($p:expr, $name) => {
|
||||||
|
$p.$peri
|
||||||
|
};
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
#[allow(unused_macros)]
|
||||||
|
macro_rules! irqs {
|
||||||
|
$(
|
||||||
|
($irq_name) => {{
|
||||||
|
embassy_nrf::bind_interrupts!(struct Irqs $irq_code);
|
||||||
|
Irqs
|
||||||
|
}};
|
||||||
|
)*
|
||||||
|
( @ dummy ) => {};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
#[allow(non_camel_case_types)]
|
||||||
|
pub mod peris {
|
||||||
|
$(
|
||||||
|
pub type $name = embassy_nrf::peripherals::$peri;
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf51422")]
|
||||||
|
define_peris!(PIN_A = P0_13, PIN_B = P0_14,);
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf52832")]
|
||||||
|
define_peris!(PIN_A = P0_11, PIN_B = P0_12,);
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf52833")]
|
||||||
|
define_peris!(PIN_A = P1_01, PIN_B = P1_02,);
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf52840")]
|
||||||
|
define_peris!(PIN_A = P1_02, PIN_B = P1_03,);
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf5340")]
|
||||||
|
define_peris!(PIN_A = P1_00, PIN_B = P1_01,);
|
||||||
|
|
||||||
|
#[cfg(feature = "nrf9160")]
|
||||||
|
define_peris!(PIN_A = P0_00, PIN_B = P0_01,);
|
@ -1,9 +0,0 @@
|
|||||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
|
||||||
#runner = "teleprobe local run --chip nRF51422_xxAA --elf"
|
|
||||||
runner = "teleprobe client run"
|
|
||||||
|
|
||||||
[build]
|
|
||||||
target = "thumbv6m-none-eabi"
|
|
||||||
|
|
||||||
[env]
|
|
||||||
DEFMT_LOG = "trace,embassy_hal_internal=debug"
|
|
@ -1,23 +0,0 @@
|
|||||||
[package]
|
|
||||||
edition = "2021"
|
|
||||||
name = "embassy-nrf51-tests"
|
|
||||||
version = "0.1.0"
|
|
||||||
license = "MIT OR Apache-2.0"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
teleprobe-meta = "1"
|
|
||||||
|
|
||||||
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
|
||||||
embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
|
|
||||||
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-128", "integrated-timers"] }
|
|
||||||
embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
|
||||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf51", "time-driver-rtc1", "unstable-pac", "time", "gpiote"] }
|
|
||||||
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
|
||||||
embedded-hal-async = { version = "1.0" }
|
|
||||||
|
|
||||||
defmt = "0.3"
|
|
||||||
defmt-rtt = "0.4"
|
|
||||||
|
|
||||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
|
||||||
cortex-m-rt = "0.7.0"
|
|
||||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
|
@ -1,17 +0,0 @@
|
|||||||
use std::error::Error;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::{env, fs};
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
|
||||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
||||||
fs::write(out.join("memory.x"), include_bytes!("memory.x")).unwrap();
|
|
||||||
println!("cargo:rustc-link-search={}", out.display());
|
|
||||||
println!("cargo:rerun-if-changed=memory.x");
|
|
||||||
|
|
||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
MEMORY
|
|
||||||
{
|
|
||||||
FLASH : ORIGIN = 0x00000000, LENGTH = 128K
|
|
||||||
RAM : ORIGIN = 0x20000000, LENGTH = 16K
|
|
||||||
}
|
|
@ -1,29 +0,0 @@
|
|||||||
[package]
|
|
||||||
edition = "2021"
|
|
||||||
name = "embassy-nrf-examples"
|
|
||||||
version = "0.1.0"
|
|
||||||
license = "MIT OR Apache-2.0"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
teleprobe-meta = "1"
|
|
||||||
|
|
||||||
embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
|
||||||
embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt", ] }
|
|
||||||
embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "task-arena-size-16384", "integrated-timers"] }
|
|
||||||
embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime"] }
|
|
||||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
|
|
||||||
embedded-io-async = { version = "0.6.1", features = ["defmt-03"] }
|
|
||||||
embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", ] }
|
|
||||||
embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
|
|
||||||
embassy-net-enc28j60 = { version = "0.1.0", path = "../../embassy-net-enc28j60", features = ["defmt"] }
|
|
||||||
embedded-hal-async = { version = "1.0" }
|
|
||||||
embedded-hal-bus = { version = "0.1", features = ["async"] }
|
|
||||||
static_cell = "2"
|
|
||||||
perf-client = { path = "../perf-client" }
|
|
||||||
|
|
||||||
defmt = "0.3"
|
|
||||||
defmt-rtt = "0.4"
|
|
||||||
|
|
||||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
|
||||||
cortex-m-rt = "0.7.0"
|
|
||||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
|
@ -1,17 +0,0 @@
|
|||||||
use std::error::Error;
|
|
||||||
use std::path::PathBuf;
|
|
||||||
use std::{env, fs};
|
|
||||||
|
|
||||||
fn main() -> Result<(), Box<dyn Error>> {
|
|
||||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
|
||||||
fs::write(out.join("link_ram.x"), include_bytes!("../link_ram_cortex_m.x")).unwrap();
|
|
||||||
println!("cargo:rustc-link-search={}", out.display());
|
|
||||||
println!("cargo:rerun-if-changed=link_ram.x");
|
|
||||||
|
|
||||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tlink_ram.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
|
||||||
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,24 +0,0 @@
|
|||||||
#![no_std]
|
|
||||||
#![no_main]
|
|
||||||
teleprobe_meta::target!(b"nrf52840-dk");
|
|
||||||
|
|
||||||
use defmt::{assert, info};
|
|
||||||
use embassy_executor::Spawner;
|
|
||||||
use embassy_time::{Instant, Timer};
|
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
|
||||||
|
|
||||||
#[embassy_executor::main]
|
|
||||||
async fn main(_spawner: Spawner) {
|
|
||||||
let _p = embassy_nrf::init(Default::default());
|
|
||||||
info!("Hello World!");
|
|
||||||
|
|
||||||
let start = Instant::now();
|
|
||||||
Timer::after_millis(100).await;
|
|
||||||
let end = Instant::now();
|
|
||||||
let ms = (end - start).as_millis();
|
|
||||||
info!("slept for {} ms", ms);
|
|
||||||
assert!(ms >= 99);
|
|
||||||
|
|
||||||
info!("Test OK");
|
|
||||||
cortex_m::asm::bkpt();
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user