aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorDavid Haig <[email protected]>2024-06-28 18:11:34 +0100
committerDavid Haig <[email protected]>2024-06-28 18:11:34 +0100
commit79f00e54cc4d13a28c7ccc9a13345bf2f3730f42 (patch)
treef84018216825751ae22401bda35ccc2490efd602 /examples
parent1123e3fd41e7b23dd0507816f1ff67fc0de6b5d1 (diff)
Moved ltdc example to its own crate
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32h7/Cargo.toml2
-rw-r--r--examples/stm32h735/.cargo/config.toml8
-rw-r--r--examples/stm32h735/Cargo.toml61
-rw-r--r--examples/stm32h735/build.rs35
-rw-r--r--examples/stm32h735/memory.x5
-rw-r--r--examples/stm32h735/src/bin/ferris.bmp (renamed from examples/stm32h7/src/bin/ferris.bmp)bin6794 -> 6794 bytes
-rw-r--r--examples/stm32h735/src/bin/ltdc.rs (renamed from examples/stm32h7/src/bin/ltdc.rs)15
7 files changed, 111 insertions, 15 deletions
diff --git a/examples/stm32h7/Cargo.toml b/examples/stm32h7/Cargo.toml
index 6f3007492..0584f3916 100644
--- a/examples/stm32h7/Cargo.toml
+++ b/examples/stm32h7/Cargo.toml
@@ -34,8 +34,6 @@ stm32-fmc = "0.3.0"
34embedded-storage = "0.3.1" 34embedded-storage = "0.3.1"
35static_cell = "2" 35static_cell = "2"
36chrono = { version = "^0.4", default-features = false } 36chrono = { version = "^0.4", default-features = false }
37embedded-graphics = { version = "0.8.1" }
38tinybmp = { version = "0.5" }
39 37
40# cargo build/run 38# cargo build/run
41[profile.dev] 39[profile.dev]
diff --git a/examples/stm32h735/.cargo/config.toml b/examples/stm32h735/.cargo/config.toml
new file mode 100644
index 000000000..95536c6a8
--- /dev/null
+++ b/examples/stm32h735/.cargo/config.toml
@@ -0,0 +1,8 @@
1[target.thumbv7em-none-eabihf]
2runner = 'probe-rs run --chip STM32H735IGKx'
3
4[build]
5target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
6
7[env]
8DEFMT_LOG = "trace"
diff --git a/examples/stm32h735/Cargo.toml b/examples/stm32h735/Cargo.toml
new file mode 100644
index 000000000..fc21cc894
--- /dev/null
+++ b/examples/stm32h735/Cargo.toml
@@ -0,0 +1,61 @@
1[package]
2edition = "2021"
3name = "embassy-stm32h735-examples"
4version = "0.1.0"
5license = "MIT OR Apache-2.0"
6
7[dependencies]
8embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h735ig", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] }
9embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] }
10embassy-embedded-hal = { version = "0.1.0", path = "../../embassy-embedded-hal" }
11embassy-executor = { version = "0.5.0", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] }
12embassy-time = { version = "0.3.1", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] }
13embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
14
15defmt = "0.3"
16defmt-rtt = "0.4"
17
18cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] }
19cortex-m-rt = "0.7.0"
20panic-probe = { version = "0.3", features = ["print-defmt"] }
21heapless = { version = "0.8", default-features = false }
22embedded-graphics = { version = "0.8.1" }
23tinybmp = { version = "0.5" }
24
25# cargo build/run
26[profile.dev]
27codegen-units = 1
28debug = 2
29debug-assertions = true # <-
30incremental = false
31opt-level = 3 # <-
32overflow-checks = true # <-
33
34# cargo test
35[profile.test]
36codegen-units = 1
37debug = 2
38debug-assertions = true # <-
39incremental = false
40opt-level = 3 # <-
41overflow-checks = true # <-
42
43# cargo build/run --release
44[profile.release]
45codegen-units = 1
46debug = 2
47debug-assertions = false # <-
48incremental = false
49lto = 'fat'
50opt-level = 3 # <-
51overflow-checks = false # <-
52
53# cargo test --release
54[profile.bench]
55codegen-units = 1
56debug = 2
57debug-assertions = false # <-
58incremental = false
59lto = 'fat'
60opt-level = 3 # <-
61overflow-checks = false # <-
diff --git a/examples/stm32h735/build.rs b/examples/stm32h735/build.rs
new file mode 100644
index 000000000..30691aa97
--- /dev/null
+++ b/examples/stm32h735/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/stm32h735/memory.x b/examples/stm32h735/memory.x
new file mode 100644
index 000000000..3a70d24d2
--- /dev/null
+++ b/examples/stm32h735/memory.x
@@ -0,0 +1,5 @@
1MEMORY
2{
3 FLASH : ORIGIN = 0x08000000, LENGTH = 1024K
4 RAM : ORIGIN = 0x24000000, LENGTH = 320K
5} \ No newline at end of file
diff --git a/examples/stm32h7/src/bin/ferris.bmp b/examples/stm32h735/src/bin/ferris.bmp
index 7a222ab84..7a222ab84 100644
--- a/examples/stm32h7/src/bin/ferris.bmp
+++ b/examples/stm32h735/src/bin/ferris.bmp
Binary files differ
diff --git a/examples/stm32h7/src/bin/ltdc.rs b/examples/stm32h735/src/bin/ltdc.rs
index 3b56bbb6c..5c75a7db1 100644
--- a/examples/stm32h7/src/bin/ltdc.rs
+++ b/examples/stm32h735/src/bin/ltdc.rs
@@ -36,19 +36,9 @@ const DISPLAY_HEIGHT: usize = 272;
36const MY_TASK_POOL_SIZE: usize = 2; 36const MY_TASK_POOL_SIZE: usize = 2;
37 37
38// the following two display buffers consume 261120 bytes that just about fits into axis ram found on the mcu 38// the following two display buffers consume 261120 bytes that just about fits into axis ram found on the mcu
39// see memory.x linker script
40pub static mut FB1: [TargetPixelType; DISPLAY_WIDTH * DISPLAY_HEIGHT] = [0; DISPLAY_WIDTH * DISPLAY_HEIGHT]; 39pub static mut FB1: [TargetPixelType; DISPLAY_WIDTH * DISPLAY_HEIGHT] = [0; DISPLAY_WIDTH * DISPLAY_HEIGHT];
41pub static mut FB2: [TargetPixelType; DISPLAY_WIDTH * DISPLAY_HEIGHT] = [0; DISPLAY_WIDTH * DISPLAY_HEIGHT]; 40pub static mut FB2: [TargetPixelType; DISPLAY_WIDTH * DISPLAY_HEIGHT] = [0; DISPLAY_WIDTH * DISPLAY_HEIGHT];
42 41
43// a basic memory.x linker script for the stm32h735g-dk is as follows:
44/*
45MEMORY
46{
47 FLASH : ORIGIN = 0x08000000, LENGTH = 1024K
48 RAM : ORIGIN = 0x24000000, LENGTH = 320K
49}
50*/
51
52bind_interrupts!(struct Irqs { 42bind_interrupts!(struct Irqs {
53 LTDC => ltdc::InterruptHandler<peripherals::LTDC>; 43 LTDC => ltdc::InterruptHandler<peripherals::LTDC>;
54}); 44});
@@ -110,7 +100,7 @@ async fn main(spawner: Spawner) {
110 100
111 // enable the bottom layer with a 256 color lookup table 101 // enable the bottom layer with a 256 color lookup table
112 ltdc.init_layer(&layer_config, Some(&clut)); 102 ltdc.init_layer(&layer_config, Some(&clut));
113 103
114 // Safety: the DoubleBuffer controls access to the statically allocated frame buffers 104 // Safety: the DoubleBuffer controls access to the statically allocated frame buffers
115 // and it is the only thing that mutates their content 105 // and it is the only thing that mutates their content
116 let mut double_buffer = DoubleBuffer::new( 106 let mut double_buffer = DoubleBuffer::new(
@@ -369,8 +359,7 @@ mod rcc_setup {
369 config.rcc.apb2_pre = APBPrescaler::DIV2; 359 config.rcc.apb2_pre = APBPrescaler::DIV2;
370 config.rcc.apb3_pre = APBPrescaler::DIV2; 360 config.rcc.apb3_pre = APBPrescaler::DIV2;
371 config.rcc.apb4_pre = APBPrescaler::DIV2; 361 config.rcc.apb4_pre = APBPrescaler::DIV2;
372 let p = embassy_stm32::init(config); 362 embassy_stm32::init(config)
373 p
374 } 363 }
375} 364}
376 365