From 0c07d0375406c6079e4b143cd7ac380d0a2bfd5f Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 8 Apr 2022 03:15:27 +0200 Subject: Add missing stm32wl/stm32wb chips except stm32wle --- ci.sh | 6 +- embassy-stm32/Cargo.toml | 11 +++ examples/stm32wb/.cargo/config.toml | 6 ++ examples/stm32wb/Cargo.toml | 20 +++++ examples/stm32wb/build.rs | 35 ++++++++ examples/stm32wb/memory.x | 41 ++++++++++ examples/stm32wb/src/bin/blinky.rs | 28 +++++++ examples/stm32wb/src/bin/button_exti.rs | 28 +++++++ examples/stm32wb55/.cargo/config.toml | 6 -- examples/stm32wb55/Cargo.toml | 20 ----- examples/stm32wb55/build.rs | 35 -------- examples/stm32wb55/memory.x | 41 ---------- examples/stm32wb55/src/bin/blinky.rs | 28 ------- examples/stm32wb55/src/bin/button_exti.rs | 28 ------- examples/stm32wl/.cargo/config.toml | 6 ++ examples/stm32wl/Cargo.toml | 24 ++++++ examples/stm32wl/build.rs | 5 ++ examples/stm32wl/src/bin/blinky.rs | 28 +++++++ examples/stm32wl/src/bin/button.rs | 31 +++++++ examples/stm32wl/src/bin/button_exti.rs | 28 +++++++ examples/stm32wl/src/bin/lorawan.rs | 72 +++++++++++++++++ examples/stm32wl/src/bin/subghz.rs | 130 ++++++++++++++++++++++++++++++ examples/stm32wl55/.cargo/config.toml | 6 -- examples/stm32wl55/Cargo.toml | 24 ------ examples/stm32wl55/build.rs | 5 -- examples/stm32wl55/src/bin/blinky.rs | 28 ------- examples/stm32wl55/src/bin/button.rs | 31 ------- examples/stm32wl55/src/bin/button_exti.rs | 28 ------- examples/stm32wl55/src/bin/lorawan.rs | 72 ----------------- examples/stm32wl55/src/bin/subghz.rs | 130 ------------------------------ stm32-gen-features/src/lib.rs | 18 +---- 31 files changed, 499 insertions(+), 500 deletions(-) create mode 100644 examples/stm32wb/.cargo/config.toml create mode 100644 examples/stm32wb/Cargo.toml create mode 100644 examples/stm32wb/build.rs create mode 100644 examples/stm32wb/memory.x create mode 100644 examples/stm32wb/src/bin/blinky.rs create mode 100644 examples/stm32wb/src/bin/button_exti.rs delete mode 100644 examples/stm32wb55/.cargo/config.toml delete mode 100644 examples/stm32wb55/Cargo.toml delete mode 100644 examples/stm32wb55/build.rs delete mode 100644 examples/stm32wb55/memory.x delete mode 100644 examples/stm32wb55/src/bin/blinky.rs delete mode 100644 examples/stm32wb55/src/bin/button_exti.rs create mode 100644 examples/stm32wl/.cargo/config.toml create mode 100644 examples/stm32wl/Cargo.toml create mode 100644 examples/stm32wl/build.rs create mode 100644 examples/stm32wl/src/bin/blinky.rs create mode 100644 examples/stm32wl/src/bin/button.rs create mode 100644 examples/stm32wl/src/bin/button_exti.rs create mode 100644 examples/stm32wl/src/bin/lorawan.rs create mode 100644 examples/stm32wl/src/bin/subghz.rs delete mode 100644 examples/stm32wl55/.cargo/config.toml delete mode 100644 examples/stm32wl55/Cargo.toml delete mode 100644 examples/stm32wl55/build.rs delete mode 100644 examples/stm32wl55/src/bin/blinky.rs delete mode 100644 examples/stm32wl55/src/bin/button.rs delete mode 100644 examples/stm32wl55/src/bin/button_exti.rs delete mode 100644 examples/stm32wl55/src/bin/lorawan.rs delete mode 100644 examples/stm32wl55/src/bin/subghz.rs diff --git a/ci.sh b/ci.sh index af93d0b72..8f375eb92 100755 --- a/ci.sh +++ b/ci.sh @@ -48,6 +48,7 @@ cargo batch \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h755zi-cm7,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32h7b3ai,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32l476vg,defmt,exti,time-driver-any,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features nightly,stm32wb15cc,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l072cz,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32l041f6,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32l151cb-a,defmt,exti,time-driver-any,unstable-traits \ @@ -55,6 +56,7 @@ cargo batch \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32g0c1ve,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7m-none-eabi --features nightly,stm32f217zg,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features nightly,stm32l552ze,defmt,exti,time-driver-any,unstable-traits \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv6m-none-eabi --features nightly,stm32wl54jc-cm0p,defmt,exti,time-driver-any,unstable-traits \ --- build --release --manifest-path docs/modules/ROOT/examples/basic/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-pac/Cargo.toml --target thumbv7em-none-eabi \ --- build --release --manifest-path docs/modules/ROOT/examples/layer-by-layer/blinky-hal/Cargo.toml --target thumbv7em-none-eabi \ @@ -76,8 +78,8 @@ cargo batch \ --- build --release --manifest-path examples/stm32l1/Cargo.toml --target thumbv7m-none-eabi --out-dir out/examples/stm32l1 \ --- build --release --manifest-path examples/stm32l4/Cargo.toml --target thumbv7em-none-eabi --out-dir out/examples/stm32l4 \ --- build --release --manifest-path examples/stm32u5/Cargo.toml --target thumbv8m.main-none-eabihf --out-dir out/examples/stm32u5 \ - --- build --release --manifest-path examples/stm32wb55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb55 \ - --- build --release --manifest-path examples/stm32wl55/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl55 \ + --- build --release --manifest-path examples/stm32wb/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wb \ + --- build --release --manifest-path examples/stm32wl/Cargo.toml --target thumbv7em-none-eabihf --out-dir out/examples/stm32wl \ --- build --release --manifest-path examples/wasm/Cargo.toml --target wasm32-unknown-unknown --out-dir out/examples/wasm \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7m-none-eabi --features stm32f103c8 --out-dir out/tests/bluepill-stm32f103c8 \ --- build --release --manifest-path tests/stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f429zi --out-dir out/tests/nucleo-stm32f429zi \ diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 5579631af..030782466 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -1316,6 +1316,12 @@ stm32u585ri = [ "stm32-metapac/stm32u585ri" ] stm32u585vi = [ "stm32-metapac/stm32u585vi" ] stm32u585ze = [ "stm32-metapac/stm32u585ze" ] stm32u585zi = [ "stm32-metapac/stm32u585zi" ] +stm32wb10cc = [ "stm32-metapac/stm32wb10cc" ] +stm32wb15cc = [ "stm32-metapac/stm32wb15cc" ] +stm32wb30ce = [ "stm32-metapac/stm32wb30ce" ] +stm32wb35cc = [ "stm32-metapac/stm32wb35cc" ] +stm32wb35ce = [ "stm32-metapac/stm32wb35ce" ] +stm32wb50cg = [ "stm32-metapac/stm32wb50cg" ] stm32wb55cc = [ "stm32-metapac/stm32wb55cc" ] stm32wb55ce = [ "stm32-metapac/stm32wb55ce" ] stm32wb55cg = [ "stm32-metapac/stm32wb55cg" ] @@ -1326,6 +1332,11 @@ stm32wb55vc = [ "stm32-metapac/stm32wb55vc" ] stm32wb55ve = [ "stm32-metapac/stm32wb55ve" ] stm32wb55vg = [ "stm32-metapac/stm32wb55vg" ] stm32wb55vy = [ "stm32-metapac/stm32wb55vy" ] +stm32wb5mmg = [ "stm32-metapac/stm32wb5mmg" ] +stm32wl54cc-cm4 = [ "stm32-metapac/stm32wl54cc-cm4" ] +stm32wl54cc-cm0p = [ "stm32-metapac/stm32wl54cc-cm0p" ] +stm32wl54jc-cm4 = [ "stm32-metapac/stm32wl54jc-cm4" ] +stm32wl54jc-cm0p = [ "stm32-metapac/stm32wl54jc-cm0p" ] stm32wl55cc-cm4 = [ "stm32-metapac/stm32wl55cc-cm4" ] stm32wl55cc-cm0p = [ "stm32-metapac/stm32wl55cc-cm0p" ] stm32wl55jc-cm4 = [ "stm32-metapac/stm32wl55jc-cm4" ] diff --git a/examples/stm32wb/.cargo/config.toml b/examples/stm32wb/.cargo/config.toml new file mode 100644 index 000000000..509517a2d --- /dev/null +++ b/examples/stm32wb/.cargo/config.toml @@ -0,0 +1,6 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace STM32WB55CCUx with your chip as listed in `probe-run --list-chips` +runner = "probe-run --chip STM32WB55CCUx --speed 1000 --connect-under-reset" + +[build] +target = "thumbv7em-none-eabihf" diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml new file mode 100644 index 000000000..d797b9c78 --- /dev/null +++ b/examples/stm32wb/Cargo.toml @@ -0,0 +1,20 @@ +[package] +authors = ["Dario Nieuwenhuis "] +edition = "2018" +name = "embassy-stm32wb-examples" +version = "0.1.0" +resolver = "2" + +[dependencies] +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } + +defmt = "0.3" +defmt-rtt = "0.3" + +cortex-m = "0.7.3" +cortex-m-rt = "0.7.0" +embedded-hal = "0.2.6" +panic-probe = { version = "0.3", features = ["print-defmt"] } +futures = { version = "0.3.17", default-features = false, features = ["async-await"] } +heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32wb/build.rs b/examples/stm32wb/build.rs new file mode 100644 index 000000000..30691aa97 --- /dev/null +++ b/examples/stm32wb/build.rs @@ -0,0 +1,35 @@ +//! This build script copies the `memory.x` file from the crate root into +//! a directory where the linker can always find it at build time. +//! For many projects this is optional, as the linker always searches the +//! project root directory -- wherever `Cargo.toml` is. However, if you +//! are using a workspace or have a more complicated build setup, this +//! build script becomes required. Additionally, by requesting that +//! Cargo re-run the build script whenever `memory.x` is changed, +//! updating `memory.x` ensures a rebuild of the application with the +//! new memory settings. + +use std::env; +use std::fs::File; +use std::io::Write; +use std::path::PathBuf; + +fn main() { + // Put `memory.x` in our output directory and ensure it's + // on the linker search path. + let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); + File::create(out.join("memory.x")) + .unwrap() + .write_all(include_bytes!("memory.x")) + .unwrap(); + println!("cargo:rustc-link-search={}", out.display()); + + // By default, Cargo will re-run a build script whenever + // any file in the project changes. By specifying `memory.x` + // here, we ensure the build script is only re-run when + // `memory.x` is changed. + 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"); +} diff --git a/examples/stm32wb/memory.x b/examples/stm32wb/memory.x new file mode 100644 index 000000000..2b4dcce34 --- /dev/null +++ b/examples/stm32wb/memory.x @@ -0,0 +1,41 @@ +/* + The size of this file must be exactly the same as in other memory_xx.x files. + Memory size for STM32WB55xC with 256K FLASH +*/ + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K + RAM (xrw) : ORIGIN = 0x20000004, LENGTH = 191K + RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K +} + +/* Place stack at the end of SRAM1 */ +_stack_start = ORIGIN(RAM) + LENGTH(RAM); + +/* + * Scatter the mailbox interface memory sections in shared memory + */ +SECTIONS { + TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED + + TL_DEVICE_INFO_TABLE 0x2003001c (NOLOAD) : { *(TL_DEVICE_INFO_TABLE) } >RAM_SHARED + TL_BLE_TABLE 0x2003003c (NOLOAD) : { *(TL_BLE_TABLE) } >RAM_SHARED + TL_THREAD_TABLE 0x2003004c (NOLOAD) : { *(TL_THREAD_TABLE) } >RAM_SHARED + TL_SYS_TABLE 0x20030058 (NOLOAD) : { *(TL_SYS_TABLE) } >RAM_SHARED + TL_MEM_MANAGER_TABLE 0x20030060 (NOLOAD) : { *(TL_MEM_MANAGER_TABLE) } >RAM_SHARED + TL_TRACES_TABLE 0x2003007c (NOLOAD) : { *(TL_TRACES_TABLE) } >RAM_SHARED + TL_MAC_802_15_4_TABLE 0x20030080 (NOLOAD) : { *(TL_MAC_802_15_4_TABLE) } >RAM_SHARED + + HCI_ACL_DATA_BUFFER 0x20030a08 (NOLOAD) : { *(HCI_ACL_DATA_BUFFER) } >RAM_SHARED + BLE_CMD_BUFFER 0x200308fc (NOLOAD) : { *(BLE_CMD_BUFFER) } >RAM_SHARED + BLE_SPARE_EVT_BUF 0x200301a8 (NOLOAD) : { *(BLE_SPARE_EVT_BUF) } >RAM_SHARED + SYS_SPARE_EVT_BUF 0x200302b4 (NOLOAD) : { *(SYS_SPARE_EVT_BUF) } >RAM_SHARED + EVT_POOL 0x200303c0 (NOLOAD) : { *(EVT_POOL) } >RAM_SHARED + SYS_CMD_BUF 0x2003009c (NOLOAD) : { *(SYS_CMD_BUF) } >RAM_SHARED + SYSTEM_EVT_QUEUE 0x20030b28 (NOLOAD) : { *(SYSTEM_EVT_QUEUE) } >RAM_SHARED + EVT_QUEUE 0x20030b10 (NOLOAD) : { *(EVT_QUEUE) } >RAM_SHARED + CS_BUFFER 0x20030b18 (NOLOAD) : { *(CS_BUFFER) } >RAM_SHARED + TRACES_EVT_QUEUE 0x20030094 (NOLOAD) : { *(TRACES_EVT_QUEUE) } >RAM_SHARED + FREE_BUF_QUEUE 0x2003008c (NOLOAD) : { *(FREE_BUF_QUEUE) } >RAM_SHARED +} diff --git a/examples/stm32wb/src/bin/blinky.rs b/examples/stm32wb/src/bin/blinky.rs new file mode 100644 index 000000000..59324161a --- /dev/null +++ b/examples/stm32wb/src/bin/blinky.rs @@ -0,0 +1,28 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; // global logger +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; +use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_stm32::Peripherals; +use panic_probe as _; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { + info!("Hello World!"); + + let mut led = Output::new(p.PB0, Level::High, Speed::Low); + + loop { + info!("high"); + led.set_high(); + Timer::after(Duration::from_millis(500)).await; + + info!("low"); + led.set_low(); + Timer::after(Duration::from_millis(500)).await; + } +} diff --git a/examples/stm32wb/src/bin/button_exti.rs b/examples/stm32wb/src/bin/button_exti.rs new file mode 100644 index 000000000..a30a4a216 --- /dev/null +++ b/examples/stm32wb/src/bin/button_exti.rs @@ -0,0 +1,28 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; // global logger +use embassy::executor::Spawner; +use embassy_stm32::exti::ExtiInput; +use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::Peripherals; +use panic_probe as _; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { + info!("Hello World!"); + + let button = Input::new(p.PC4, Pull::Up); + let mut button = ExtiInput::new(button, p.EXTI4); + + info!("Press the USER button..."); + + loop { + button.wait_for_falling_edge().await; + info!("Pressed!"); + button.wait_for_rising_edge().await; + info!("Released!"); + } +} diff --git a/examples/stm32wb55/.cargo/config.toml b/examples/stm32wb55/.cargo/config.toml deleted file mode 100644 index 509517a2d..000000000 --- a/examples/stm32wb55/.cargo/config.toml +++ /dev/null @@ -1,6 +0,0 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -# replace STM32WB55CCUx with your chip as listed in `probe-run --list-chips` -runner = "probe-run --chip STM32WB55CCUx --speed 1000 --connect-under-reset" - -[build] -target = "thumbv7em-none-eabihf" diff --git a/examples/stm32wb55/Cargo.toml b/examples/stm32wb55/Cargo.toml deleted file mode 100644 index 8997d411d..000000000 --- a/examples/stm32wb55/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -authors = ["Dario Nieuwenhuis "] -edition = "2018" -name = "embassy-stm32wb55-examples" -version = "0.1.0" -resolver = "2" - -[dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55cc", "time-driver-any", "exti"] } - -defmt = "0.3" -defmt-rtt = "0.3" - -cortex-m = "0.7.3" -cortex-m-rt = "0.7.0" -embedded-hal = "0.2.6" -panic-probe = { version = "0.3", features = ["print-defmt"] } -futures = { version = "0.3.17", default-features = false, features = ["async-await"] } -heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32wb55/build.rs b/examples/stm32wb55/build.rs deleted file mode 100644 index 30691aa97..000000000 --- a/examples/stm32wb55/build.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! This build script copies the `memory.x` file from the crate root into -//! a directory where the linker can always find it at build time. -//! For many projects this is optional, as the linker always searches the -//! project root directory -- wherever `Cargo.toml` is. However, if you -//! are using a workspace or have a more complicated build setup, this -//! build script becomes required. Additionally, by requesting that -//! Cargo re-run the build script whenever `memory.x` is changed, -//! updating `memory.x` ensures a rebuild of the application with the -//! new memory settings. - -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; - -fn main() { - // Put `memory.x` in our output directory and ensure it's - // on the linker search path. - let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); - File::create(out.join("memory.x")) - .unwrap() - .write_all(include_bytes!("memory.x")) - .unwrap(); - println!("cargo:rustc-link-search={}", out.display()); - - // By default, Cargo will re-run a build script whenever - // any file in the project changes. By specifying `memory.x` - // here, we ensure the build script is only re-run when - // `memory.x` is changed. - 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"); -} diff --git a/examples/stm32wb55/memory.x b/examples/stm32wb55/memory.x deleted file mode 100644 index 2b4dcce34..000000000 --- a/examples/stm32wb55/memory.x +++ /dev/null @@ -1,41 +0,0 @@ -/* - The size of this file must be exactly the same as in other memory_xx.x files. - Memory size for STM32WB55xC with 256K FLASH -*/ - -MEMORY -{ - FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K - RAM (xrw) : ORIGIN = 0x20000004, LENGTH = 191K - RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K -} - -/* Place stack at the end of SRAM1 */ -_stack_start = ORIGIN(RAM) + LENGTH(RAM); - -/* - * Scatter the mailbox interface memory sections in shared memory - */ -SECTIONS { - TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED - - TL_DEVICE_INFO_TABLE 0x2003001c (NOLOAD) : { *(TL_DEVICE_INFO_TABLE) } >RAM_SHARED - TL_BLE_TABLE 0x2003003c (NOLOAD) : { *(TL_BLE_TABLE) } >RAM_SHARED - TL_THREAD_TABLE 0x2003004c (NOLOAD) : { *(TL_THREAD_TABLE) } >RAM_SHARED - TL_SYS_TABLE 0x20030058 (NOLOAD) : { *(TL_SYS_TABLE) } >RAM_SHARED - TL_MEM_MANAGER_TABLE 0x20030060 (NOLOAD) : { *(TL_MEM_MANAGER_TABLE) } >RAM_SHARED - TL_TRACES_TABLE 0x2003007c (NOLOAD) : { *(TL_TRACES_TABLE) } >RAM_SHARED - TL_MAC_802_15_4_TABLE 0x20030080 (NOLOAD) : { *(TL_MAC_802_15_4_TABLE) } >RAM_SHARED - - HCI_ACL_DATA_BUFFER 0x20030a08 (NOLOAD) : { *(HCI_ACL_DATA_BUFFER) } >RAM_SHARED - BLE_CMD_BUFFER 0x200308fc (NOLOAD) : { *(BLE_CMD_BUFFER) } >RAM_SHARED - BLE_SPARE_EVT_BUF 0x200301a8 (NOLOAD) : { *(BLE_SPARE_EVT_BUF) } >RAM_SHARED - SYS_SPARE_EVT_BUF 0x200302b4 (NOLOAD) : { *(SYS_SPARE_EVT_BUF) } >RAM_SHARED - EVT_POOL 0x200303c0 (NOLOAD) : { *(EVT_POOL) } >RAM_SHARED - SYS_CMD_BUF 0x2003009c (NOLOAD) : { *(SYS_CMD_BUF) } >RAM_SHARED - SYSTEM_EVT_QUEUE 0x20030b28 (NOLOAD) : { *(SYSTEM_EVT_QUEUE) } >RAM_SHARED - EVT_QUEUE 0x20030b10 (NOLOAD) : { *(EVT_QUEUE) } >RAM_SHARED - CS_BUFFER 0x20030b18 (NOLOAD) : { *(CS_BUFFER) } >RAM_SHARED - TRACES_EVT_QUEUE 0x20030094 (NOLOAD) : { *(TRACES_EVT_QUEUE) } >RAM_SHARED - FREE_BUF_QUEUE 0x2003008c (NOLOAD) : { *(FREE_BUF_QUEUE) } >RAM_SHARED -} diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs deleted file mode 100644 index 59324161a..000000000 --- a/examples/stm32wb55/src/bin/blinky.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use defmt_rtt as _; // global logger -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; -use panic_probe as _; - -#[embassy::main] -async fn main(_spawner: Spawner, p: Peripherals) { - info!("Hello World!"); - - let mut led = Output::new(p.PB0, Level::High, Speed::Low); - - loop { - info!("high"); - led.set_high(); - Timer::after(Duration::from_millis(500)).await; - - info!("low"); - led.set_low(); - Timer::after(Duration::from_millis(500)).await; - } -} diff --git a/examples/stm32wb55/src/bin/button_exti.rs b/examples/stm32wb55/src/bin/button_exti.rs deleted file mode 100644 index a30a4a216..000000000 --- a/examples/stm32wb55/src/bin/button_exti.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use defmt_rtt as _; // global logger -use embassy::executor::Spawner; -use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; -use panic_probe as _; - -#[embassy::main] -async fn main(_spawner: Spawner, p: Peripherals) { - info!("Hello World!"); - - let button = Input::new(p.PC4, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI4); - - info!("Press the USER button..."); - - loop { - button.wait_for_falling_edge().await; - info!("Pressed!"); - button.wait_for_rising_edge().await; - info!("Released!"); - } -} diff --git a/examples/stm32wl/.cargo/config.toml b/examples/stm32wl/.cargo/config.toml new file mode 100644 index 000000000..60076e06b --- /dev/null +++ b/examples/stm32wl/.cargo/config.toml @@ -0,0 +1,6 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace your chip as listed in `probe-run --list-chips` +runner = "probe-run --chip STM32WLE5JCIx" + +[build] +target = "thumbv7em-none-eabihf" diff --git a/examples/stm32wl/Cargo.toml b/examples/stm32wl/Cargo.toml new file mode 100644 index 000000000..e95a009ce --- /dev/null +++ b/examples/stm32wl/Cargo.toml @@ -0,0 +1,24 @@ +[package] +authors = ["Dario Nieuwenhuis ", "Ulf Lilleengen "] +edition = "2018" +name = "embassy-stm32wl-examples" +version = "0.1.0" +resolver = "2" + +[dependencies] +embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } +embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } +embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time"] } + +lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["async"] } +lorawan-encoding = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["default-crypto"] } + +defmt = "0.3" +defmt-rtt = "0.3" + +cortex-m = "0.7.3" +cortex-m-rt = "0.7.0" +embedded-hal = "0.2.6" +panic-probe = { version = "0.3", features = ["print-defmt"] } +futures = { version = "0.3.17", default-features = false, features = ["async-await"] } +heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32wl/build.rs b/examples/stm32wl/build.rs new file mode 100644 index 000000000..8cd32d7ed --- /dev/null +++ b/examples/stm32wl/build.rs @@ -0,0 +1,5 @@ +fn main() { + println!("cargo:rustc-link-arg-bins=--nmagic"); + println!("cargo:rustc-link-arg-bins=-Tlink.x"); + println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); +} diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs new file mode 100644 index 000000000..78079bfd3 --- /dev/null +++ b/examples/stm32wl/src/bin/blinky.rs @@ -0,0 +1,28 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; // global logger +use embassy::executor::Spawner; +use embassy::time::{Duration, Timer}; +use embassy_stm32::gpio::{Level, Output, Speed}; +use embassy_stm32::Peripherals; +use panic_probe as _; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { + info!("Hello World!"); + + let mut led = Output::new(p.PB15, Level::High, Speed::Low); + + loop { + info!("high"); + led.set_high(); + Timer::after(Duration::from_millis(500)).await; + + info!("low"); + led.set_low(); + Timer::after(Duration::from_millis(500)).await; + } +} diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs new file mode 100644 index 000000000..f80b9ab4f --- /dev/null +++ b/examples/stm32wl/src/bin/button.rs @@ -0,0 +1,31 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; // global logger +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use panic_probe as _; + +use cortex_m_rt::entry; + +#[entry] +fn main() -> ! { + info!("Hello World!"); + + let p = embassy_stm32::init(Default::default()); + + let button = Input::new(p.PA0, Pull::Up); + let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); + let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); + + loop { + if button.is_high() { + led1.set_high(); + led2.set_low(); + } else { + led1.set_low(); + led2.set_high(); + } + } +} diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs new file mode 100644 index 000000000..9a427c2d3 --- /dev/null +++ b/examples/stm32wl/src/bin/button_exti.rs @@ -0,0 +1,28 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use defmt_rtt as _; // global logger +use embassy::executor::Spawner; +use embassy_stm32::exti::ExtiInput; +use embassy_stm32::gpio::{Input, Pull}; +use embassy_stm32::Peripherals; +use panic_probe as _; + +#[embassy::main] +async fn main(_spawner: Spawner, p: Peripherals) { + info!("Hello World!"); + + let button = Input::new(p.PA0, Pull::Up); + let mut button = ExtiInput::new(button, p.EXTI0); + + info!("Press the USER button..."); + + loop { + button.wait_for_falling_edge().await; + info!("Pressed!"); + button.wait_for_rising_edge().await; + info!("Released!"); + } +} diff --git a/examples/stm32wl/src/bin/lorawan.rs b/examples/stm32wl/src/bin/lorawan.rs new file mode 100644 index 000000000..db4725630 --- /dev/null +++ b/examples/stm32wl/src/bin/lorawan.rs @@ -0,0 +1,72 @@ +#![no_std] +#![no_main] +#![macro_use] +#![allow(dead_code)] +#![feature(generic_associated_types)] +#![feature(type_alias_impl_trait)] + +use defmt_rtt as _; // global logger +use panic_probe as _; + +use embassy_lora::{stm32wl::*, LoraTimer}; +use embassy_stm32::{ + dma::NoDma, + gpio::{Level, Output, Pin, Speed}, + interrupt, pac, + rng::Rng, + subghz::*, + Peripherals, +}; +use lorawan_device::async_device::{region, Device, JoinMode}; +use lorawan_encoding::default_crypto::DefaultFactory as Crypto; + +fn config() -> embassy_stm32::Config { + let mut config = embassy_stm32::Config::default(); + config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; + config.rcc.enable_lsi = true; + config +} + +#[embassy::main(config = "config()")] +async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { + unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } + + let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); + let ctrl2 = Output::new(p.PC4.degrade(), Level::High, Speed::High); + let ctrl3 = Output::new(p.PC5.degrade(), Level::High, Speed::High); + let rfs = RadioSwitch::new(ctrl1, ctrl2, ctrl3); + + let radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); + + let irq = interrupt::take!(SUBGHZ_RADIO); + static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new(); + let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; + + let region = region::EU868::default().into(); + let mut radio_buffer = [0; 256]; + let mut device: Device<'_, _, Crypto, _, _> = Device::new( + region, + radio, + LoraTimer, + Rng::new(p.RNG), + &mut radio_buffer[..], + ); + + defmt::info!("Joining LoRaWAN network"); + + // TODO: Adjust the EUI and Keys according to your network credentials + device + .join(&JoinMode::OTAA { + deveui: [0, 0, 0, 0, 0, 0, 0, 0], + appeui: [0, 0, 0, 0, 0, 0, 0, 0], + appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], + }) + .await + .ok() + .unwrap(); + defmt::info!("LoRaWAN network joined"); + + defmt::info!("Sending 'PING'"); + device.send(b"PING", 1, false).await.ok().unwrap(); + defmt::info!("Message sent!"); +} diff --git a/examples/stm32wl/src/bin/subghz.rs b/examples/stm32wl/src/bin/subghz.rs new file mode 100644 index 000000000..562e25ac0 --- /dev/null +++ b/examples/stm32wl/src/bin/subghz.rs @@ -0,0 +1,130 @@ +#![no_std] +#![no_main] +#![macro_use] +#![allow(dead_code)] +#![feature(generic_associated_types)] +#![feature(type_alias_impl_trait)] + +use defmt_rtt as _; // global logger +use panic_probe as _; + +use defmt::*; +use embassy::channel::signal::Signal; +use embassy::interrupt::{Interrupt, InterruptExt}; +use embassy_stm32::dma::NoDma; +use embassy_stm32::exti::ExtiInput; +use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::interrupt; +use embassy_stm32::subghz::*; +use embassy_stm32::Peripherals; + +const PING_DATA: &str = "PING"; +const DATA_LEN: u8 = PING_DATA.len() as u8; +const PING_DATA_BYTES: &[u8] = PING_DATA.as_bytes(); +const PREAMBLE_LEN: u16 = 5 * 8; + +const RF_FREQ: RfFreq = RfFreq::from_frequency(867_500_000); + +const SYNC_WORD: [u8; 8] = [0x79, 0x80, 0x0C, 0xC0, 0x29, 0x95, 0xF8, 0x4A]; +const SYNC_WORD_LEN: u8 = SYNC_WORD.len() as u8; +const SYNC_WORD_LEN_BITS: u8 = SYNC_WORD_LEN * 8; + +const TX_BUF_OFFSET: u8 = 128; +const RX_BUF_OFFSET: u8 = 0; +const LORA_PACKET_PARAMS: LoRaPacketParams = LoRaPacketParams::new() + .set_crc_en(true) + .set_preamble_len(PREAMBLE_LEN) + .set_payload_len(DATA_LEN) + .set_invert_iq(false) + .set_header_type(HeaderType::Fixed); + +const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new() + .set_bw(LoRaBandwidth::Bw125) + .set_cr(CodingRate::Cr45) + .set_ldro_en(true) + .set_sf(SpreadingFactor::Sf7); + +// configuration for +10 dBm output power +// see table 35 "PA optimal setting and operating modes" +const PA_CONFIG: PaConfig = PaConfig::new() + .set_pa_duty_cycle(0x1) + .set_hp_max(0x0) + .set_pa(PaSel::Lp); + +const TCXO_MODE: TcxoMode = TcxoMode::new() + .set_txco_trim(TcxoTrim::Volts1pt7) + .set_timeout(Timeout::from_duration_sat( + core::time::Duration::from_millis(10), + )); + +const TX_PARAMS: TxParams = TxParams::new() + .set_power(0x0D) + .set_ramp_time(RampTime::Micros40); + +fn config() -> embassy_stm32::Config { + let mut config = embassy_stm32::Config::default(); + config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; + config +} + +#[embassy::main(config = "config()")] +async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { + let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); + let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); + let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); + + let button = Input::new(p.PA0, Pull::Up); + let mut pin = ExtiInput::new(button, p.EXTI0); + + static IRQ_SIGNAL: Signal<()> = Signal::new(); + let radio_irq = interrupt::take!(SUBGHZ_RADIO); + radio_irq.set_handler(|_| { + IRQ_SIGNAL.signal(()); + unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable(); + }); + + let mut radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); + + defmt::info!("Radio ready for use"); + + led1.set_low(); + + led2.set_high(); + + unwrap!(radio.set_standby(StandbyClk::Rc)); + unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); + unwrap!(radio.set_standby(StandbyClk::Hse)); + unwrap!(radio.set_regulator_mode(RegMode::Ldo)); + unwrap!(radio.set_buffer_base_address(TX_BUF_OFFSET, RX_BUF_OFFSET)); + unwrap!(radio.set_pa_config(&PA_CONFIG)); + unwrap!(radio.set_pa_ocp(Ocp::Max60m)); + unwrap!(radio.set_tx_params(&TX_PARAMS)); + unwrap!(radio.set_packet_type(PacketType::LoRa)); + unwrap!(radio.set_lora_sync_word(LoRaSyncWord::Public)); + unwrap!(radio.set_lora_mod_params(&LORA_MOD_PARAMS)); + unwrap!(radio.set_lora_packet_params(&LORA_PACKET_PARAMS)); + unwrap!(radio.calibrate_image(CalibrateImage::ISM_863_870)); + unwrap!(radio.set_rf_frequency(&RF_FREQ)); + + defmt::info!("Status: {:?}", unwrap!(radio.status())); + + led2.set_low(); + + loop { + pin.wait_for_rising_edge().await; + led3.set_high(); + unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); + unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); + unwrap!(radio.set_tx(Timeout::DISABLED)); + + radio_irq.enable(); + IRQ_SIGNAL.wait().await; + + let (_, irq_status) = unwrap!(radio.irq_status()); + if irq_status & Irq::TxDone.mask() != 0 { + defmt::info!("TX done"); + } + unwrap!(radio.clear_irq_status(irq_status)); + led3.set_low(); + } +} diff --git a/examples/stm32wl55/.cargo/config.toml b/examples/stm32wl55/.cargo/config.toml deleted file mode 100644 index 60076e06b..000000000 --- a/examples/stm32wl55/.cargo/config.toml +++ /dev/null @@ -1,6 +0,0 @@ -[target.'cfg(all(target_arch = "arm", target_os = "none"))'] -# replace your chip as listed in `probe-run --list-chips` -runner = "probe-run --chip STM32WLE5JCIx" - -[build] -target = "thumbv7em-none-eabihf" diff --git a/examples/stm32wl55/Cargo.toml b/examples/stm32wl55/Cargo.toml deleted file mode 100644 index 97b38aeab..000000000 --- a/examples/stm32wl55/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -authors = ["Dario Nieuwenhuis ", "Ulf Lilleengen "] -edition = "2018" -name = "embassy-stm32wl55-examples" -version = "0.1.0" -resolver = "2" - -[dependencies] -embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-timestamp-uptime"] } -embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "subghz", "unstable-pac", "exti"] } -embassy-lora = { version = "0.1.0", path = "../../embassy-lora", features = ["stm32wl", "time"] } - -lorawan-device = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["async"] } -lorawan-encoding = { git = "https://github.com/ivajloip/rust-lorawan.git", rev = "0de1a2a31933f7c97887b5718c1755fa5ab93a42", default-features = false, features = ["default-crypto"] } - -defmt = "0.3" -defmt-rtt = "0.3" - -cortex-m = "0.7.3" -cortex-m-rt = "0.7.0" -embedded-hal = "0.2.6" -panic-probe = { version = "0.3", features = ["print-defmt"] } -futures = { version = "0.3.17", default-features = false, features = ["async-await"] } -heapless = { version = "0.7.5", default-features = false } diff --git a/examples/stm32wl55/build.rs b/examples/stm32wl55/build.rs deleted file mode 100644 index 8cd32d7ed..000000000 --- a/examples/stm32wl55/build.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - println!("cargo:rustc-link-arg-bins=--nmagic"); - println!("cargo:rustc-link-arg-bins=-Tlink.x"); - println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); -} diff --git a/examples/stm32wl55/src/bin/blinky.rs b/examples/stm32wl55/src/bin/blinky.rs deleted file mode 100644 index 78079bfd3..000000000 --- a/examples/stm32wl55/src/bin/blinky.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use defmt_rtt as _; // global logger -use embassy::executor::Spawner; -use embassy::time::{Duration, Timer}; -use embassy_stm32::gpio::{Level, Output, Speed}; -use embassy_stm32::Peripherals; -use panic_probe as _; - -#[embassy::main] -async fn main(_spawner: Spawner, p: Peripherals) { - info!("Hello World!"); - - let mut led = Output::new(p.PB15, Level::High, Speed::Low); - - loop { - info!("high"); - led.set_high(); - Timer::after(Duration::from_millis(500)).await; - - info!("low"); - led.set_low(); - Timer::after(Duration::from_millis(500)).await; - } -} diff --git a/examples/stm32wl55/src/bin/button.rs b/examples/stm32wl55/src/bin/button.rs deleted file mode 100644 index f80b9ab4f..000000000 --- a/examples/stm32wl55/src/bin/button.rs +++ /dev/null @@ -1,31 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use defmt_rtt as _; // global logger -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use panic_probe as _; - -use cortex_m_rt::entry; - -#[entry] -fn main() -> ! { - info!("Hello World!"); - - let p = embassy_stm32::init(Default::default()); - - let button = Input::new(p.PA0, Pull::Up); - let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); - let mut led2 = Output::new(p.PB9, Level::High, Speed::Low); - - loop { - if button.is_high() { - led1.set_high(); - led2.set_low(); - } else { - led1.set_low(); - led2.set_high(); - } - } -} diff --git a/examples/stm32wl55/src/bin/button_exti.rs b/examples/stm32wl55/src/bin/button_exti.rs deleted file mode 100644 index 9a427c2d3..000000000 --- a/examples/stm32wl55/src/bin/button_exti.rs +++ /dev/null @@ -1,28 +0,0 @@ -#![no_std] -#![no_main] -#![feature(type_alias_impl_trait)] - -use defmt::*; -use defmt_rtt as _; // global logger -use embassy::executor::Spawner; -use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Pull}; -use embassy_stm32::Peripherals; -use panic_probe as _; - -#[embassy::main] -async fn main(_spawner: Spawner, p: Peripherals) { - info!("Hello World!"); - - let button = Input::new(p.PA0, Pull::Up); - let mut button = ExtiInput::new(button, p.EXTI0); - - info!("Press the USER button..."); - - loop { - button.wait_for_falling_edge().await; - info!("Pressed!"); - button.wait_for_rising_edge().await; - info!("Released!"); - } -} diff --git a/examples/stm32wl55/src/bin/lorawan.rs b/examples/stm32wl55/src/bin/lorawan.rs deleted file mode 100644 index db4725630..000000000 --- a/examples/stm32wl55/src/bin/lorawan.rs +++ /dev/null @@ -1,72 +0,0 @@ -#![no_std] -#![no_main] -#![macro_use] -#![allow(dead_code)] -#![feature(generic_associated_types)] -#![feature(type_alias_impl_trait)] - -use defmt_rtt as _; // global logger -use panic_probe as _; - -use embassy_lora::{stm32wl::*, LoraTimer}; -use embassy_stm32::{ - dma::NoDma, - gpio::{Level, Output, Pin, Speed}, - interrupt, pac, - rng::Rng, - subghz::*, - Peripherals, -}; -use lorawan_device::async_device::{region, Device, JoinMode}; -use lorawan_encoding::default_crypto::DefaultFactory as Crypto; - -fn config() -> embassy_stm32::Config { - let mut config = embassy_stm32::Config::default(); - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSI16; - config.rcc.enable_lsi = true; - config -} - -#[embassy::main(config = "config()")] -async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { - unsafe { pac::RCC.ccipr().modify(|w| w.set_rngsel(0b01)) } - - let ctrl1 = Output::new(p.PC3.degrade(), Level::High, Speed::High); - let ctrl2 = Output::new(p.PC4.degrade(), Level::High, Speed::High); - let ctrl3 = Output::new(p.PC5.degrade(), Level::High, Speed::High); - let rfs = RadioSwitch::new(ctrl1, ctrl2, ctrl3); - - let radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); - - let irq = interrupt::take!(SUBGHZ_RADIO); - static mut RADIO_STATE: SubGhzState<'static> = SubGhzState::new(); - let radio = unsafe { SubGhzRadio::new(&mut RADIO_STATE, radio, rfs, irq) }; - - let region = region::EU868::default().into(); - let mut radio_buffer = [0; 256]; - let mut device: Device<'_, _, Crypto, _, _> = Device::new( - region, - radio, - LoraTimer, - Rng::new(p.RNG), - &mut radio_buffer[..], - ); - - defmt::info!("Joining LoRaWAN network"); - - // TODO: Adjust the EUI and Keys according to your network credentials - device - .join(&JoinMode::OTAA { - deveui: [0, 0, 0, 0, 0, 0, 0, 0], - appeui: [0, 0, 0, 0, 0, 0, 0, 0], - appkey: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], - }) - .await - .ok() - .unwrap(); - defmt::info!("LoRaWAN network joined"); - - defmt::info!("Sending 'PING'"); - device.send(b"PING", 1, false).await.ok().unwrap(); - defmt::info!("Message sent!"); -} diff --git a/examples/stm32wl55/src/bin/subghz.rs b/examples/stm32wl55/src/bin/subghz.rs deleted file mode 100644 index 562e25ac0..000000000 --- a/examples/stm32wl55/src/bin/subghz.rs +++ /dev/null @@ -1,130 +0,0 @@ -#![no_std] -#![no_main] -#![macro_use] -#![allow(dead_code)] -#![feature(generic_associated_types)] -#![feature(type_alias_impl_trait)] - -use defmt_rtt as _; // global logger -use panic_probe as _; - -use defmt::*; -use embassy::channel::signal::Signal; -use embassy::interrupt::{Interrupt, InterruptExt}; -use embassy_stm32::dma::NoDma; -use embassy_stm32::exti::ExtiInput; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; -use embassy_stm32::interrupt; -use embassy_stm32::subghz::*; -use embassy_stm32::Peripherals; - -const PING_DATA: &str = "PING"; -const DATA_LEN: u8 = PING_DATA.len() as u8; -const PING_DATA_BYTES: &[u8] = PING_DATA.as_bytes(); -const PREAMBLE_LEN: u16 = 5 * 8; - -const RF_FREQ: RfFreq = RfFreq::from_frequency(867_500_000); - -const SYNC_WORD: [u8; 8] = [0x79, 0x80, 0x0C, 0xC0, 0x29, 0x95, 0xF8, 0x4A]; -const SYNC_WORD_LEN: u8 = SYNC_WORD.len() as u8; -const SYNC_WORD_LEN_BITS: u8 = SYNC_WORD_LEN * 8; - -const TX_BUF_OFFSET: u8 = 128; -const RX_BUF_OFFSET: u8 = 0; -const LORA_PACKET_PARAMS: LoRaPacketParams = LoRaPacketParams::new() - .set_crc_en(true) - .set_preamble_len(PREAMBLE_LEN) - .set_payload_len(DATA_LEN) - .set_invert_iq(false) - .set_header_type(HeaderType::Fixed); - -const LORA_MOD_PARAMS: LoRaModParams = LoRaModParams::new() - .set_bw(LoRaBandwidth::Bw125) - .set_cr(CodingRate::Cr45) - .set_ldro_en(true) - .set_sf(SpreadingFactor::Sf7); - -// configuration for +10 dBm output power -// see table 35 "PA optimal setting and operating modes" -const PA_CONFIG: PaConfig = PaConfig::new() - .set_pa_duty_cycle(0x1) - .set_hp_max(0x0) - .set_pa(PaSel::Lp); - -const TCXO_MODE: TcxoMode = TcxoMode::new() - .set_txco_trim(TcxoTrim::Volts1pt7) - .set_timeout(Timeout::from_duration_sat( - core::time::Duration::from_millis(10), - )); - -const TX_PARAMS: TxParams = TxParams::new() - .set_power(0x0D) - .set_ramp_time(RampTime::Micros40); - -fn config() -> embassy_stm32::Config { - let mut config = embassy_stm32::Config::default(); - config.rcc.mux = embassy_stm32::rcc::ClockSrc::HSE32; - config -} - -#[embassy::main(config = "config()")] -async fn main(_spawner: embassy::executor::Spawner, p: Peripherals) { - let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); - let mut led2 = Output::new(p.PB9, Level::Low, Speed::Low); - let mut led3 = Output::new(p.PB11, Level::Low, Speed::Low); - - let button = Input::new(p.PA0, Pull::Up); - let mut pin = ExtiInput::new(button, p.EXTI0); - - static IRQ_SIGNAL: Signal<()> = Signal::new(); - let radio_irq = interrupt::take!(SUBGHZ_RADIO); - radio_irq.set_handler(|_| { - IRQ_SIGNAL.signal(()); - unsafe { interrupt::SUBGHZ_RADIO::steal() }.disable(); - }); - - let mut radio = SubGhz::new(p.SUBGHZSPI, p.PA5, p.PA7, p.PA6, NoDma, NoDma); - - defmt::info!("Radio ready for use"); - - led1.set_low(); - - led2.set_high(); - - unwrap!(radio.set_standby(StandbyClk::Rc)); - unwrap!(radio.set_tcxo_mode(&TCXO_MODE)); - unwrap!(radio.set_standby(StandbyClk::Hse)); - unwrap!(radio.set_regulator_mode(RegMode::Ldo)); - unwrap!(radio.set_buffer_base_address(TX_BUF_OFFSET, RX_BUF_OFFSET)); - unwrap!(radio.set_pa_config(&PA_CONFIG)); - unwrap!(radio.set_pa_ocp(Ocp::Max60m)); - unwrap!(radio.set_tx_params(&TX_PARAMS)); - unwrap!(radio.set_packet_type(PacketType::LoRa)); - unwrap!(radio.set_lora_sync_word(LoRaSyncWord::Public)); - unwrap!(radio.set_lora_mod_params(&LORA_MOD_PARAMS)); - unwrap!(radio.set_lora_packet_params(&LORA_PACKET_PARAMS)); - unwrap!(radio.calibrate_image(CalibrateImage::ISM_863_870)); - unwrap!(radio.set_rf_frequency(&RF_FREQ)); - - defmt::info!("Status: {:?}", unwrap!(radio.status())); - - led2.set_low(); - - loop { - pin.wait_for_rising_edge().await; - led3.set_high(); - unwrap!(radio.set_irq_cfg(&CfgIrq::new().irq_enable_all(Irq::TxDone))); - unwrap!(radio.write_buffer(TX_BUF_OFFSET, PING_DATA_BYTES)); - unwrap!(radio.set_tx(Timeout::DISABLED)); - - radio_irq.enable(); - IRQ_SIGNAL.wait().await; - - let (_, irq_status) = unwrap!(radio.irq_status()); - if irq_status & Irq::TxDone.mask() != 0 { - defmt::info!("TX done"); - } - unwrap!(radio.clear_irq_status(irq_status)); - led3.set_low(); - } -} diff --git a/stm32-gen-features/src/lib.rs b/stm32-gen-features/src/lib.rs index c9768cdbb..bef11c2ad 100644 --- a/stm32-gen-features/src/lib.rs +++ b/stm32-gen-features/src/lib.rs @@ -3,22 +3,8 @@ use std::{iter::FilterMap, path::Path, slice::Iter}; const SUPPORTED_FAMILIES: &[&str] = &[ - "stm32f0", - "stm32f1", - "stm32f2", - "stm32f3", - "stm32f4", - "stm32f7", - "stm32g0", - "stm32g4", - "stm32l0", - "stm32l1", - "stm32l4", - "stm32l5", - "stm32h7", - "stm32u5", - "stm32wb55", - "stm32wl55", + "stm32f0", "stm32f1", "stm32f2", "stm32f3", "stm32f4", "stm32f7", "stm32g0", "stm32g4", + "stm32l0", "stm32l1", "stm32l4", "stm32l5", "stm32h7", "stm32u5", "stm32wb", "stm32wl5", ]; const SEPARATOR_START: &str = "# BEGIN GENERATED FEATURES\n"; -- cgit