aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTyler <[email protected]>2023-07-16 19:08:01 -0500
committerGitHub <[email protected]>2023-07-16 19:08:01 -0500
commit6d8a5c6c20953c998df6ddd26906abe520df946d (patch)
tree32cfdf85a1aa132cb0f1aac56a934ceed93fc597 /tests
parent3aedbce5c2775ff1ab10c3ca95ea1311043f4be4 (diff)
parentc7ec45a004750f590c1d9ea4a721972efe133b8e (diff)
Merge pull request #2 from embassy-rs/main
Pull changes from base embassy repo
Diffstat (limited to 'tests')
-rw-r--r--tests/nrf/Cargo.toml4
-rw-r--r--tests/nrf/src/bin/wifi_esp_hosted_perf.rs6
-rw-r--r--tests/riscv32/Cargo.toml2
-rw-r--r--tests/rp/Cargo.toml8
-rw-r--r--tests/rp/src/bin/adc.rs86
-rw-r--r--tests/rp/src/bin/cyw43-perf.rs10
-rw-r--r--tests/rp/src/bin/gpio.rs36
-rw-r--r--tests/rp/src/bin/pio_irq.rs55
-rw-r--r--tests/stm32/Cargo.toml30
-rw-r--r--tests/stm32/src/bin/can.rs7
-rw-r--r--tests/stm32/src/bin/gpio.rs36
-rw-r--r--tests/stm32/src/bin/rtc.rs2
-rw-r--r--tests/stm32/src/bin/wpan_ble.rs (renamed from tests/stm32/src/bin/tl_mbox.rs)2
-rw-r--r--tests/stm32/src/bin/wpan_mac.rs108
14 files changed, 360 insertions, 32 deletions
diff --git a/tests/nrf/Cargo.toml b/tests/nrf/Cargo.toml
index 4f9ecc47a..7ce51aa5e 100644
--- a/tests/nrf/Cargo.toml
+++ b/tests/nrf/Cargo.toml
@@ -10,12 +10,12 @@ teleprobe-meta = "1"
10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 10embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
11embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt", "nightly"] } 11embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt", "nightly"] }
12embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] } 12embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] }
13embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "nightly", "defmt-timestamp-uptime"] } 13embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] }
14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] } 14embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
15embedded-io = { version = "0.4.0", features = ["async"] } 15embedded-io = { version = "0.4.0", features = ["async"] }
16embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] } 16embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
17embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] } 17embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
18embedded-hal-async = { version = "0.2.0-alpha.1" } 18embedded-hal-async = { version = "0.2.0-alpha.2" }
19static_cell = { version = "1.1", features = [ "nightly" ] } 19static_cell = { version = "1.1", features = [ "nightly" ] }
20 20
21defmt = "0.3" 21defmt = "0.3"
diff --git a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
index 277b985c5..398ab9d27 100644
--- a/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
+++ b/tests/nrf/src/bin/wifi_esp_hosted_perf.rs
@@ -14,7 +14,7 @@ use embassy_nrf::gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull};
14use embassy_nrf::rng::Rng; 14use embassy_nrf::rng::Rng;
15use embassy_nrf::spim::{self, Spim}; 15use embassy_nrf::spim::{self, Spim};
16use embassy_nrf::{bind_interrupts, peripherals}; 16use embassy_nrf::{bind_interrupts, peripherals};
17use embassy_time::{with_timeout, Duration, Timer}; 17use embassy_time::{with_timeout, Delay, Duration, Timer};
18use embedded_hal_async::spi::ExclusiveDevice; 18use embedded_hal_async::spi::ExclusiveDevice;
19use static_cell::make_static; 19use static_cell::make_static;
20use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _}; 20use {defmt_rtt as _, embassy_net_esp_hosted as hosted, panic_probe as _};
@@ -30,7 +30,7 @@ bind_interrupts!(struct Irqs {
30async fn wifi_task( 30async fn wifi_task(
31 runner: hosted::Runner< 31 runner: hosted::Runner<
32 'static, 32 'static,
33 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>>, 33 ExclusiveDevice<Spim<'static, peripherals::SPI3>, Output<'static, peripherals::P0_31>, Delay>,
34 Input<'static, AnyPin>, 34 Input<'static, AnyPin>,
35 Output<'static, peripherals::P1_05>, 35 Output<'static, peripherals::P1_05>,
36 >, 36 >,
@@ -63,7 +63,7 @@ async fn main(spawner: Spawner) {
63 config.frequency = spim::Frequency::M32; 63 config.frequency = spim::Frequency::M32;
64 config.mode = spim::MODE_2; // !!! 64 config.mode = spim::MODE_2; // !!!
65 let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config); 65 let spi = spim::Spim::new(p.SPI3, Irqs, sck, miso, mosi, config);
66 let spi = ExclusiveDevice::new(spi, cs); 66 let spi = ExclusiveDevice::new(spi, cs, Delay);
67 67
68 let (device, mut control, runner) = embassy_net_esp_hosted::new( 68 let (device, mut control, runner) = embassy_net_esp_hosted::new(
69 make_static!(embassy_net_esp_hosted::State::new()), 69 make_static!(embassy_net_esp_hosted::State::new()),
diff --git a/tests/riscv32/Cargo.toml b/tests/riscv32/Cargo.toml
index 81bfdfab6..61f886c0c 100644
--- a/tests/riscv32/Cargo.toml
+++ b/tests/riscv32/Cargo.toml
@@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
8critical-section = { version = "1.1.1", features = ["restore-state-bool"] } 8critical-section = { version = "1.1.1", features = ["restore-state-bool"] }
9embassy-sync = { version = "0.2.0", path = "../../embassy-sync" } 9embassy-sync = { version = "0.2.0", path = "../../embassy-sync" }
10embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-riscv32", "nightly", "executor-thread"] } 10embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-riscv32", "nightly", "executor-thread"] }
11embassy-time = { version = "0.1.0", path = "../../embassy-time" } 11embassy-time = { version = "0.1.2", path = "../../embassy-time" }
12embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 12embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
13 13
14riscv-rt = "0.11" 14riscv-rt = "0.11"
diff --git a/tests/rp/Cargo.toml b/tests/rp/Cargo.toml
index 180d0ebbe..f2c902787 100644
--- a/tests/rp/Cargo.toml
+++ b/tests/rp/Cargo.toml
@@ -9,7 +9,7 @@ teleprobe-meta = "1.1"
9 9
10embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } 10embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 11embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt"] } 12embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt"] }
13embassy-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"] } 13embassy-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"] }
14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 14embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
15embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] } 15embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "nightly", "tcp", "udp", "dhcpv4", "medium-ethernet"] }
@@ -22,13 +22,15 @@ defmt-rtt = "0.4"
22cortex-m = { version = "0.7.6" } 22cortex-m = { version = "0.7.6" }
23cortex-m-rt = "0.7.0" 23cortex-m-rt = "0.7.0"
24embedded-hal = "0.2.6" 24embedded-hal = "0.2.6"
25embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } 25embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" }
26embedded-hal-async = { version = "=0.2.0-alpha.1" } 26embedded-hal-async = { version = "=0.2.0-alpha.2" }
27panic-probe = { version = "0.3.0", features = ["print-defmt"] } 27panic-probe = { version = "0.3.0", features = ["print-defmt"] }
28futures = { version = "0.3.17", default-features = false, features = ["async-await"] } 28futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
29embedded-io = { version = "0.4.0", features = ["async"] } 29embedded-io = { version = "0.4.0", features = ["async"] }
30embedded-storage = { version = "0.3" } 30embedded-storage = { version = "0.3" }
31static_cell = { version = "1.1", features = ["nightly"]} 31static_cell = { version = "1.1", features = ["nightly"]}
32pio = "0.2"
33pio-proc = "0.2"
32 34
33[profile.dev] 35[profile.dev]
34debug = 2 36debug = 2
diff --git a/tests/rp/src/bin/adc.rs b/tests/rp/src/bin/adc.rs
new file mode 100644
index 000000000..e659844ae
--- /dev/null
+++ b/tests/rp/src/bin/adc.rs
@@ -0,0 +1,86 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4#[path = "../common.rs"]
5mod common;
6
7use defmt::*;
8use embassy_executor::Spawner;
9use embassy_rp::adc::{Adc, Config, InterruptHandler, Pin};
10use embassy_rp::bind_interrupts;
11use embassy_rp::gpio::Pull;
12use {defmt_rtt as _, panic_probe as _};
13
14bind_interrupts!(struct Irqs {
15 ADC_IRQ_FIFO => InterruptHandler;
16});
17
18#[embassy_executor::main]
19async fn main(_spawner: Spawner) {
20 let mut p = embassy_rp::init(Default::default());
21 let mut adc = Adc::new(p.ADC, Irqs, Config::default());
22
23 {
24 {
25 let mut p = Pin::new(&mut p.PIN_26, Pull::Down);
26 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
27 defmt::assert!(adc.read(&mut p).await.unwrap() < 0b01_0000_0000);
28 }
29 {
30 let mut p = Pin::new(&mut p.PIN_26, Pull::Up);
31 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
32 defmt::assert!(adc.read(&mut p).await.unwrap() > 0b11_0000_0000);
33 }
34 }
35 // not bothering with async reads from now on
36 {
37 {
38 let mut p = Pin::new(&mut p.PIN_27, Pull::Down);
39 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
40 }
41 {
42 let mut p = Pin::new(&mut p.PIN_27, Pull::Up);
43 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
44 }
45 }
46 {
47 {
48 let mut p = Pin::new(&mut p.PIN_28, Pull::Down);
49 defmt::assert!(adc.blocking_read(&mut p).unwrap() < 0b01_0000_0000);
50 }
51 {
52 let mut p = Pin::new(&mut p.PIN_28, Pull::Up);
53 defmt::assert!(adc.blocking_read(&mut p).unwrap() > 0b11_0000_0000);
54 }
55 }
56 {
57 // gp29 is connected to vsys through a 200k/100k divider,
58 // adding pulls should change the value
59 let low = {
60 let mut p = Pin::new(&mut p.PIN_29, Pull::Down);
61 adc.blocking_read(&mut p).unwrap()
62 };
63 let none = {
64 let mut p = Pin::new(&mut p.PIN_29, Pull::None);
65 adc.blocking_read(&mut p).unwrap()
66 };
67 let up = {
68 let mut p = Pin::new(&mut p.PIN_29, Pull::Up);
69 adc.blocking_read(&mut p).unwrap()
70 };
71 defmt::assert!(low < none);
72 defmt::assert!(none < up);
73 }
74
75 let temp = convert_to_celsius(adc.read_temperature().await.unwrap());
76 defmt::assert!(temp > 0.0);
77 defmt::assert!(temp < 60.0);
78
79 info!("Test OK");
80 cortex_m::asm::bkpt();
81}
82
83fn convert_to_celsius(raw_temp: u16) -> f32 {
84 // According to chapter 4.9.5. Temperature Sensor in RP2040 datasheet
85 27.0 - (raw_temp as f32 * 3.3 / 4096.0 - 0.706) / 0.001721 as f32
86}
diff --git a/tests/rp/src/bin/cyw43-perf.rs b/tests/rp/src/bin/cyw43-perf.rs
index 1ecaab266..bc127e2e5 100644
--- a/tests/rp/src/bin/cyw43-perf.rs
+++ b/tests/rp/src/bin/cyw43-perf.rs
@@ -12,12 +12,16 @@ use embassy_net::tcp::TcpSocket;
12use embassy_net::{Config, Ipv4Address, Stack, StackResources}; 12use embassy_net::{Config, Ipv4Address, Stack, StackResources};
13use embassy_rp::gpio::{Level, Output}; 13use embassy_rp::gpio::{Level, Output};
14use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0}; 14use embassy_rp::peripherals::{DMA_CH0, PIN_23, PIN_25, PIO0};
15use embassy_rp::pio::Pio; 15use embassy_rp::pio::{InterruptHandler, Pio};
16use embassy_rp::rom_data; 16use embassy_rp::{bind_interrupts, rom_data};
17use embassy_time::{with_timeout, Duration, Timer}; 17use embassy_time::{with_timeout, Duration, Timer};
18use static_cell::make_static; 18use static_cell::make_static;
19use {defmt_rtt as _, panic_probe as _}; 19use {defmt_rtt as _, panic_probe as _};
20 20
21bind_interrupts!(struct Irqs {
22 PIO0_IRQ_0 => InterruptHandler<PIO0>;
23});
24
21teleprobe_meta::timeout!(120); 25teleprobe_meta::timeout!(120);
22 26
23#[embassy_executor::task] 27#[embassy_executor::task]
@@ -51,7 +55,7 @@ async fn main(spawner: Spawner) {
51 55
52 let pwr = Output::new(p.PIN_23, Level::Low); 56 let pwr = Output::new(p.PIN_23, Level::Low);
53 let cs = Output::new(p.PIN_25, Level::High); 57 let cs = Output::new(p.PIN_25, Level::High);
54 let mut pio = Pio::new(p.PIO0); 58 let mut pio = Pio::new(p.PIO0, Irqs);
55 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0); 59 let spi = PioSpi::new(&mut pio.common, pio.sm0, pio.irq0, cs, p.PIN_24, p.PIN_29, p.DMA_CH0);
56 60
57 let state = make_static!(cyw43::State::new()); 61 let state = make_static!(cyw43::State::new());
diff --git a/tests/rp/src/bin/gpio.rs b/tests/rp/src/bin/gpio.rs
index 51112d319..946b7dc88 100644
--- a/tests/rp/src/bin/gpio.rs
+++ b/tests/rp/src/bin/gpio.rs
@@ -21,14 +21,46 @@ async fn main(_spawner: Spawner) {
21 let b = Input::new(&mut b, Pull::None); 21 let b = Input::new(&mut b, Pull::None);
22 22
23 { 23 {
24 let _a = Output::new(&mut a, Level::Low); 24 let a = Output::new(&mut a, Level::Low);
25 delay(); 25 delay();
26 assert!(b.is_low()); 26 assert!(b.is_low());
27 assert!(!b.is_high());
28 assert!(a.is_set_low());
29 assert!(!a.is_set_high());
27 } 30 }
28 { 31 {
29 let _a = Output::new(&mut a, Level::High); 32 let mut a = Output::new(&mut a, Level::High);
30 delay(); 33 delay();
34 assert!(!b.is_low());
31 assert!(b.is_high()); 35 assert!(b.is_high());
36 assert!(!a.is_set_low());
37 assert!(a.is_set_high());
38
39 // Test is_set_low / is_set_high
40 a.set_low();
41 delay();
42 assert!(b.is_low());
43 assert!(a.is_set_low());
44 assert!(!a.is_set_high());
45
46 a.set_high();
47 delay();
48 assert!(b.is_high());
49 assert!(!a.is_set_low());
50 assert!(a.is_set_high());
51
52 // Test toggle
53 a.toggle();
54 delay();
55 assert!(b.is_low());
56 assert!(a.is_set_low());
57 assert!(!a.is_set_high());
58
59 a.toggle();
60 delay();
61 assert!(b.is_high());
62 assert!(!a.is_set_low());
63 assert!(a.is_set_high());
32 } 64 }
33 } 65 }
34 66
diff --git a/tests/rp/src/bin/pio_irq.rs b/tests/rp/src/bin/pio_irq.rs
new file mode 100644
index 000000000..45004424a
--- /dev/null
+++ b/tests/rp/src/bin/pio_irq.rs
@@ -0,0 +1,55 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4#[path = "../common.rs"]
5mod common;
6
7use defmt::info;
8use embassy_executor::Spawner;
9use embassy_rp::bind_interrupts;
10use embassy_rp::peripherals::PIO0;
11use embassy_rp::pio::{Config, InterruptHandler, Pio};
12use embassy_rp::relocate::RelocatedProgram;
13use {defmt_rtt as _, panic_probe as _};
14
15bind_interrupts!(struct Irqs {
16 PIO0_IRQ_0 => InterruptHandler<PIO0>;
17});
18
19#[embassy_executor::main]
20async fn main(_spawner: Spawner) {
21 let p = embassy_rp::init(Default::default());
22 let pio = p.PIO0;
23 let Pio {
24 mut common,
25 sm0: mut sm,
26 irq_flags,
27 ..
28 } = Pio::new(pio, Irqs);
29
30 let prg = pio_proc::pio_asm!(
31 "irq set 0",
32 "irq wait 0",
33 "irq set 1",
34 // pause execution here
35 "irq wait 1",
36 );
37
38 let relocated = RelocatedProgram::new(&prg.program);
39 let mut cfg = Config::default();
40 cfg.use_program(&common.load_program(&relocated), &[]);
41 sm.set_config(&cfg);
42 sm.set_enable(true);
43
44 // not using the wait futures on purpose because they clear the irq bits,
45 // and we want to see in which order they are set.
46 while !irq_flags.check(0) {}
47 cortex_m::asm::nop();
48 assert!(!irq_flags.check(1));
49 irq_flags.clear(0);
50 cortex_m::asm::nop();
51 assert!(irq_flags.check(1));
52
53 info!("Test OK");
54 cortex_m::asm::bkpt();
55}
diff --git a/tests/stm32/Cargo.toml b/tests/stm32/Cargo.toml
index c2422f7bc..3007cd1e6 100644
--- a/tests/stm32/Cargo.toml
+++ b/tests/stm32/Cargo.toml
@@ -12,14 +12,16 @@ stm32g071rb = ["embassy-stm32/stm32g071rb", "not-gpdma"] # Nucleo
12stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo 12stm32c031c6 = ["embassy-stm32/stm32c031c6", "not-gpdma"] # Nucleo
13stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo 13stm32g491re = ["embassy-stm32/stm32g491re", "not-gpdma"] # Nucleo
14stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "not-gpdma"] # Nucleo 14stm32h755zi = ["embassy-stm32/stm32h755zi-cm7", "not-gpdma"] # Nucleo
15stm32wb55rg = ["embassy-stm32/stm32wb55rg", "not-gpdma", "ble" ] # Nucleo 15stm32wb55rg = ["embassy-stm32/stm32wb55rg", "not-gpdma", "ble", "mac" ] # Nucleo
16stm32h563zi = ["embassy-stm32/stm32h563zi"] # Nucleo 16stm32h563zi = ["embassy-stm32/stm32h563zi"] # Nucleo
17stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board 17stm32u585ai = ["embassy-stm32/stm32u585ai"] # IoT board
18 18
19sdmmc = [] 19sdmmc = []
20chrono = ["embassy-stm32/chrono", "dep:chrono"] 20chrono = ["embassy-stm32/chrono", "dep:chrono"]
21can = [] 21can = []
22ble = ["dep:embassy-stm32-wpan"] 22ble = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/ble"]
23mac = ["dep:embassy-stm32-wpan", "embassy-stm32-wpan/mac"]
24embassy-stm32-wpan = []
23not-gpdma = [] 25not-gpdma = []
24 26
25[dependencies] 27[dependencies]
@@ -27,7 +29,7 @@ teleprobe-meta = "1"
27 29
28embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } 30embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] }
29embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } 31embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
30embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768", "defmt-timestamp-uptime"] } 32embassy-time = { version = "0.1.2", path = "../../embassy-time", features = ["defmt", "tick-hz-32_768", "defmt-timestamp-uptime"] }
31embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] } 33embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "unstable-pac", "memory-x", "time-driver-any"] }
32embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } 34embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
33embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] } 35embassy-stm32-wpan = { version = "0.1.0", path = "../../embassy-stm32-wpan", optional = true, features = ["defmt", "stm32wb55rg", "ble"] }
@@ -38,25 +40,17 @@ defmt-rtt = "0.4"
38cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] } 40cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
39cortex-m-rt = "0.7.0" 41cortex-m-rt = "0.7.0"
40embedded-hal = "0.2.6" 42embedded-hal = "0.2.6"
41embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.10" } 43embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.11" }
42embedded-hal-async = { version = "=0.2.0-alpha.1" } 44embedded-hal-async = { version = "=0.2.0-alpha.2" }
43panic-probe = { version = "0.3.0", features = ["print-defmt"] } 45panic-probe = { version = "0.3.0", features = ["print-defmt"] }
44rand_core = { version = "0.6", default-features = false } 46rand_core = { version = "0.6", default-features = false }
45rand_chacha = { version = "0.3", default-features = false } 47rand_chacha = { version = "0.3", default-features = false }
46 48
47chrono = { version = "^0.4", default-features = false, optional = true} 49chrono = { version = "^0.4", default-features = false, optional = true}
48 50
49[patch.crates-io]
50stm32wb-hci = { git = "https://github.com/OueslatiGhaith/stm32wb-hci", rev = "9f663be"}
51
52# BEGIN TESTS 51# BEGIN TESTS
53# Generated by gen_test.py. DO NOT EDIT. 52# Generated by gen_test.py. DO NOT EDIT.
54[[bin]] 53[[bin]]
55name = "tl_mbox"
56path = "src/bin/tl_mbox.rs"
57required-features = [ "ble",]
58
59[[bin]]
60name = "can" 54name = "can"
61path = "src/bin/can.rs" 55path = "src/bin/can.rs"
62required-features = [ "can",] 56required-features = [ "can",]
@@ -106,6 +100,16 @@ name = "usart_rx_ringbuffered"
106path = "src/bin/usart_rx_ringbuffered.rs" 100path = "src/bin/usart_rx_ringbuffered.rs"
107required-features = [ "not-gpdma",] 101required-features = [ "not-gpdma",]
108 102
103[[bin]]
104name = "wpan_ble"
105path = "src/bin/wpan_ble.rs"
106required-features = [ "ble",]
107
108[[bin]]
109name = "wpan_mac"
110path = "src/bin/wpan_mac.rs"
111required-features = [ "mac",]
112
109# END TESTS 113# END TESTS
110 114
111[profile.dev] 115[profile.dev]
diff --git a/tests/stm32/src/bin/can.rs b/tests/stm32/src/bin/can.rs
index 33d63d546..8bdd3c24f 100644
--- a/tests/stm32/src/bin/can.rs
+++ b/tests/stm32/src/bin/can.rs
@@ -43,10 +43,13 @@ async fn main(_spawner: Spawner) {
43 43
44 info!("Configuring can..."); 44 info!("Configuring can...");
45 45
46 can.modify_filters().enable_bank(0, Fifo::Fifo0, Mask32::accept_all()); 46 can.as_mut()
47 .modify_filters()
48 .enable_bank(0, Fifo::Fifo0, Mask32::accept_all());
47 49
48 can.set_bitrate(1_000_000); 50 can.set_bitrate(1_000_000);
49 can.modify_config() 51 can.as_mut()
52 .modify_config()
50 .set_loopback(true) // Receive own frames 53 .set_loopback(true) // Receive own frames
51 .set_silent(true) 54 .set_silent(true)
52 // .set_bit_timing(0x001c0003) 55 // .set_bit_timing(0x001c0003)
diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs
index 67f44317e..aad174431 100644
--- a/tests/stm32/src/bin/gpio.rs
+++ b/tests/stm32/src/bin/gpio.rs
@@ -40,14 +40,46 @@ async fn main(_spawner: Spawner) {
40 let b = Input::new(&mut b, Pull::None); 40 let b = Input::new(&mut b, Pull::None);
41 41
42 { 42 {
43 let _a = Output::new(&mut a, Level::Low, Speed::Low); 43 let a = Output::new(&mut a, Level::Low, Speed::Low);
44 delay(); 44 delay();
45 assert!(b.is_low()); 45 assert!(b.is_low());
46 assert!(!b.is_high());
47 assert!(a.is_set_low());
48 assert!(!a.is_set_high());
46 } 49 }
47 { 50 {
48 let _a = Output::new(&mut a, Level::High, Speed::Low); 51 let mut a = Output::new(&mut a, Level::High, Speed::Low);
49 delay(); 52 delay();
53 assert!(!b.is_low());
50 assert!(b.is_high()); 54 assert!(b.is_high());
55 assert!(!a.is_set_low());
56 assert!(a.is_set_high());
57
58 // Test is_set_low / is_set_high
59 a.set_low();
60 delay();
61 assert!(b.is_low());
62 assert!(a.is_set_low());
63 assert!(!a.is_set_high());
64
65 a.set_high();
66 delay();
67 assert!(b.is_high());
68 assert!(!a.is_set_low());
69 assert!(a.is_set_high());
70
71 // Test toggle
72 a.toggle();
73 delay();
74 assert!(b.is_low());
75 assert!(a.is_set_low());
76 assert!(!a.is_set_high());
77
78 a.toggle();
79 delay();
80 assert!(b.is_high());
81 assert!(!a.is_set_low());
82 assert!(a.is_set_high());
51 } 83 }
52 } 84 }
53 85
diff --git a/tests/stm32/src/bin/rtc.rs b/tests/stm32/src/bin/rtc.rs
index 582df5753..194b153d5 100644
--- a/tests/stm32/src/bin/rtc.rs
+++ b/tests/stm32/src/bin/rtc.rs
@@ -1,3 +1,5 @@
1// required-features: chrono
2
1#![no_std] 3#![no_std]
2#![no_main] 4#![no_main]
3#![feature(type_alias_impl_trait)] 5#![feature(type_alias_impl_trait)]
diff --git a/tests/stm32/src/bin/tl_mbox.rs b/tests/stm32/src/bin/wpan_ble.rs
index af3832709..3ad8aca4e 100644
--- a/tests/stm32/src/bin/tl_mbox.rs
+++ b/tests/stm32/src/bin/wpan_ble.rs
@@ -64,7 +64,7 @@ async fn main(spawner: Spawner) {
64 version_major, version_minor, subversion, sram2a_size, sram2b_size 64 version_major, version_minor, subversion, sram2a_size, sram2b_size
65 ); 65 );
66 66
67 mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await; 67 let _ = mbox.sys_subsystem.shci_c2_ble_init(Default::default()).await;
68 68
69 info!("resetting BLE..."); 69 info!("resetting BLE...");
70 mbox.ble_subsystem.reset().await; 70 mbox.ble_subsystem.reset().await;
diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs
new file mode 100644
index 000000000..cfa0aca3b
--- /dev/null
+++ b/tests/stm32/src/bin/wpan_mac.rs
@@ -0,0 +1,108 @@
1// required-features: mac
2
3#![no_std]
4#![no_main]
5#![feature(type_alias_impl_trait)]
6#[path = "../common.rs"]
7mod common;
8
9use common::*;
10use embassy_executor::Spawner;
11use embassy_stm32::bind_interrupts;
12use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
13use embassy_stm32_wpan::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest};
14use embassy_stm32_wpan::mac::event::MacEvent;
15use embassy_stm32_wpan::mac::typedefs::{
16 AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel,
17};
18use embassy_stm32_wpan::sub::mm;
19use embassy_stm32_wpan::TlMbox;
20use {defmt_rtt as _, panic_probe as _};
21
22bind_interrupts!(struct Irqs{
23 IPCC_C1_RX => ReceiveInterruptHandler;
24 IPCC_C1_TX => TransmitInterruptHandler;
25});
26
27#[embassy_executor::task]
28async fn run_mm_queue(memory_manager: mm::MemoryManager) {
29 memory_manager.run_queue().await;
30}
31
32#[embassy_executor::main]
33async fn main(spawner: Spawner) {
34 let p = embassy_stm32::init(config());
35 info!("Hello World!");
36
37 let config = Config::default();
38 let mbox = TlMbox::init(p.IPCC, Irqs, config);
39
40 spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
41
42 let sys_event = mbox.sys_subsystem.read().await;
43 info!("sys event: {}", sys_event.payload());
44
45 core::mem::drop(sys_event);
46
47 let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
48 info!("initialized mac: {}", result);
49
50 info!("resetting");
51 mbox.mac_subsystem
52 .send_command(&ResetRequest { set_default_pib: true })
53 .await
54 .unwrap();
55 let evt = mbox.mac_subsystem.read().await;
56 info!("{:#x}", evt);
57
58 info!("setting extended address");
59 let extended_address: u64 = 0xACDE480000000002;
60 mbox.mac_subsystem
61 .send_command(&SetRequest {
62 pib_attribute_ptr: &extended_address as *const _ as *const u8,
63 pib_attribute: PibId::ExtendedAddress,
64 })
65 .await
66 .unwrap();
67 let evt = mbox.mac_subsystem.read().await;
68 info!("{:#x}", evt);
69
70 info!("getting extended address");
71 mbox.mac_subsystem
72 .send_command(&GetRequest {
73 pib_attribute: PibId::ExtendedAddress,
74 })
75 .await
76 .unwrap();
77 let evt = mbox.mac_subsystem.read().await;
78 info!("{:#x}", evt);
79
80 if let Ok(MacEvent::MlmeGetCnf(evt)) = evt {
81 if evt.pib_attribute_value_len == 8 {
82 let value = unsafe { core::ptr::read_unaligned(evt.pib_attribute_value_ptr as *const u64) };
83
84 info!("value {:#x}", value)
85 }
86 }
87
88 info!("assocation request");
89 let a = AssociateRequest {
90 channel_number: MacChannel::Channel16,
91 channel_page: 0,
92 coord_addr_mode: AddressMode::Short,
93 coord_address: MacAddress { short: [34, 17] },
94 capability_information: Capabilities::ALLOCATE_ADDRESS,
95 coord_pan_id: PanId([0x1A, 0xAA]),
96 security_level: SecurityLevel::Unsecure,
97 key_id_mode: KeyIdMode::Implicite,
98 key_source: [0; 8],
99 key_index: 152,
100 };
101 info!("{}", a);
102 mbox.mac_subsystem.send_command(&a).await.unwrap();
103 let evt = mbox.mac_subsystem.read().await;
104 info!("{:#x}", evt);
105
106 info!("Test OK");
107 cortex_m::asm::bkpt();
108}