diff options
| author | xoviat <[email protected]> | 2023-05-29 15:07:21 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-05-29 15:07:21 -0500 |
| commit | 68441a74c2da3d3186ca351f0b3d263940564a16 (patch) | |
| tree | e5d40a357c49accd1b774a2b401d79b03ecf6075 /examples | |
| parent | aba0f8fd6cd51cad65480689bc9254df4f071175 (diff) | |
| parent | 3b38079490b0c283899cab42308c4feab4c47fdc (diff) | |
Merge branch 'main' of https://github.com/embassy-rs/embassy into uart
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/stm32wb/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/stm32wb/build.rs | 36 | ||||
| -rw-r--r-- | examples/stm32wb/memory.x | 35 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox.rs | 14 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | 23 |
5 files changed, 25 insertions, 85 deletions
diff --git a/examples/stm32wb/Cargo.toml b/examples/stm32wb/Cargo.toml index 3c7e3e874..8cfac772a 100644 --- a/examples/stm32wb/Cargo.toml +++ b/examples/stm32wb/Cargo.toml | |||
| @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0" | |||
| 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } | 8 | embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt"] } |
| 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } | 9 | embassy-executor = { version = "0.2.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "integrated-timers"] } |
| 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } | 10 | embassy-time = { version = "0.1.0", path = "../../embassy-time", features = ["defmt", "defmt-timestamp-uptime", "tick-hz-32_768"] } |
| 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "exti"] } | 11 | embassy-stm32 = { version = "0.1.0", path = "../../embassy-stm32", features = ["nightly", "defmt", "stm32wb55rg", "time-driver-any", "memory-x", "exti"] } |
| 12 | 12 | ||
| 13 | defmt = "0.3" | 13 | defmt = "0.3" |
| 14 | defmt-rtt = "0.4" | 14 | defmt-rtt = "0.4" |
diff --git a/examples/stm32wb/build.rs b/examples/stm32wb/build.rs index 30691aa97..29b3a9b2a 100644 --- a/examples/stm32wb/build.rs +++ b/examples/stm32wb/build.rs | |||
| @@ -1,35 +1,11 @@ | |||
| 1 | //! This build script copies the `memory.x` file from the crate root into | 1 | use std::error::Error; |
| 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 | 2 | ||
| 3 | fn main() -> Result<(), Box<dyn Error>> { | ||
| 32 | println!("cargo:rustc-link-arg-bins=--nmagic"); | 4 | println!("cargo:rustc-link-arg-bins=--nmagic"); |
| 33 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); | 5 | println!("cargo:rustc-link-arg-bins=-Tlink.x"); |
| 6 | println!("cargo:rerun-if-changed=link.x"); | ||
| 7 | println!("cargo:rustc-link-arg-bins=-Ttl_mbox.x"); | ||
| 34 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); | 8 | println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); |
| 9 | |||
| 10 | Ok(()) | ||
| 35 | } | 11 | } |
diff --git a/examples/stm32wb/memory.x b/examples/stm32wb/memory.x deleted file mode 100644 index e1f0530bd..000000000 --- a/examples/stm32wb/memory.x +++ /dev/null | |||
| @@ -1,35 +0,0 @@ | |||
| 1 | /* | ||
| 2 | The size of this file must be exactly the same as in other memory_xx.x files. | ||
| 3 | Memory size for STM32WB55xC with 256K FLASH | ||
| 4 | */ | ||
| 5 | |||
| 6 | MEMORY | ||
| 7 | { | ||
| 8 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 256K | ||
| 9 | RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 192K | ||
| 10 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K | ||
| 11 | } | ||
| 12 | |||
| 13 | /* | ||
| 14 | Memory size for STM32WB55xG with 512K FLASH | ||
| 15 | |||
| 16 | MEMORY | ||
| 17 | { | ||
| 18 | FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 512K | ||
| 19 | RAM (xrw) : ORIGIN = 0x20000008, LENGTH = 0x2FFF8 | ||
| 20 | RAM_SHARED (xrw) : ORIGIN = 0x20030000, LENGTH = 10K | ||
| 21 | } | ||
| 22 | */ | ||
| 23 | |||
| 24 | /* Place stack at the end of SRAM1 */ | ||
| 25 | _stack_start = ORIGIN(RAM) + LENGTH(RAM); | ||
| 26 | |||
| 27 | /* | ||
| 28 | * Scatter the mailbox interface memory sections in shared memory | ||
| 29 | */ | ||
| 30 | SECTIONS { | ||
| 31 | TL_REF_TABLE (NOLOAD) : { *(TL_REF_TABLE) } >RAM_SHARED | ||
| 32 | |||
| 33 | MB_MEM1 (NOLOAD) : { *(MB_MEM1) } >RAM_SHARED | ||
| 34 | MB_MEM2 (NOLOAD) : { _sMB_MEM2 = . ; *(MB_MEM2) ; _eMB_MEM2 = . ; } >RAM_SHARED | ||
| 35 | } | ||
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs index 326e4be85..8f4e70af0 100644 --- a/examples/stm32wb/src/bin/tl_mbox.rs +++ b/examples/stm32wb/src/bin/tl_mbox.rs | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::ipcc::{Config, Ipcc}; | 7 | use embassy_stm32::tl_mbox::{Config, TlMbox}; |
| 8 | use embassy_stm32::tl_mbox::TlMbox; | ||
| 9 | use embassy_stm32::{bind_interrupts, tl_mbox}; | 8 | use embassy_stm32::{bind_interrupts, tl_mbox}; |
| 10 | use embassy_time::{Duration, Timer}; | 9 | use embassy_time::{Duration, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -45,14 +44,12 @@ async fn main(_spawner: Spawner) { | |||
| 45 | info!("Hello World!"); | 44 | info!("Hello World!"); |
| 46 | 45 | ||
| 47 | let config = Config::default(); | 46 | let config = Config::default(); |
| 48 | let mut ipcc = Ipcc::new(p.IPCC, config); | 47 | let mbox = TlMbox::new(p.IPCC, Irqs, config); |
| 49 | |||
| 50 | let mbox = TlMbox::init(&mut ipcc, Irqs); | ||
| 51 | 48 | ||
| 52 | loop { | 49 | loop { |
| 53 | let wireless_fw_info = mbox.wireless_fw_info(); | 50 | let wireless_fw_info = mbox.wireless_fw_info(); |
| 54 | match wireless_fw_info { | 51 | match wireless_fw_info { |
| 55 | None => error!("not yet initialized"), | 52 | None => info!("not yet initialized"), |
| 56 | Some(fw_info) => { | 53 | Some(fw_info) => { |
| 57 | let version_major = fw_info.version_major(); | 54 | let version_major = fw_info.version_major(); |
| 58 | let version_minor = fw_info.version_minor(); | 55 | let version_minor = fw_info.version_minor(); |
| @@ -70,6 +67,9 @@ async fn main(_spawner: Spawner) { | |||
| 70 | } | 67 | } |
| 71 | } | 68 | } |
| 72 | 69 | ||
| 73 | Timer::after(Duration::from_millis(500)).await; | 70 | Timer::after(Duration::from_millis(50)).await; |
| 74 | } | 71 | } |
| 72 | |||
| 73 | info!("Test OK"); | ||
| 74 | cortex_m::asm::bkpt(); | ||
| 75 | } | 75 | } |
diff --git a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs index 7a69f26b7..1724d946f 100644 --- a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs +++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | |||
| @@ -4,8 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::ipcc::{Config, Ipcc}; | 7 | use embassy_stm32::tl_mbox::{Config, TlMbox}; |
| 8 | use embassy_stm32::tl_mbox::TlMbox; | ||
| 9 | use embassy_stm32::{bind_interrupts, tl_mbox}; | 8 | use embassy_stm32::{bind_interrupts, tl_mbox}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 9 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 10 | ||
| @@ -44,12 +43,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | info!("Hello World!"); | 43 | info!("Hello World!"); |
| 45 | 44 | ||
| 46 | let config = Config::default(); | 45 | let config = Config::default(); |
| 47 | let mut ipcc = Ipcc::new(p.IPCC, config); | 46 | let mbox = TlMbox::new(p.IPCC, Irqs, config); |
| 48 | |||
| 49 | let mbox = TlMbox::init(&mut ipcc, Irqs); | ||
| 50 | |||
| 51 | // initialize ble stack, does not return a response | ||
| 52 | mbox.shci_ble_init(&mut ipcc, Default::default()); | ||
| 53 | 47 | ||
| 54 | info!("waiting for coprocessor to boot"); | 48 | info!("waiting for coprocessor to boot"); |
| 55 | let event_box = mbox.read().await; | 49 | let event_box = mbox.read().await; |
| @@ -74,10 +68,11 @@ async fn main(_spawner: Spawner) { | |||
| 74 | ); | 68 | ); |
| 75 | } | 69 | } |
| 76 | 70 | ||
| 77 | mbox.shci_ble_init(&mut ipcc, Default::default()); | 71 | // initialize ble stack, does not return a response |
| 72 | mbox.shci_ble_init(Default::default()); | ||
| 78 | 73 | ||
| 79 | info!("resetting BLE"); | 74 | info!("resetting BLE"); |
| 80 | mbox.send_ble_cmd(&mut ipcc, &[0x01, 0x03, 0x0c, 0x00, 0x00]); | 75 | mbox.send_ble_cmd(&[0x01, 0x03, 0x0c, 0x00, 0x00]); |
| 81 | 76 | ||
| 82 | let event_box = mbox.read().await; | 77 | let event_box = mbox.read().await; |
| 83 | 78 | ||
| @@ -92,8 +87,12 @@ async fn main(_spawner: Spawner) { | |||
| 92 | 87 | ||
| 93 | info!( | 88 | info!( |
| 94 | "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}", | 89 | "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}", |
| 95 | kind, code, payload_len, payload | 90 | kind, |
| 91 | code, | ||
| 92 | payload_len, | ||
| 93 | payload[3..] | ||
| 96 | ); | 94 | ); |
| 97 | 95 | ||
| 98 | loop {} | 96 | info!("Test OK"); |
| 97 | cortex_m::asm::bkpt(); | ||
| 99 | } | 98 | } |
