aboutsummaryrefslogtreecommitdiff
path: root/examples/stm32h755cm4
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stm32h755cm4')
-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.x14
-rw-r--r--examples/stm32h755cm4/src/bin/blinky.rs26
5 files changed, 158 insertions, 0 deletions
diff --git a/examples/stm32h755cm4/.cargo/config.toml b/examples/stm32h755cm4/.cargo/config.toml
new file mode 100644
index 000000000..f9ae6f2e7
--- /dev/null
+++ b/examples/stm32h755cm4/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip STM32H755ZITx'
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..c366bc3d2
--- /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.1.0", path = "../../embassy-embedded-hal" }
12embassy-executor = { version = "0.5.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.2.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..f946b6210
--- /dev/null
+++ b/examples/stm32h755cm4/memory.x
@@ -0,0 +1,14 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08100000, LENGTH = 1024K /* BANK_2 */
4 RAM : ORIGIN = 0x30000000, LENGTH = 128K /* SRAM1 */
5 RAM_D3 : ORIGIN = 0x38000000, LENGTH = 64K /* SRAM4 */
6}
7
8SECTIONS
9{
10 .ram_d3 :
11 {
12 *(.ram_d3)
13 } > RAM_D3
14} \ 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..765be5ba1
--- /dev/null
+++ b/examples/stm32h755cm4/src/bin/blinky.rs
@@ -0,0 +1,26 @@
1#![no_std]
2#![no_main]
3
4use defmt::*;
5use embassy_executor::Spawner;
6use embassy_stm32::gpio::{Level, Output, Speed};
7use embassy_time::Timer;
8use {defmt_rtt as _, panic_probe as _};
9
10#[embassy_executor::main]
11async fn main(_spawner: Spawner) {
12 let p = embassy_stm32::init(Default::default());
13 info!("Hello World!");
14
15 let mut led = Output::new(p.PE1, Level::High, Speed::Low);
16
17 loop {
18 info!("high");
19 led.set_high();
20 Timer::after_millis(500).await;
21
22 info!("low");
23 led.set_low();
24 Timer::after_millis(500).await;
25 }
26}