aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wl5x-lp/.cargo/config.toml9
-rw-r--r--examples/stm32wl5x-lp/Cargo.toml39
-rw-r--r--examples/stm32wl5x-lp/build.rs5
-rw-r--r--examples/stm32wl5x-lp/memory.x15
-rw-r--r--examples/stm32wl5x-lp/src/bin/blinky.rs59
5 files changed, 127 insertions, 0 deletions
diff --git a/examples/stm32wl5x-lp/.cargo/config.toml b/examples/stm32wl5x-lp/.cargo/config.toml
new file mode 100644
index 000000000..969068656
--- /dev/null
+++ b/examples/stm32wl5x-lp/.cargo/config.toml
@@ -0,0 +1,9 @@
1[target.'cfg(all(target_arch = "arm", target_os = "none"))']
2# replace your chip as listed in `probe-rs chip list`
3runner = "probe-rs run --chip STM32WLE5JCIx --connect-under-reset"
4
5[build]
6target = "thumbv7em-none-eabi"
7
8[env]
9DEFMT_LOG = "debug"
diff --git a/examples/stm32wl5x-lp/Cargo.toml b/examples/stm32wl5x-lp/Cargo.toml
new file mode 100644
index 000000000..b1823fb8a
--- /dev/null
+++ b/examples/stm32wl5x-lp/Cargo.toml
@@ -0,0 +1,39 @@
1[package]
2edition = "2024"
3name = "embassy-stm32wl5x-lp"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6publish = false
7
8[dependencies]
9# Change stm32wl55jc-cm4 to your chip name, if necessary.
10embassy-stm32 = { version = "0.4.0", path = "../../embassy-stm32", features = ["defmt", "stm32wl55jc-cm4", "time-driver-any", "memory-x", "unstable-pac", "exti", "chrono", "low-power-pender"] }
11embassy-sync = { version = "0.7.2", path = "../../embassy-sync", features = ["defmt"] }
12embassy-executor = { version = "0.9.0", path = "../../embassy-executor", features = ["defmt"] }
13embassy-time = { version = "0.5.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
14embassy-embedded-hal = { version = "0.5.0", path = "../../embassy-embedded-hal" }
15
16defmt = "1.0.1"
17defmt-rtt = { version = "1.1.0", optional = true }
18defmt-serial = { git = "https://github.com/gauteh/defmt-serial", rev = "411ae7fa909b4fd2667885aff687e009b9108190", optional = true }
19
20cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
21cortex-m-rt = "0.7.0"
22embedded-hal = "1.0.0"
23embedded-storage = "0.3.1"
24panic-probe = { version = "1.0.0", features = ["print-defmt"] }
25chrono = { version = "^0.4", default-features = false }
26static_cell = { version = "2.1.1", default-features = false }
27
28[profile.release]
29debug = 2
30
31[package.metadata.embassy]
32build = [
33 { target = "thumbv7em-none-eabi", artifact-dir = "out/examples/stm32wl" }
34]
35
36[features]
37default = ["defmt-serial"]
38defmt-rtt = ["dep:defmt-rtt"]
39defmt-serial = ["dep:defmt-serial"]
diff --git a/examples/stm32wl5x-lp/build.rs b/examples/stm32wl5x-lp/build.rs
new file mode 100644
index 000000000..8cd32d7ed
--- /dev/null
+++ b/examples/stm32wl5x-lp/build.rs
@@ -0,0 +1,5 @@
1fn main() {
2 println!("cargo:rustc-link-arg-bins=--nmagic");
3 println!("cargo:rustc-link-arg-bins=-Tlink.x");
4 println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
5}
diff --git a/examples/stm32wl5x-lp/memory.x b/examples/stm32wl5x-lp/memory.x
new file mode 100644
index 000000000..4590867a8
--- /dev/null
+++ b/examples/stm32wl5x-lp/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 = 128
6 RAM (rwx) : ORIGIN = 0x20000080, LENGTH = 64K - 128
7}
8
9SECTIONS
10{
11 .shared_data :
12 {
13 *(.shared_data)
14 } > SHARED_RAM
15}
diff --git a/examples/stm32wl5x-lp/src/bin/blinky.rs b/examples/stm32wl5x-lp/src/bin/blinky.rs
new file mode 100644
index 000000000..068b65248
--- /dev/null
+++ b/examples/stm32wl5x-lp/src/bin/blinky.rs
@@ -0,0 +1,59 @@
1#![no_std]
2#![no_main]
3
4use core::mem::MaybeUninit;
5
6use defmt::*;
7#[cfg(feature = "defmt-rtt")]
8use defmt_rtt as _;
9use embassy_executor::Spawner;
10use embassy_stm32::SharedData;
11use embassy_stm32::gpio::{Level, Output, Speed};
12use embassy_time::Timer;
13use panic_probe as _;
14
15#[unsafe(link_section = ".shared_data")]
16static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
17
18#[embassy_executor::main(executor = "embassy_stm32::Executor", entry = "cortex_m_rt::entry")]
19async fn async_main(_spawner: Spawner) {
20 let mut config = embassy_stm32::Config::default();
21 // enable HSI clock
22 // config.rcc.hsi = true;
23 // enable LSI clock for RTC
24 config.rcc.ls = embassy_stm32::rcc::LsConfig::default_lsi();
25 config.rcc.msi = Some(embassy_stm32::rcc::MSIRange::RANGE4M);
26 config.rcc.sys = embassy_stm32::rcc::Sysclk::MSI;
27 #[cfg(feature = "defmt-serial")]
28 {
29 // disable debug during sleep to reduce power consumption since we are
30 // using defmt-serial on LPUART1.
31 config.enable_debug_during_sleep = false;
32 }
33 let p = embassy_stm32::init_primary(config, &SHARED_DATA);
34
35 #[cfg(feature = "defmt-serial")]
36 {
37 use embassy_stm32::mode::Blocking;
38 use embassy_stm32::usart::Uart;
39 use static_cell::StaticCell;
40 let config = embassy_stm32::usart::Config::default();
41 let uart = Uart::new_blocking(p.LPUART1, p.PA3, p.PA2, config).expect("failed to configure UART!");
42 static SERIAL: StaticCell<Uart<'static, Blocking>> = StaticCell::new();
43 defmt_serial::defmt_serial(SERIAL.init(uart));
44 }
45
46 info!("Hello World!");
47
48 let mut led = Output::new(p.PB15, Level::High, Speed::Low);
49
50 loop {
51 info!("low");
52 led.set_low();
53 Timer::after_millis(5000).await;
54
55 info!("high");
56 led.set_high();
57 Timer::after_millis(5000).await;
58 }
59}