From d97724cca3164250118c732759f403f4f94d4629 Mon Sep 17 00:00:00 2001 From: goueslati Date: Mon, 15 May 2023 10:25:02 +0100 Subject: tl_mbox read and write --- examples/stm32wb/src/bin/tl_mbox.rs | 6 +- examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | 96 +++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 examples/stm32wb/src/bin/tl_mbox_tx_rx.rs (limited to 'examples') diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs index 6876526ae..ccd01cbc7 100644 --- a/examples/stm32wb/src/bin/tl_mbox.rs +++ b/examples/stm32wb/src/bin/tl_mbox.rs @@ -4,6 +4,7 @@ use defmt::*; use embassy_executor::Spawner; +use embassy_stm32::interrupt; use embassy_stm32::ipcc::{Config, Ipcc}; use embassy_stm32::tl_mbox::TlMbox; use embassy_time::{Duration, Timer}; @@ -40,7 +41,10 @@ async fn main(_spawner: Spawner) { let config = Config::default(); let mut ipcc = Ipcc::new(p.IPCC, config); - let mbox = TlMbox::init(&mut ipcc); + let rx_irq = interrupt::take!(IPCC_C1_RX); + let tx_irq = interrupt::take!(IPCC_C1_TX); + + let mbox = TlMbox::init(&mut ipcc, rx_irq, tx_irq); loop { let wireless_fw_info = mbox.wireless_fw_info(); diff --git a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs new file mode 100644 index 000000000..315172df8 --- /dev/null +++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs @@ -0,0 +1,96 @@ +#![no_std] +#![no_main] +#![feature(type_alias_impl_trait)] + +use defmt::*; +use embassy_executor::Spawner; +use embassy_stm32::interrupt; +use embassy_stm32::ipcc::{Config, Ipcc}; +use embassy_stm32::tl_mbox::TlMbox; +use {defmt_rtt as _, panic_probe as _}; + +#[embassy_executor::main] +async fn main(_spawner: Spawner) { + /* + How to make this work: + + - Obtain a NUCLEO-STM32WB55 from your preferred supplier. + - Download and Install STM32CubeProgrammer. + - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from + gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x + - Open STM32CubeProgrammer + - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware. + - Once complete, click connect to connect to the device. + - On the left hand pane, click the RSS signal icon to open "Firmware Upgrade Services". + - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file + - Select that file, the memory address, "verify download", and then "Firmware Upgrade". + - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the + stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. + - Select that file, the memory address, "verify download", and then "Firmware Upgrade". + - Disconnect from the device. + - In the examples folder for stm32wb, modify the memory.x file to match your target device. + - Run this example. + + Note: extended stack versions are not supported at this time. Do not attempt to install a stack with "extended" in the name. + */ + + let p = embassy_stm32::init(Default::default()); + info!("Hello World!"); + + let config = Config::default(); + let mut ipcc = Ipcc::new(p.IPCC, config); + + let rx_irq = interrupt::take!(IPCC_C1_RX); + let tx_irq = interrupt::take!(IPCC_C1_TX); + + let mbox = TlMbox::init(&mut ipcc, rx_irq, tx_irq); + + // initialize ble stack, does not return a response + // mbox.shci_ble_init(&mut ipcc, Default::default()); + + info!("waiting for coprocessor to boot"); + let event_box = mbox.read().await; + + let mut payload = [0u8; 6]; + event_box.copy_into_slice(&mut payload).unwrap(); + + let event_packet = event_box.evt(); + let kind = event_packet.evt_serial.kind; + + // means recieved SYS event, which indicates in this case that the coprocessor is ready + if kind == 0x12 { + let code = event_packet.evt_serial.evt.evt_code; + let payload_len = event_packet.evt_serial.evt.payload_len; + + info!( + "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}", + kind, + code, + payload_len, + payload[3..] + ); + } + + mbox.shci_ble_init(&mut ipcc, Default::default()); + + info!("resetting BLE"); + mbox.send_ble_cmd(&mut ipcc, &[0x01, 0x03, 0x0c]); + + let event_box = mbox.read().await; + + let mut payload = [0u8; 7]; + event_box.copy_into_slice(&mut payload).unwrap(); + + let event_packet = event_box.evt(); + let kind = event_packet.evt_serial.kind; + + let code = event_packet.evt_serial.evt.evt_code; + let payload_len = event_packet.evt_serial.evt.payload_len; + + info!( + "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}", + kind, code, payload_len, payload + ); + + loop {} +} -- cgit From eb09d7d67174d4b1f94e84e452f2920dd5fe442b Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 21 May 2023 18:39:13 -0500 Subject: stm32/ipcc: update doc --- examples/stm32wb/src/bin/tl_mbox.rs | 1 + examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | 1 + 2 files changed, 2 insertions(+) (limited to 'examples') diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs index ccd01cbc7..acbc60c87 100644 --- a/examples/stm32wb/src/bin/tl_mbox.rs +++ b/examples/stm32wb/src/bin/tl_mbox.rs @@ -28,6 +28,7 @@ async fn main(_spawner: Spawner) { - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. - Select that file, the memory address, "verify download", and then "Firmware Upgrade". + - Select "Start Wireless Stack". - Disconnect from the device. - In the examples folder for stm32wb, modify the memory.x file to match your target device. - Run this example. diff --git a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs index 315172df8..ff506338d 100644 --- a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs +++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs @@ -27,6 +27,7 @@ async fn main(_spawner: Spawner) { - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. - Select that file, the memory address, "verify download", and then "Firmware Upgrade". + - Select "Start Wireless Stack". - Disconnect from the device. - In the examples folder for stm32wb, modify the memory.x file to match your target device. - Run this example. -- cgit From d1dfaa190518df6adc66ab0716236bac3fe5f894 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 21 May 2023 20:18:26 -0500 Subject: stm32/ipcc: fix hil test --- examples/stm32wb/memory.x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/stm32wb/memory.x b/examples/stm32wb/memory.x index 5a07b7d19..e1f0530bd 100644 --- a/examples/stm32wb/memory.x +++ b/examples/stm32wb/memory.x @@ -11,7 +11,7 @@ MEMORY } /* - Memory size for STM32WB55xC with 512K FLASH + Memory size for STM32WB55xG with 512K FLASH MEMORY { -- cgit From 12720737e1c099b5626e45946b4f92b606922c2d Mon Sep 17 00:00:00 2001 From: goueslati Date: Mon, 22 May 2023 10:52:05 +0100 Subject: stm32/ipcc: fix incorrect example --- examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs index ff506338d..be606399f 100644 --- a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs +++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs @@ -75,7 +75,7 @@ async fn main(_spawner: Spawner) { mbox.shci_ble_init(&mut ipcc, Default::default()); info!("resetting BLE"); - mbox.send_ble_cmd(&mut ipcc, &[0x01, 0x03, 0x0c]); + mbox.send_ble_cmd(&mut ipcc, &[0x01, 0x03, 0x0c, 0x00, 0x00]); let event_box = mbox.read().await; -- cgit From 059ab358a5bd9102df09e511b190a70684e9c261 Mon Sep 17 00:00:00 2001 From: goueslati Date: Mon, 22 May 2023 11:13:22 +0100 Subject: stm32/ipcc: uncomment shci init cmd --- examples/stm32wb/src/bin/tl_mbox_tx_rx.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs index be606399f..1008e1e41 100644 --- a/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs +++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs @@ -47,7 +47,7 @@ async fn main(_spawner: Spawner) { let mbox = TlMbox::init(&mut ipcc, rx_irq, tx_irq); // initialize ble stack, does not return a response - // mbox.shci_ble_init(&mut ipcc, Default::default()); + mbox.shci_ble_init(&mut ipcc, Default::default()); info!("waiting for coprocessor to boot"); let event_box = mbox.read().await; -- cgit