diff options
| author | Dion Dokter <[email protected]> | 2024-07-08 13:32:23 +0200 |
|---|---|---|
| committer | Dion Dokter <[email protected]> | 2024-07-08 13:32:23 +0200 |
| commit | b1ea90a87e5ce6b16bbc155ad30d6d3473a998bb (patch) | |
| tree | 8b471551499cafb419b031f3e74ff8b693ec2367 /examples/stm32h755cm4 | |
| parent | 462daeeb4927416ed817423e91adb71c0861a83d (diff) | |
Add H755 examples
Diffstat (limited to 'examples/stm32h755cm4')
| -rw-r--r-- | examples/stm32h755cm4/.cargo/config.toml | 8 | ||||
| -rw-r--r-- | examples/stm32h755cm4/Cargo.toml | 75 | ||||
| -rw-r--r-- | examples/stm32h755cm4/build.rs | 35 | ||||
| -rw-r--r-- | examples/stm32h755cm4/memory.x | 14 | ||||
| -rw-r--r-- | examples/stm32h755cm4/src/bin/blinky.rs | 26 |
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] | ||
| 2 | runner = 'probe-rs run --chip STM32H755ZITx' | ||
| 3 | |||
| 4 | [build] | ||
| 5 | target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU) | ||
| 6 | |||
| 7 | [env] | ||
| 8 | DEFMT_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] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32h7-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | # Change stm32h755zi-cm4 to your chip name, if necessary. | ||
| 9 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h755zi-cm4", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } | ||
| 10 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 11 | embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" } | ||
| 12 | embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | ||
| 13 | embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 14 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } | ||
| 15 | embassy-usb = { version = "0.2.0", path = "../../embassy-usb", features = ["defmt"] } | ||
| 16 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 17 | |||
| 18 | defmt = "0.3" | ||
| 19 | defmt-rtt = "0.4" | ||
| 20 | |||
| 21 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 22 | cortex-m-rt = "0.7.0" | ||
| 23 | embedded-hal = "0.2.6" | ||
| 24 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | ||
| 25 | embedded-hal-async = { version = "1.0" } | ||
| 26 | embedded-nal-async = { version = "0.7.1" } | ||
| 27 | embedded-io-async = { version = "0.6.1" } | ||
| 28 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 29 | heapless = { version = "0.8", default-features = false } | ||
| 30 | rand_core = "0.6.3" | ||
| 31 | critical-section = "1.1" | ||
| 32 | micromath = "2.0.0" | ||
| 33 | stm32-fmc = "0.3.0" | ||
| 34 | embedded-storage = "0.3.1" | ||
| 35 | static_cell = "2" | ||
| 36 | chrono = { version = "^0.4", default-features = false } | ||
| 37 | grounded = "0.2.0" | ||
| 38 | |||
| 39 | # cargo build/run | ||
| 40 | [profile.dev] | ||
| 41 | codegen-units = 1 | ||
| 42 | debug = 2 | ||
| 43 | debug-assertions = true # <- | ||
| 44 | incremental = false | ||
| 45 | opt-level = 3 # <- | ||
| 46 | overflow-checks = true # <- | ||
| 47 | |||
| 48 | # cargo test | ||
| 49 | [profile.test] | ||
| 50 | codegen-units = 1 | ||
| 51 | debug = 2 | ||
| 52 | debug-assertions = true # <- | ||
| 53 | incremental = false | ||
| 54 | opt-level = 3 # <- | ||
| 55 | overflow-checks = true # <- | ||
| 56 | |||
| 57 | # cargo build/run --release | ||
| 58 | [profile.release] | ||
| 59 | codegen-units = 1 | ||
| 60 | debug = 2 | ||
| 61 | debug-assertions = false # <- | ||
| 62 | incremental = false | ||
| 63 | lto = 'fat' | ||
| 64 | opt-level = 3 # <- | ||
| 65 | overflow-checks = false # <- | ||
| 66 | |||
| 67 | # cargo test --release | ||
| 68 | [profile.bench] | ||
| 69 | codegen-units = 1 | ||
| 70 | debug = 2 | ||
| 71 | debug-assertions = false # <- | ||
| 72 | incremental = false | ||
| 73 | lto = 'fat' | ||
| 74 | opt-level = 3 # <- | ||
| 75 | overflow-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 | |||
| 11 | use std::env; | ||
| 12 | use std::fs::File; | ||
| 13 | use std::io::Write; | ||
| 14 | use std::path::PathBuf; | ||
| 15 | |||
| 16 | fn 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 @@ | |||
| 1 | MEMORY | ||
| 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 | |||
| 8 | SECTIONS | ||
| 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 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_stm32::gpio::{Level, Output, Speed}; | ||
| 7 | use embassy_time::Timer; | ||
| 8 | use {defmt_rtt as _, panic_probe as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async 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 | } | ||
