diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32h7b0/.cargo/config.toml | 8 | ||||
| -rw-r--r-- | examples/stm32h7b0/Cargo.toml | 74 | ||||
| -rw-r--r-- | examples/stm32h7b0/build.rs | 35 | ||||
| -rw-r--r-- | examples/stm32h7b0/memory.x | 5 | ||||
| -rw-r--r-- | examples/stm32h7b0/src/bin/ospi_memory_mapped.rs (renamed from examples/stm32h7/src/bin/ospi_memory_mapped.rs) | 5 |
5 files changed, 124 insertions, 3 deletions
diff --git a/examples/stm32h7b0/.cargo/config.toml b/examples/stm32h7b0/.cargo/config.toml new file mode 100644 index 000000000..870849a27 --- /dev/null +++ b/examples/stm32h7b0/.cargo/config.toml | |||
| @@ -0,0 +1,8 @@ | |||
| 1 | [target.thumbv7em-none-eabihf] | ||
| 2 | runner = 'probe-rs run --chip STM32H7B0VBTx' | ||
| 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/stm32h7b0/Cargo.toml b/examples/stm32h7b0/Cargo.toml new file mode 100644 index 000000000..02c620443 --- /dev/null +++ b/examples/stm32h7b0/Cargo.toml | |||
| @@ -0,0 +1,74 @@ | |||
| 1 | [package] | ||
| 2 | edition = "2021" | ||
| 3 | name = "embassy-stm32h7b0-examples" | ||
| 4 | version = "0.1.0" | ||
| 5 | license = "MIT OR Apache-2.0" | ||
| 6 | |||
| 7 | [dependencies] | ||
| 8 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["defmt", "stm32h7b0vb", "time-driver-tim2", "exti", "memory-x", "unstable-pac", "chrono"] } | ||
| 9 | embassy-sync = { version = "0.6.0", path = "../../embassy-sync", features = ["defmt"] } | ||
| 10 | embassy-embedded-hal = { version = "0.2.0", path = "../../embassy-embedded-hal" } | ||
| 11 | embassy-executor = { version = "0.6.1", path = "../../embassy-executor", features = ["task-arena-size-32768", "arch-cortex-m", "executor-thread", "executor-interrupt", "defmt", "integrated-timers"] } | ||
| 12 | embassy-time = { version = "0.3.2", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | ||
| 13 | embassy-net = { version = "0.4.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "proto-ipv6", "dns"] } | ||
| 14 | embassy-usb = { version = "0.3.0", path = "../../embassy-usb", features = ["defmt"] } | ||
| 15 | embassy-futures = { version = "0.1.0", path = "../../embassy-futures" } | ||
| 16 | |||
| 17 | defmt = "0.3" | ||
| 18 | defmt-rtt = "0.4" | ||
| 19 | |||
| 20 | cortex-m = { version = "0.7.6", features = ["inline-asm", "critical-section-single-core"] } | ||
| 21 | cortex-m-rt = "0.7.0" | ||
| 22 | embedded-hal = "0.2.6" | ||
| 23 | embedded-hal-1 = { package = "embedded-hal", version = "1.0" } | ||
| 24 | embedded-hal-async = { version = "1.0" } | ||
| 25 | embedded-nal-async = "0.8.0" | ||
| 26 | embedded-io-async = { version = "0.6.1" } | ||
| 27 | panic-probe = { version = "0.3", features = ["print-defmt"] } | ||
| 28 | heapless = { version = "0.8", default-features = false } | ||
| 29 | rand_core = "0.6.3" | ||
| 30 | critical-section = "1.1" | ||
| 31 | micromath = "2.0.0" | ||
| 32 | stm32-fmc = "0.3.0" | ||
| 33 | embedded-storage = "0.3.1" | ||
| 34 | static_cell = "2" | ||
| 35 | chrono = { version = "^0.4", default-features = false } | ||
| 36 | grounded = "0.2.0" | ||
| 37 | |||
| 38 | # cargo build/run | ||
| 39 | [profile.dev] | ||
| 40 | codegen-units = 1 | ||
| 41 | debug = 2 | ||
| 42 | debug-assertions = true # <- | ||
| 43 | incremental = false | ||
| 44 | opt-level = 3 # <- | ||
| 45 | overflow-checks = true # <- | ||
| 46 | |||
| 47 | # cargo test | ||
| 48 | [profile.test] | ||
| 49 | codegen-units = 1 | ||
| 50 | debug = 2 | ||
| 51 | debug-assertions = true # <- | ||
| 52 | incremental = false | ||
| 53 | opt-level = 3 # <- | ||
| 54 | overflow-checks = true # <- | ||
| 55 | |||
| 56 | # cargo build/run --release | ||
| 57 | [profile.release] | ||
| 58 | codegen-units = 1 | ||
| 59 | debug = 2 | ||
| 60 | debug-assertions = false # <- | ||
| 61 | incremental = false | ||
| 62 | lto = 'fat' | ||
| 63 | opt-level = 3 # <- | ||
| 64 | overflow-checks = false # <- | ||
| 65 | |||
| 66 | # cargo test --release | ||
| 67 | [profile.bench] | ||
| 68 | codegen-units = 1 | ||
| 69 | debug = 2 | ||
| 70 | debug-assertions = false # <- | ||
| 71 | incremental = false | ||
| 72 | lto = 'fat' | ||
| 73 | opt-level = 3 # <- | ||
| 74 | overflow-checks = false # <- | ||
diff --git a/examples/stm32h7b0/build.rs b/examples/stm32h7b0/build.rs new file mode 100644 index 000000000..30691aa97 --- /dev/null +++ b/examples/stm32h7b0/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/stm32h7b0/memory.x b/examples/stm32h7b0/memory.x new file mode 100644 index 000000000..6eb1bb7c1 --- /dev/null +++ b/examples/stm32h7b0/memory.x | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | MEMORY | ||
| 2 | { | ||
| 3 | FLASH : ORIGIN = 0x08000000, LENGTH = 128K /* BANK_1 */ | ||
| 4 | RAM : ORIGIN = 0x24000000, LENGTH = 512K /* SRAM */ | ||
| 5 | } \ No newline at end of file | ||
diff --git a/examples/stm32h7/src/bin/ospi_memory_mapped.rs b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs index 40f39f751..e32a22e41 100644 --- a/examples/stm32h7/src/bin/ospi_memory_mapped.rs +++ b/examples/stm32h7b0/src/bin/ospi_memory_mapped.rs | |||
| @@ -61,7 +61,7 @@ async fn main(_spawner: Spawner) { | |||
| 61 | free_running_clock: false, | 61 | free_running_clock: false, |
| 62 | clock_mode: false, | 62 | clock_mode: false, |
| 63 | wrap_size: WrapSize::None, | 63 | wrap_size: WrapSize::None, |
| 64 | clock_prescaler: 2, | 64 | clock_prescaler: 4, |
| 65 | sample_shifting: true, | 65 | sample_shifting: true, |
| 66 | delay_hold_quarter_cycle: false, | 66 | delay_hold_quarter_cycle: false, |
| 67 | chip_select_boundary: 0, | 67 | chip_select_boundary: 0, |
| @@ -94,8 +94,8 @@ async fn main(_spawner: Spawner) { | |||
| 94 | flash.read_memory(0, &mut rd_buf, true); | 94 | flash.read_memory(0, &mut rd_buf, true); |
| 95 | info!("WRITE BUF: {=[u8]:#X}", wr_buf); | 95 | info!("WRITE BUF: {=[u8]:#X}", wr_buf); |
| 96 | info!("READ BUF: {=[u8]:#X}", rd_buf); | 96 | info!("READ BUF: {=[u8]:#X}", rd_buf); |
| 97 | info!("Enabling memory mapped mode"); | ||
| 98 | flash.enable_mm().await; | 97 | flash.enable_mm().await; |
| 98 | info!("Enabled memory mapped mode"); | ||
| 99 | 99 | ||
| 100 | let first_u32 = unsafe { *(0x90000000 as *const u32) }; | 100 | let first_u32 = unsafe { *(0x90000000 as *const u32) }; |
| 101 | assert_eq!(first_u32, 0x03020100); | 101 | assert_eq!(first_u32, 0x03020100); |
| @@ -121,7 +121,6 @@ const CMD_QUAD_READ: u8 = 0x6B; | |||
| 121 | const CMD_QUAD_WRITE_PG: u8 = 0x32; | 121 | const CMD_QUAD_WRITE_PG: u8 = 0x32; |
| 122 | 122 | ||
| 123 | const CMD_READ_ID: u8 = 0x9F; | 123 | const CMD_READ_ID: u8 = 0x9F; |
| 124 | const CMD_READ_UUID: u8 = 0x4B; | ||
| 125 | 124 | ||
| 126 | const CMD_ENABLE_RESET: u8 = 0x66; | 125 | const CMD_ENABLE_RESET: u8 = 0x66; |
| 127 | const CMD_RESET: u8 = 0x99; | 126 | const CMD_RESET: u8 = 0x99; |
