aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2023-09-16 03:44:01 +0200
committerDario Nieuwenhuis <[email protected]>2023-09-16 04:04:45 +0200
commit8315cf064eab133006e1397819b50f072fec6398 (patch)
tree6eaa13745fc8df757e07c9c4e749aa7343a7f206 /examples
parenta2a26f489b81a0ad34c5244f2acfde2ecb9951fe (diff)
stm32: add stm32wba support.
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wba/.cargo/config.toml8
-rw-r--r--examples/stm32wba/Cargo.toml26
-rw-r--r--examples/stm32wba/build.rs10
-rw-r--r--examples/stm32wba/src/bin/blinky.rs27
-rw-r--r--examples/stm32wba/src/bin/button_exti.rs27
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"))']
2runner = "probe-rs run --chip STM32WBA52CGUxT"
3
4[build]
5target = "thumbv8m.main-none-eabihf"
6
7[env]
8DEFMT_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]
2edition = "2021"
3name = "embassy-stm32wba-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wba52cg", "time-driver-any", "memory-x", "exti"] }
9embassy-sync = { version = "0.3.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["nightly", "arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] }
11embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
12embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "udp", "proto-ipv6", "medium-ieee802154", "nightly"], optional=true }
13
14defmt = "0.3"
15defmt-rtt = "0.4"
16
17cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
18cortex-m-rt = "0.7.0"
19embedded-hal = "0.2.6"
20panic-probe = { version = "0.3", features = ["print-defmt"] }
21futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
22heapless = { version = "0.7.5", default-features = false }
23static_cell = { version = "1.1", features = ["nightly"]}
24
25[profile.release]
26debug = 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 @@
1use std::error::Error;
2
3fn 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
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed};
8use embassy_time::{Duration, Timer};
9use {defmt_rtt as _, panic_probe as _};
10
11#[embassy_executor::main]
12async 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
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::exti::ExtiInput;
8use embassy_stm32::gpio::{Input, Pull};
9use {defmt_rtt as _, panic_probe as _};
10
11#[embassy_executor::main]
12async 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}