diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-09-16 03:44:01 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2023-09-16 04:04:45 +0200 |
| commit | 8315cf064eab133006e1397819b50f072fec6398 (patch) | |
| tree | 6eaa13745fc8df757e07c9c4e749aa7343a7f206 /examples | |
| parent | a2a26f489b81a0ad34c5244f2acfde2ecb9951fe (diff) | |
stm32: add stm32wba support.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wba/.cargo/config.toml | 8 | ||||
| -rw-r--r-- | examples/stm32wba/Cargo.toml | 26 | ||||
| -rw-r--r-- | examples/stm32wba/build.rs | 10 | ||||
| -rw-r--r-- | examples/stm32wba/src/bin/blinky.rs | 27 | ||||
| -rw-r--r-- | examples/stm32wba/src/bin/button_exti.rs | 27 |
5 files changed, 98 insertions, 0 deletions
diff --git a/examples/stm32wba/.cargo/config.toml b/examples/stm32wba/.cargo/config.toml new file mode 100644 index 000000000..477413397 --- /dev/null +++ b/examples/stm32wba/.cargo/config.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [target.'cfg(all(target_arch = "arm", target_os = "none"))'] | ||
| 2 | runner = "probe-rs run --chip STM32WBA52CGUxT" | ||
| 3 | |||
| 4 | [build] | ||
| 5 | target = "thumbv8m.main-none-eabihf" | ||
| 6 | |||
| 7 | [env] | ||
| 8 | DEFMT_LOG = "trace" | ||
diff --git a/examples/stm32wba/Cargo.toml b/examples/stm32wba/Cargo.toml new file mode 100644 index 000000000..26fcce26b --- /dev/null +++ b/examples/stm32wba/Cargo.toml | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32wba-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] } | ||
| 9 | embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 10 | embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | ||
| 11 | embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 12 | embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true } | ||
| 13 | |||
| 14 | defmt = "0.3" | ||
| 15 | defmt-rtt = "0.4" | ||
| 16 | |||
| 17 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 18 | cortex-m-rt = "0.7.0" | ||
| 19 | embedded-hal = "0.2.6" | ||
| 20 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 21 | futures = { version = "0.3.17", default-features = false, features = ["async-await"] } | ||
| 22 | heapless = { version = "0.7.5", default-features = false } | ||
| 23 | static_cell = { version = "1.1", features = ["nightly"]} | ||
| 24 | |||
| 25 | [profile.release] | ||
| 26 | debug = 2 | ||
diff --git a/examples/stm32wba/build.rs b/examples/stm32wba/build.rs new file mode 100644 index 000000000..8fc6faab8 --- /dev/null +++ b/examples/stm32wba/build.rs | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | use std::error::Error; | ||
| 2 | |||
| 3 | fn main() -> Result<(), Box<dyn Error>> { | ||
| 4 | println!("cargo:rerun-if-changed=link.x"); | ||
| 5 | println!("cargo:rustc-link-arg-bins=--nmagic"); | ||
| 6 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | ||
| 7 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | ||
| 8 | |||
| 9 | Ok(()) | ||
| 10 | } | ||
diff --git a/examples/stm32wba/src/bin/blinky.rs b/examples/stm32wba/src/bin/blinky.rs new file mode 100644 index 000000000..530746296 --- /dev/null +++ b/examples/stm32wba/src/bin/blinky.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 8 | use embassy_time::{Duration, Timer}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | let mut led = Output::new(p.PB4, Level::High, Speed::Low); | ||
| 17 | |||
| 18 | loop { | ||
| 19 | info!("high"); | ||
| 20 | led.set_high(); | ||
| 21 | Timer::after(Duration::from_millis(500)).await; | ||
| 22 | |||
| 23 | info!("low"); | ||
| 24 | led.set_low(); | ||
| 25 | Timer::after(Duration::from_millis(500)).await; | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/examples/stm32wba/src/bin/button_exti.rs b/examples/stm32wba/src/bin/button_exti.rs new file mode 100644 index 000000000..ef32d4c4a --- /dev/null +++ b/examples/stm32wba/src/bin/button_exti.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | #![feature(type_alias_impl_trait)] | ||
| 4 | |||
| 5 | use defmt::*; | ||
| 6 | use embassy_executor::Spawner; | ||
| 7 | use embassy_stm32::exti::ExtiInput; | ||
| 8 | use embassy_stm32::gpio::{Input, Pull}; | ||
| 9 | use {defmt_rtt as _, panic_probe as _}; | ||
| 10 | |||
| 11 | #[embassy_executor::main] | ||
| 12 | async fn main(_spawner: Spawner) { | ||
| 13 | let p = embassy_stm32::init(Default::default()); | ||
| 14 | info!("Hello World!"); | ||
| 15 | |||
| 16 | let button = Input::new(p.PC13, Pull::Up); | ||
| 17 | let mut button = ExtiInput::new(button, p.EXTI13); | ||
| 18 | |||
| 19 | info!("Press the USER button..."); | ||
| 20 | |||
| 21 | loop { | ||
| 22 | button.wait_for_falling_edge().await; | ||
| 23 | info!("Pressed!"); | ||
| 24 | button.wait_for_rising_edge().await; | ||
| 25 | info!("Released!"); | ||
| 26 | } | ||
| 27 | } | ||
