aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/boot/application/stm32wl/memory.x11
-rw-r--r--examples/boot/application/stm32wl/src/bin/a.rs8
-rw-r--r--examples/boot/application/stm32wl/src/bin/b.rs8
-rw-r--r--examples/stm32h755cm4/.cargo/config.toml8
-rw-r--r--examples/stm32h755cm4/Cargo.toml75
-rw-r--r--examples/stm32h755cm4/build.rs35
-rw-r--r--examples/stm32h755cm4/memory.x15
-rw-r--r--examples/stm32h755cm4/src/bin/blinky.rs32
-rw-r--r--examples/stm32h755cm7/.cargo/config.toml8
-rw-r--r--examples/stm32h755cm7/Cargo.toml75
-rw-r--r--examples/stm32h755cm7/build.rs35
-rw-r--r--examples/stm32h755cm7/memory.x15
-rw-r--r--examples/stm32h755cm7/src/bin/blinky.rs54
-rw-r--r--examples/stm32wl/memory.x15
-rw-r--r--examples/stm32wl/src/bin/blinky.rs8
-rw-r--r--examples/stm32wl/src/bin/button.rs8
-rw-r--r--examples/stm32wl/src/bin/button_exti.rs8
-rw-r--r--examples/stm32wl/src/bin/flash.rs8
-rw-r--r--examples/stm32wl/src/bin/random.rs9
-rw-r--r--examples/stm32wl/src/bin/rtc.rs9
-rw-r--r--examples/stm32wl/src/bin/uart_async.rs9
21 files changed, 440 insertions, 13 deletions
diff --git a/examples/boot/application/stm32wl/memory.x b/examples/boot/application/stm32wl/memory.x
index e1d4e7fa8..5af1723f5 100644
--- a/examples/boot/application/stm32wl/memory.x
+++ b/examples/boot/application/stm32wl/memory.x
@@ -5,7 +5,8 @@ MEMORY
5 BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K 5 BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
6 FLASH : ORIGIN = 0x08008000, LENGTH = 64K 6 FLASH : ORIGIN = 0x08008000, LENGTH = 64K
7 DFU : ORIGIN = 0x08018000, LENGTH = 68K 7 DFU : ORIGIN = 0x08018000, LENGTH = 68K
8 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K 8 SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64
9 RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 32K - 64
9} 10}
10 11
11__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); 12__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER);
@@ -13,3 +14,11 @@ __bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - O
13 14
14__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); 15__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER);
15__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); 16__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER);
17
18SECTIONS
19{
20 .shared_data :
21 {
22 *(.shared_data)
23 } > SHARED_RAM
24} \ No newline at end of file
diff --git a/examples/boot/application/stm32wl/src/bin/a.rs b/examples/boot/application/stm32wl/src/bin/a.rs
index 9f4f0b238..127de0237 100644
--- a/examples/boot/application/stm32wl/src/bin/a.rs
+++ b/examples/boot/application/stm32wl/src/bin/a.rs
@@ -1,6 +1,8 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4#[cfg(feature = "defmt")] 6#[cfg(feature = "defmt")]
5use defmt_rtt::*; 7use defmt_rtt::*;
6use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig}; 8use embassy_boot_stm32::{AlignedBuffer, FirmwareUpdater, FirmwareUpdaterConfig};
@@ -9,6 +11,7 @@ use embassy_executor::Spawner;
9use embassy_stm32::exti::ExtiInput; 11use embassy_stm32::exti::ExtiInput;
10use embassy_stm32::flash::{Flash, WRITE_SIZE}; 12use embassy_stm32::flash::{Flash, WRITE_SIZE};
11use embassy_stm32::gpio::{Level, Output, Pull, Speed}; 13use embassy_stm32::gpio::{Level, Output, Pull, Speed};
14use embassy_stm32::SharedData;
12use embassy_sync::mutex::Mutex; 15use embassy_sync::mutex::Mutex;
13use panic_reset as _; 16use panic_reset as _;
14 17
@@ -17,9 +20,12 @@ static APP_B: &[u8] = &[0, 1, 2, 3];
17#[cfg(not(feature = "skip-include"))] 20#[cfg(not(feature = "skip-include"))]
18static APP_B: &[u8] = include_bytes!("../../b.bin"); 21static APP_B: &[u8] = include_bytes!("../../b.bin");
19 22
23#[link_section = ".shared_data"]
24static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
25
20#[embassy_executor::main] 26#[embassy_executor::main]
21async fn main(_spawner: Spawner) { 27async fn main(_spawner: Spawner) {
22 let p = embassy_stm32::init(Default::default()); 28 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
23 let flash = Flash::new_blocking(p.FLASH); 29 let flash = Flash::new_blocking(p.FLASH);
24 let flash = Mutex::new(BlockingAsync::new(flash)); 30 let flash = Mutex::new(BlockingAsync::new(flash));
25 31
diff --git a/examples/boot/application/stm32wl/src/bin/b.rs b/examples/boot/application/stm32wl/src/bin/b.rs
index e954d8b91..768dadf8b 100644
--- a/examples/boot/application/stm32wl/src/bin/b.rs
+++ b/examples/boot/application/stm32wl/src/bin/b.rs
@@ -1,16 +1,22 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4#[cfg(feature = "defmt")] 6#[cfg(feature = "defmt")]
5use defmt_rtt::*; 7use defmt_rtt::*;
6use embassy_executor::Spawner; 8use embassy_executor::Spawner;
7use embassy_stm32::gpio::{Level, Output, Speed}; 9use embassy_stm32::gpio::{Level, Output, Speed};
10use embassy_stm32::SharedData;
8use embassy_time::Timer; 11use embassy_time::Timer;
9use panic_reset as _; 12use panic_reset as _;
10 13
14#[link_section = ".shared_data"]
15static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
16
11#[embassy_executor::main] 17#[embassy_executor::main]
12async fn main(_spawner: Spawner) { 18async fn main(_spawner: Spawner) {
13 let p = embassy_stm32::init(Default::default()); 19 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
14 let mut led = Output::new(p.PB15, Level::High, Speed::Low); 20 let mut led = Output::new(p.PB15, Level::High, Speed::Low);
15 21
16 loop { 22 loop {
diff --git a/examples/stm32h755cm4/.cargo/config.toml b/examples/stm32h755cm4/.cargo/config.toml
new file mode 100644
index 000000000..193e6bbc3
--- /dev/null
+++ b/examples/stm32h755cm4/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip STM32H755ZITx --catch-hardfault --always-print-stacktrace'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/stm32h755cm4/Cargo.toml b/examples/stm32h755cm4/Cargo.toml
new file mode 100644
index 000000000..9d2fb9060
--- /dev/null
+++ b/examples/stm32h755cm4/Cargo.toml
@@ -0,0 +1,75 @@
1[package]
2edition = "2021"
3name = "embassy-stm32h7-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8# Change stm32h755zi-cm4 to your chip name, if necessary.
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm4", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.6.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
13embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
15embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17
18defmt = "0.3"
19defmt-rtt = "0.4"
20
21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
22cortex-m-rt = "0.7.0"
23embedded-hal = "0.2.6"
24embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
25embedded-hal-async = { version = "1.0" }
26embedded-nal-async = { version = "0.7.1" }
27embedded-io-async = { version = "0.6.1" }
28panic-probe = { version = "0.3", features = ["print-defmt"] }
29heapless = { version = "0.8", default-features = false }
30rand_core = "0.6.3"
31critical-section = "1.1"
32micromath = "2.0.0"
33stm32-fmc = "0.3.0"
34embedded-storage = "0.3.1"
35static_cell = "2"
36chrono = { version = "^0.4", default-features = false }
37grounded = "0.2.0"
38
39# cargo build/run
40[profile.dev]
41codegen-units = 1
42debug = 2
43debug-assertions = true # <-
44incremental = false
45opt-level = 3 # <-
46overflow-checks = true # <-
47
48# cargo test
49[profile.test]
50codegen-units = 1
51debug = 2
52debug-assertions = true # <-
53incremental = false
54opt-level = 3 # <-
55overflow-checks = true # <-
56
57# cargo build/run --release
58[profile.release]
59codegen-units = 1
60debug = 2
61debug-assertions = false # <-
62incremental = false
63lto = 'fat'
64opt-level = 3 # <-
65overflow-checks = false # <-
66
67# cargo test --release
68[profile.bench]
69codegen-units = 1
70debug = 2
71debug-assertions = false # <-
72incremental = false
73lto = 'fat'
74opt-level = 3 # <-
75overflow-checks = false # <-
diff --git a/examples/stm32h755cm4/build.rs b/examples/stm32h755cm4/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/stm32h755cm4/build.rs
@@ -0,0 +1,35 @@
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
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/stm32h755cm4/memory.x b/examples/stm32h755cm4/memory.x
new file mode 100644
index 000000000..7d60354e3
--- /dev/null
+++ b/examples/stm32h755cm4/memory.x
@@ -0,0 +1,15 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08100000, LENGTH = 1024K /* BANK_2 */
4 RAM : ORIGIN = 0x10000000, LENGTH = 128K /* SRAM1 */
5 RAM_D3 : ORIGIN = 0x38000000, LENGTH = 64K /* SRAM4 */
6}
7
8SECTIONS
9{
10 .ram_d3 :
11 {
12 *(.ram_d3.shared_data)
13 *(.ram_d3)
14 } > RAM_D3
15} \ No newline at end of file
diff --git a/examples/stm32h755cm4/src/bin/blinky.rs b/examples/stm32h755cm4/src/bin/blinky.rs
new file mode 100644
index 000000000..b5c547839
--- /dev/null
+++ b/examples/stm32h755cm4/src/bin/blinky.rs
@@ -0,0 +1,32 @@
1#![no_std]
2#![no_main]
3
4use core::mem::MaybeUninit;
5
6use defmt::*;
7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_stm32::SharedData;
10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _};
12
13#[link_section = ".ram_d3.shared_data"]
14static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
15
16#[embassy_executor::main]
17async fn main(_spawner: Spawner) {
18 let p = embassy_stm32::init_secondary(&SHARED_DATA);
19 info!("Hello World!");
20
21 let mut led = Output::new(p.PE1, Level::High, Speed::Low);
22
23 loop {
24 info!("high");
25 led.set_high();
26 Timer::after_millis(250).await;
27
28 info!("low");
29 led.set_low();
30 Timer::after_millis(250).await;
31 }
32}
diff --git a/examples/stm32h755cm7/.cargo/config.toml b/examples/stm32h755cm7/.cargo/config.toml
new file mode 100644
index 000000000..193e6bbc3
--- /dev/null
+++ b/examples/stm32h755cm7/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip STM32H755ZITx --catch-hardfault --always-print-stacktrace'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/stm32h755cm7/Cargo.toml b/examples/stm32h755cm7/Cargo.toml
new file mode 100644
index 000000000..ab088fd33
--- /dev/null
+++ b/examples/stm32h755cm7/Cargo.toml
@@ -0,0 +1,75 @@
1[package]
2edition = "2021"
3name = "embassy-stm32h7-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8# Change stm32h743bi to your chip name, if necessary.
9embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm7", "time-driver-tim3", "exti", "memory-x", "unstable-pac", "chrono"] }
10embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] }
11embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.6.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
13embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] }
15embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] }
16embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
17
18defmt = "0.3"
19defmt-rtt = "0.4"
20
21cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
22cortex-m-rt = "0.7.0"
23embedded-hal = "0.2.6"
24embedded-hal-1 = { package = "embedded-hal", version = "1.0" }
25embedded-hal-async = { version = "1.0" }
26embedded-nal-async = { version = "0.7.1" }
27embedded-io-async = { version = "0.6.1" }
28panic-probe = { version = "0.3", features = ["print-defmt"] }
29heapless = { version = "0.8", default-features = false }
30rand_core = "0.6.3"
31critical-section = "1.1"
32micromath = "2.0.0"
33stm32-fmc = "0.3.0"
34embedded-storage = "0.3.1"
35static_cell = "2"
36chrono = { version = "^0.4", default-features = false }
37grounded = "0.2.0"
38
39# cargo build/run
40[profile.dev]
41codegen-units = 1
42debug = 2
43debug-assertions = true # <-
44incremental = false
45opt-level = 3 # <-
46overflow-checks = true # <-
47
48# cargo test
49[profile.test]
50codegen-units = 1
51debug = 2
52debug-assertions = true # <-
53incremental = false
54opt-level = 3 # <-
55overflow-checks = true # <-
56
57# cargo build/run --release
58[profile.release]
59codegen-units = 1
60debug = 2
61debug-assertions = false # <-
62incremental = false
63lto = 'fat'
64opt-level = 3 # <-
65overflow-checks = false # <-
66
67# cargo test --release
68[profile.bench]
69codegen-units = 1
70debug = 2
71debug-assertions = false # <-
72incremental = false
73lto = 'fat'
74opt-level = 3 # <-
75overflow-checks = false # <-
diff --git a/examples/stm32h755cm7/build.rs b/examples/stm32h755cm7/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/stm32h755cm7/build.rs
@@ -0,0 +1,35 @@
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
32 println!("cargo:rustc-link-arg-bins=--nmagic");
33 println!("cargo:rustc-link-arg-bins=-Tlink.x");
34 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
35}
diff --git a/examples/stm32h755cm7/memory.x b/examples/stm32h755cm7/memory.x
new file mode 100644
index 000000000..ef884796a
--- /dev/null
+++ b/examples/stm32h755cm7/memory.x
@@ -0,0 +1,15 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08000000, LENGTH = 1024K /* BANK_1 */
4 RAM : ORIGIN = 0x24000000, LENGTH = 512K /* AXIRAM */
5 RAM_D3 : ORIGIN = 0x38000000, LENGTH = 64K /* SRAM4 */
6}
7
8SECTIONS
9{
10 .ram_d3 :
11 {
12 *(.ram_d3.shared_data)
13 *(.ram_d3)
14 } > RAM_D3
15} \ No newline at end of file
diff --git a/examples/stm32h755cm7/src/bin/blinky.rs b/examples/stm32h755cm7/src/bin/blinky.rs
new file mode 100644
index 000000000..94d2226c0
--- /dev/null
+++ b/examples/stm32h755cm7/src/bin/blinky.rs
@@ -0,0 +1,54 @@
1#![no_std]
2#![no_main]
3
4use core::mem::MaybeUninit;
5
6use defmt::*;
7use embassy_executor::Spawner;
8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_stm32::SharedData;
10use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _};
12
13#[link_section = ".ram_d3.shared_data"]
14static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
15
16#[embassy_executor::main]
17async fn main(_spawner: Spawner) {
18 let mut config = embassy_stm32::Config::default();
19 {
20 use embassy_stm32::rcc::*;
21 config.rcc.hsi = Some(HSIPrescaler::DIV1);
22 config.rcc.csi = true;
23 config.rcc.pll1 = Some(Pll {
24 source: PllSource::HSI,
25 prediv: PllPreDiv::DIV4,
26 mul: PllMul::MUL50,
27 divp: Some(PllDiv::DIV2),
28 divq: Some(PllDiv::DIV8), // 100mhz
29 divr: None,
30 });
31 config.rcc.sys = Sysclk::PLL1_P; // 400 Mhz
32 config.rcc.ahb_pre = AHBPrescaler::DIV2; // 200 Mhz
33 config.rcc.apb1_pre = APBPrescaler::DIV2; // 100 Mhz
34 config.rcc.apb2_pre = APBPrescaler::DIV2; // 100 Mhz
35 config.rcc.apb3_pre = APBPrescaler::DIV2; // 100 Mhz
36 config.rcc.apb4_pre = APBPrescaler::DIV2; // 100 Mhz
37 config.rcc.voltage_scale = VoltageScale::Scale1;
38 config.rcc.supply_config = SupplyConfig::DirectSMPS;
39 }
40 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
41 info!("Hello World!");
42
43 let mut led = Output::new(p.PB14, Level::High, Speed::Low);
44
45 loop {
46 info!("high");
47 led.set_high();
48 Timer::after_millis(500).await;
49
50 info!("low");
51 led.set_low();
52 Timer::after_millis(500).await;
53 }
54}
diff --git a/examples/stm32wl/memory.x b/examples/stm32wl/memory.x
new file mode 100644
index 000000000..0298caa4b
--- /dev/null
+++ b/examples/stm32wl/memory.x
@@ -0,0 +1,15 @@
1MEMORY
2{
3 /* NOTE 1 K = 1 KiBi = 1024 bytes */
4 FLASH : ORIGIN = 0x08000000, LENGTH = 256K
5 SHARED_RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 64
6 RAM (rwx) : ORIGIN = 0x20000040, LENGTH = 64K - 64
7}
8
9SECTIONS
10{
11 .shared_data :
12 {
13 *(.shared_data)
14 } > SHARED_RAM
15} \ No newline at end of file
diff --git a/examples/stm32wl/src/bin/blinky.rs b/examples/stm32wl/src/bin/blinky.rs
index 347bd093f..ce7d0ec58 100644
--- a/examples/stm32wl/src/bin/blinky.rs
+++ b/examples/stm32wl/src/bin/blinky.rs
@@ -1,15 +1,21 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use defmt::*; 6use defmt::*;
5use embassy_executor::Spawner; 7use embassy_executor::Spawner;
6use embassy_stm32::gpio::{Level, Output, Speed}; 8use embassy_stm32::gpio::{Level, Output, Speed};
9use embassy_stm32::SharedData;
7use embassy_time::Timer; 10use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
9 12
13#[link_section = ".shared_data"]
14static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
15
10#[embassy_executor::main] 16#[embassy_executor::main]
11async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
12 let p = embassy_stm32::init(Default::default()); 18 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
13 info!("Hello World!"); 19 info!("Hello World!");
14 20
15 let mut led = Output::new(p.PB15, Level::High, Speed::Low); 21 let mut led = Output::new(p.PB15, Level::High, Speed::Low);
diff --git a/examples/stm32wl/src/bin/button.rs b/examples/stm32wl/src/bin/button.rs
index eccd211e2..8b5204479 100644
--- a/examples/stm32wl/src/bin/button.rs
+++ b/examples/stm32wl/src/bin/button.rs
@@ -1,16 +1,22 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use cortex_m_rt::entry; 6use cortex_m_rt::entry;
5use defmt::*; 7use defmt::*;
6use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; 8use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
9use embassy_stm32::SharedData;
7use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
8 11
12#[link_section = ".shared_data"]
13static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
14
9#[entry] 15#[entry]
10fn main() -> ! { 16fn main() -> ! {
11 info!("Hello World!"); 17 info!("Hello World!");
12 18
13 let p = embassy_stm32::init(Default::default()); 19 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
14 20
15 let button = Input::new(p.PA0, Pull::Up); 21 let button = Input::new(p.PA0, Pull::Up);
16 let mut led1 = Output::new(p.PB15, Level::High, Speed::Low); 22 let mut led1 = Output::new(p.PB15, Level::High, Speed::Low);
diff --git a/examples/stm32wl/src/bin/button_exti.rs b/examples/stm32wl/src/bin/button_exti.rs
index 27d5330bd..8dd1a6a5e 100644
--- a/examples/stm32wl/src/bin/button_exti.rs
+++ b/examples/stm32wl/src/bin/button_exti.rs
@@ -1,15 +1,21 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use defmt::*; 6use defmt::*;
5use embassy_executor::Spawner; 7use embassy_executor::Spawner;
6use embassy_stm32::exti::ExtiInput; 8use embassy_stm32::exti::ExtiInput;
7use embassy_stm32::gpio::Pull; 9use embassy_stm32::gpio::Pull;
10use embassy_stm32::SharedData;
8use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
9 12
13#[link_section = ".shared_data"]
14static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
15
10#[embassy_executor::main] 16#[embassy_executor::main]
11async fn main(_spawner: Spawner) { 17async fn main(_spawner: Spawner) {
12 let p = embassy_stm32::init(Default::default()); 18 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
13 info!("Hello World!"); 19 info!("Hello World!");
14 20
15 let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up); 21 let mut button = ExtiInput::new(p.PA0, p.EXTI0, Pull::Up);
diff --git a/examples/stm32wl/src/bin/flash.rs b/examples/stm32wl/src/bin/flash.rs
index 0b7417c01..147f5d293 100644
--- a/examples/stm32wl/src/bin/flash.rs
+++ b/examples/stm32wl/src/bin/flash.rs
@@ -1,14 +1,20 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use defmt::{info, unwrap}; 6use defmt::{info, unwrap};
5use embassy_executor::Spawner; 7use embassy_executor::Spawner;
6use embassy_stm32::flash::Flash; 8use embassy_stm32::flash::Flash;
9use embassy_stm32::SharedData;
7use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
8 11
12#[link_section = ".shared_data"]
13static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
14
9#[embassy_executor::main] 15#[embassy_executor::main]
10async fn main(_spawner: Spawner) { 16async fn main(_spawner: Spawner) {
11 let p = embassy_stm32::init(Default::default()); 17 let p = embassy_stm32::init_primary(Default::default(), &SHARED_DATA);
12 info!("Hello Flash!"); 18 info!("Hello Flash!");
13 19
14 const ADDR: u32 = 0x36000; 20 const ADDR: u32 = 0x36000;
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs
index 8e9fe02b2..df2ed0054 100644
--- a/examples/stm32wl/src/bin/random.rs
+++ b/examples/stm32wl/src/bin/random.rs
@@ -1,17 +1,22 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use defmt::*; 6use defmt::*;
5use embassy_executor::Spawner; 7use embassy_executor::Spawner;
6use embassy_stm32::rng::{self, Rng}; 8use embassy_stm32::rng::{self, Rng};
7use embassy_stm32::time::Hertz; 9use embassy_stm32::time::Hertz;
8use embassy_stm32::{bind_interrupts, peripherals}; 10use embassy_stm32::{bind_interrupts, peripherals, SharedData};
9use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
10 12
11bind_interrupts!(struct Irqs{ 13bind_interrupts!(struct Irqs{
12 RNG => rng::InterruptHandler<peripherals::RNG>; 14 RNG => rng::InterruptHandler<peripherals::RNG>;
13}); 15});
14 16
17#[link_section = ".shared_data"]
18static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
19
15#[embassy_executor::main] 20#[embassy_executor::main]
16async fn main(_spawner: Spawner) { 21async fn main(_spawner: Spawner) {
17 let mut config = embassy_stm32::Config::default(); 22 let mut config = embassy_stm32::Config::default();
@@ -32,7 +37,7 @@ async fn main(_spawner: Spawner) {
32 divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) 37 divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2)
33 }); 38 });
34 } 39 }
35 let p = embassy_stm32::init(config); 40 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
36 41
37 info!("Hello World!"); 42 info!("Hello World!");
38 43
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs
index cf7d6d220..69a9ddc4c 100644
--- a/examples/stm32wl/src/bin/rtc.rs
+++ b/examples/stm32wl/src/bin/rtc.rs
@@ -1,15 +1,20 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use chrono::{NaiveDate, NaiveDateTime}; 6use chrono::{NaiveDate, NaiveDateTime};
5use defmt::*; 7use defmt::*;
6use embassy_executor::Spawner; 8use embassy_executor::Spawner;
7use embassy_stm32::rtc::{Rtc, RtcConfig}; 9use embassy_stm32::rtc::{Rtc, RtcConfig};
8use embassy_stm32::time::Hertz; 10use embassy_stm32::time::Hertz;
9use embassy_stm32::Config; 11use embassy_stm32::{Config, SharedData};
10use embassy_time::Timer; 12use embassy_time::Timer;
11use {defmt_rtt as _, panic_probe as _}; 13use {defmt_rtt as _, panic_probe as _};
12 14
15#[link_section = ".shared_data"]
16static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
17
13#[embassy_executor::main] 18#[embassy_executor::main]
14async fn main(_spawner: Spawner) { 19async fn main(_spawner: Spawner) {
15 let mut config = Config::default(); 20 let mut config = Config::default();
@@ -31,7 +36,7 @@ async fn main(_spawner: Spawner) {
31 divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2) 36 divr: Some(PllRDiv::DIV2), // sysclk 48Mhz clock (32 / 2 * 6 / 2)
32 }); 37 });
33 } 38 }
34 let p = embassy_stm32::init(config); 39 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
35 info!("Hello World!"); 40 info!("Hello World!");
36 41
37 let now = NaiveDate::from_ymd_opt(2020, 5, 15) 42 let now = NaiveDate::from_ymd_opt(2020, 5, 15)
diff --git a/examples/stm32wl/src/bin/uart_async.rs b/examples/stm32wl/src/bin/uart_async.rs
index 3637243a0..ece9b9201 100644
--- a/examples/stm32wl/src/bin/uart_async.rs
+++ b/examples/stm32wl/src/bin/uart_async.rs
@@ -1,10 +1,12 @@
1#![no_std] 1#![no_std]
2#![no_main] 2#![no_main]
3 3
4use core::mem::MaybeUninit;
5
4use defmt::*; 6use defmt::*;
5use embassy_executor::Spawner; 7use embassy_executor::Spawner;
6use embassy_stm32::usart::{Config, InterruptHandler, Uart}; 8use embassy_stm32::usart::{Config, InterruptHandler, Uart};
7use embassy_stm32::{bind_interrupts, peripherals}; 9use embassy_stm32::{bind_interrupts, peripherals, SharedData};
8use {defmt_rtt as _, panic_probe as _}; 10use {defmt_rtt as _, panic_probe as _};
9 11
10bind_interrupts!(struct Irqs{ 12bind_interrupts!(struct Irqs{
@@ -12,6 +14,9 @@ bind_interrupts!(struct Irqs{
12 LPUART1 => InterruptHandler<peripherals::LPUART1>; 14 LPUART1 => InterruptHandler<peripherals::LPUART1>;
13}); 15});
14 16
17#[link_section = ".shared_data"]
18static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
19
15/* 20/*
16Pass Incoming data from LPUART1 to USART1 21Pass Incoming data from LPUART1 to USART1
17Example is written for the LoRa-E5 mini v1.0, 22Example is written for the LoRa-E5 mini v1.0,
@@ -21,7 +26,7 @@ but can be surely changed for your needs.
21async fn main(_spawner: Spawner) { 26async fn main(_spawner: Spawner) {
22 let mut config = embassy_stm32::Config::default(); 27 let mut config = embassy_stm32::Config::default();
23 config.rcc.sys = embassy_stm32::rcc::Sysclk::HSE; 28 config.rcc.sys = embassy_stm32::rcc::Sysclk::HSE;
24 let p = embassy_stm32::init(config); 29 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
25 30
26 defmt::info!("Starting system"); 31 defmt::info!("Starting system");
27 32