aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.example.toml1
-rw-r--r--embassy-stm32/Cargo.toml10
-rw-r--r--embassy-stm32/gen_features.py1
-rw-r--r--examples/stm32wb55/.cargo/config.toml21
-rw-r--r--examples/stm32wb55/Cargo.toml35
-rw-r--r--examples/stm32wb55/build.rs31
-rw-r--r--examples/stm32wb55/memory.x41
-rw-r--r--examples/stm32wb55/src/bin/blinky.rs42
-rw-r--r--examples/stm32wb55/src/example_common.rs17
-rw-r--r--rust-toolchain.toml2
m---------stm32-data0
11 files changed, 200 insertions, 1 deletions
diff --git a/Cargo.example.toml b/Cargo.example.toml
index 5defac9e5..d94f7e9bb 100644
--- a/Cargo.example.toml
+++ b/Cargo.example.toml
@@ -36,6 +36,7 @@ members = [
36 #"examples/stm32f4", 36 #"examples/stm32f4",
37 #"examples/stm32h7", 37 #"examples/stm32h7",
38 #"examples/stm32l0", 38 #"examples/stm32l0",
39 #"examples/stm32wb55",
39 40
40 # rp2040 41 # rp2040
41 #"embassy-rp", 42 #"embassy-rp",
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml
index a93fce41e..8b9a00391 100644
--- a/embassy-stm32/Cargo.toml
+++ b/embassy-stm32/Cargo.toml
@@ -544,4 +544,14 @@ stm32l4s7zi = [ "stm32-metapac/stm32l4s7zi",]
544stm32l4s9ai = [ "stm32-metapac/stm32l4s9ai",] 544stm32l4s9ai = [ "stm32-metapac/stm32l4s9ai",]
545stm32l4s9vi = [ "stm32-metapac/stm32l4s9vi",] 545stm32l4s9vi = [ "stm32-metapac/stm32l4s9vi",]
546stm32l4s9zi = [ "stm32-metapac/stm32l4s9zi",] 546stm32l4s9zi = [ "stm32-metapac/stm32l4s9zi",]
547stm32wb55cc = [ "stm32-metapac/stm32wb55cc",]
548stm32wb55ce = [ "stm32-metapac/stm32wb55ce",]
549stm32wb55cg = [ "stm32-metapac/stm32wb55cg",]
550stm32wb55rc = [ "stm32-metapac/stm32wb55rc",]
551stm32wb55re = [ "stm32-metapac/stm32wb55re",]
552stm32wb55rg = [ "stm32-metapac/stm32wb55rg",]
553stm32wb55vc = [ "stm32-metapac/stm32wb55vc",]
554stm32wb55ve = [ "stm32-metapac/stm32wb55ve",]
555stm32wb55vg = [ "stm32-metapac/stm32wb55vg",]
556stm32wb55vy = [ "stm32-metapac/stm32wb55vy",]
547# END GENERATED FEATURES 557# END GENERATED FEATURES
diff --git a/embassy-stm32/gen_features.py b/embassy-stm32/gen_features.py
index e25a28563..4c46d602e 100644
--- a/embassy-stm32/gen_features.py
+++ b/embassy-stm32/gen_features.py
@@ -11,6 +11,7 @@ supported_families = [
11 'STM32L0', 11 'STM32L0',
12 'STM32L4', 12 'STM32L4',
13 'STM32H7', 13 'STM32H7',
14 'STM32WB55',
14] 15]
15 16
16# ======= load chip list 17# ======= load chip list
diff --git a/examples/stm32wb55/.cargo/config.toml b/examples/stm32wb55/.cargo/config.toml
new file mode 100644
index 000000000..9df740898
--- /dev/null
+++ b/examples/stm32wb55/.cargo/config.toml
@@ -0,0 +1,21 @@
1[unstable]
2build-std = ["core"]
3
4[target.'cfg(all(target_arch = "arm", target_os = "none"))']
5# replace STM32WB55CCUx with your chip as listed in `probe-run --list-chips`
6runner = "probe-run --chip STM32WB55CCUx --speed 1000 --connect-under-reset"
7
8rustflags = [
9 # LLD (shipped with the Rust toolchain) is used as the default linker
10 "-C", "link-arg=--nmagic",
11 "-C", "link-arg=-Tlink.x",
12 "-C", "link-arg=-Tdefmt.x",
13
14 # Code-size optimizations.
15 "-Z", "trap-unreachable=no",
16 "-C", "inline-threshold=5",
17 "-C", "no-vectorize-loops",
18]
19
20[build]
21target = "thumbv7em-none-eabihf"
diff --git a/examples/stm32wb55/Cargo.toml b/examples/stm32wb55/Cargo.toml
new file mode 100644
index 000000000..1ba79c580
--- /dev/null
+++ b/examples/stm32wb55/Cargo.toml
@@ -0,0 +1,35 @@
1[package]
2authors = ["Dario Nieuwenhuis <[email protected]>"]
3edition = "2018"
4name = "embassy-stm32f4-examples"
5version = "0.1.0"
6resolver = "2"
7
8[features]
9default = [
10 "defmt-default",
11]
12defmt-default = []
13defmt-trace = []
14defmt-debug = []
15defmt-info = []
16defmt-warn = []
17defmt-error = []
18
19[dependencies]
20embassy = { version = "0.1.0", path = "../../embassy", features = ["defmt", "defmt-trace"] }
21embassy-traits = { version = "0.1.0", path = "../../embassy-traits", features = ["defmt"] }
22embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "defmt-trace", "stm32wb55cc"] }
23embassy-extras = {version = "0.1.0", path = "../../embassy-extras" }
24stm32wb-pac = "0.2"
25
26defmt = "0.2.0"
27defmt-rtt = "0.2.0"
28
29cortex-m = "0.7.1"
30cortex-m-rt = "0.6.14"
31embedded-hal = { version = "0.2.4" }
32panic-probe = { version = "0.2.0", features= ["print-defmt"] }
33futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
34rtt-target = { version = "0.3", features = ["cortex-m"] }
35heapless = { version = "0.7.1", default-features = false }
diff --git a/examples/stm32wb55/build.rs b/examples/stm32wb55/build.rs
new file mode 100644
index 000000000..d534cc3df
--- /dev/null
+++ b/examples/stm32wb55/build.rs
@@ -0,0 +1,31 @@
1//! This build script copies the `memory.x` file from the crate root into
2//! a directory where the linker can always find it at build time.
3//! For many projects this is optional, as the linker always searches the
4//! project root directory -- wherever `Cargo.toml` is. However, if you
5//! are using a workspace or have a more complicated build setup, this
6//! build script becomes required. Additionally, by requesting that
7//! Cargo re-run the build script whenever `memory.x` is changed,
8//! updating `memory.x` ensures a rebuild of the application with the
9//! new memory settings.
10
11use std::env;
12use std::fs::File;
13use std::io::Write;
14use std::path::PathBuf;
15
16fn main() {
17 // Put `memory.x` in our output directory and ensure it's
18 // on the linker search path.
19 let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
20 File::create(out.join("memory.x"))
21 .unwrap()
22 .write_all(include_bytes!("memory.x"))
23 .unwrap();
24 println!("cargo:rustc-link-search={}", out.display());
25
26 // By default, Cargo will re-run a build script whenever
27 // any file in the project changes. By specifying `memory.x`
28 // here, we ensure the build script is only re-run when
29 // `memory.x` is changed.
30 println!("cargo:rerun-if-changed=memory.x");
31}
diff --git a/examples/stm32wb55/memory.x b/examples/stm32wb55/memory.x
new file mode 100644
index 000000000..2b4dcce34
--- /dev/null
+++ b/examples/stm32wb55/memory.x
@@ -0,0 +1,41 @@
1/*
2 The size of this file must be exactly the same as in other memory_xx.x files.
3 Memory size for STM32WB55xC with 256K FLASH
4*/
5
6MEMORY
7{
8 FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K
9 RAM (xrw) : ORIGIN = 0x20000004, LENGTH = 191K
10 RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K
11}
12
13/* Place stack at the end of SRAM1 */
14_stack_start = ORIGIN(RAM) + LENGTH(RAM);
15
16/*
17 * Scatter the mailbox interface memory sections in shared memory
18 */
19SECTIONS {
20 TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED
21
22 TL_DEVICE_INFO_TABLE 0x2003001c (NOLOAD) : { *(TL_DEVICE_INFO_TABLE) } >RAM_SHARED
23 TL_BLE_TABLE 0x2003003c (NOLOAD) : { *(TL_BLE_TABLE) } >RAM_SHARED
24 TL_THREAD_TABLE 0x2003004c (NOLOAD) : { *(TL_THREAD_TABLE) } >RAM_SHARED
25 TL_SYS_TABLE 0x20030058 (NOLOAD) : { *(TL_SYS_TABLE) } >RAM_SHARED
26 TL_MEM_MANAGER_TABLE 0x20030060 (NOLOAD) : { *(TL_MEM_MANAGER_TABLE) } >RAM_SHARED
27 TL_TRACES_TABLE 0x2003007c (NOLOAD) : { *(TL_TRACES_TABLE) } >RAM_SHARED
28 TL_MAC_802_15_4_TABLE 0x20030080 (NOLOAD) : { *(TL_MAC_802_15_4_TABLE) } >RAM_SHARED
29
30 HCI_ACL_DATA_BUFFER 0x20030a08 (NOLOAD) : { *(HCI_ACL_DATA_BUFFER) } >RAM_SHARED
31 BLE_CMD_BUFFER 0x200308fc (NOLOAD) : { *(BLE_CMD_BUFFER) } >RAM_SHARED
32 BLE_SPARE_EVT_BUF 0x200301a8 (NOLOAD) : { *(BLE_SPARE_EVT_BUF) } >RAM_SHARED
33 SYS_SPARE_EVT_BUF 0x200302b4 (NOLOAD) : { *(SYS_SPARE_EVT_BUF) } >RAM_SHARED
34 EVT_POOL 0x200303c0 (NOLOAD) : { *(EVT_POOL) } >RAM_SHARED
35 SYS_CMD_BUF 0x2003009c (NOLOAD) : { *(SYS_CMD_BUF) } >RAM_SHARED
36 SYSTEM_EVT_QUEUE 0x20030b28 (NOLOAD) : { *(SYSTEM_EVT_QUEUE) } >RAM_SHARED
37 EVT_QUEUE 0x20030b10 (NOLOAD) : { *(EVT_QUEUE) } >RAM_SHARED
38 CS_BUFFER 0x20030b18 (NOLOAD) : { *(CS_BUFFER) } >RAM_SHARED
39 TRACES_EVT_QUEUE 0x20030094 (NOLOAD) : { *(TRACES_EVT_QUEUE) } >RAM_SHARED
40 FREE_BUF_QUEUE 0x2003008c (NOLOAD) : { *(FREE_BUF_QUEUE) } >RAM_SHARED
41}
diff --git a/examples/stm32wb55/src/bin/blinky.rs b/examples/stm32wb55/src/bin/blinky.rs
new file mode 100644
index 000000000..8ce78a3c3
--- /dev/null
+++ b/examples/stm32wb55/src/bin/blinky.rs
@@ -0,0 +1,42 @@
1#![no_std]
2#![no_main]
3#![feature(trait_alias)]
4#![feature(min_type_alias_impl_trait)]
5#![feature(impl_trait_in_bindings)]
6#![feature(type_alias_impl_trait)]
7#![allow(incomplete_features)]
8
9#[path = "../example_common.rs"]
10mod example_common;
11use embassy_stm32::gpio::{Level, Output};
12use embedded_hal::digital::v2::OutputPin;
13use example_common::*;
14
15use cortex_m_rt::entry;
16use stm32wb_pac as pac;
17
18#[entry]
19fn main() -> ! {
20 info!("Hello World!");
21
22 let pp = pac::Peripherals::take().unwrap();
23
24 pp.RCC.ahb2enr.modify(|_, w| {
25 w.gpioben().set_bit();
26 w
27 });
28
29 let p = embassy_stm32::init(Default::default());
30
31 let mut led = Output::new(p.PB0, Level::High);
32
33 loop {
34 info!("high");
35 led.set_high().unwrap();
36 cortex_m::asm::delay(10_000_000);
37
38 info!("low");
39 led.set_low().unwrap();
40 cortex_m::asm::delay(10_000_000);
41 }
42}
diff --git a/examples/stm32wb55/src/example_common.rs b/examples/stm32wb55/src/example_common.rs
new file mode 100644
index 000000000..54d633837
--- /dev/null
+++ b/examples/stm32wb55/src/example_common.rs
@@ -0,0 +1,17 @@
1#![macro_use]
2
3use defmt_rtt as _; // global logger
4use panic_probe as _;
5
6pub use defmt::*;
7
8use core::sync::atomic::{AtomicUsize, Ordering};
9
10defmt::timestamp! {"{=u64}", {
11 static COUNT: AtomicUsize = AtomicUsize::new(0);
12 // NOTE(no-CAS) `timestamps` runs with interrupts disabled
13 let n = COUNT.load(Ordering::Relaxed);
14 COUNT.store(n + 1, Ordering::Relaxed);
15 n as u64
16 }
17}
diff --git a/rust-toolchain.toml b/rust-toolchain.toml
index 2cb177974..3e084ac46 100644
--- a/rust-toolchain.toml
+++ b/rust-toolchain.toml
@@ -3,4 +3,4 @@
3[toolchain] 3[toolchain]
4channel = "nightly-2021-05-07" 4channel = "nightly-2021-05-07"
5components = [ "rust-src", "rustfmt" ] 5components = [ "rust-src", "rustfmt" ]
6targets = [ "thumbv7em-none-eabi", "thumbv6m-none-eabi" ] 6targets = [ "thumbv7em-none-eabi", "thumbv6m-none-eabi", "thumbv7em-none-eabihf" ]
diff --git a/stm32-data b/stm32-data
Subproject a33b0b94b06cda756ed8cff0c404131f0349ae5 Subproject 8f32d8e4f25276f6f2155e8dd5bbed1acefd657