aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2023-05-23 01:15:22 +0000
committerGitHub <[email protected]>2023-05-23 01:15:22 +0000
commit1fdde8f03fc8b98c7fdb91a94e2dfd47bcbc24cb (patch)
treeb28d26b4a54ecccce2de498e5106fc55be631061 /examples
parentab7d129e152a9450b2a6445397365bcb3a3ce183 (diff)
parent64092169e3133b572626c1efa106963139a63b3f (diff)
Merge #1457
1457: TL Mbox read and write for stm32wb r=xoviat a=OueslatiGhaith Hello, This pull request is related to #1397 and #1401, inspired by #24, built upon the work done in #1405 and #1424, and was tested on an stm32wb55rg. This pull request aims to add read and write functionality to the TL mailbox for stm32wb microcontrollers Co-authored-by: goueslati <[email protected]> Co-authored-by: xoviat <[email protected]>
Diffstat (limited to 'examples')
-rw-r--r--examples/stm32wb/memory.x2
-rw-r--r--examples/stm32wb/src/bin/tl_mbox.rs7
-rw-r--r--examples/stm32wb/src/bin/tl_mbox_tx_rx.rs97
3 files changed, 104 insertions, 2 deletions
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
11} 11}
12 12
13/* 13/*
14 Memory size for STM32WB55xC with 512K FLASH 14 Memory size for STM32WB55xG with 512K FLASH
15 15
16 MEMORY 16 MEMORY
17 { 17 {
diff --git a/examples/stm32wb/src/bin/tl_mbox.rs b/examples/stm32wb/src/bin/tl_mbox.rs
index 6876526ae..acbc60c87 100644
--- a/examples/stm32wb/src/bin/tl_mbox.rs
+++ b/examples/stm32wb/src/bin/tl_mbox.rs
@@ -4,6 +4,7 @@
4 4
5use defmt::*; 5use defmt::*;
6use embassy_executor::Spawner; 6use embassy_executor::Spawner;
7use embassy_stm32::interrupt;
7use embassy_stm32::ipcc::{Config, Ipcc}; 8use embassy_stm32::ipcc::{Config, Ipcc};
8use embassy_stm32::tl_mbox::TlMbox; 9use embassy_stm32::tl_mbox::TlMbox;
9use embassy_time::{Duration, Timer}; 10use embassy_time::{Duration, Timer};
@@ -27,6 +28,7 @@ async fn main(_spawner: Spawner) {
27 - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the 28 - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the
28 stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address. 29 stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address.
29 - Select that file, the memory address, "verify download", and then "Firmware Upgrade". 30 - Select that file, the memory address, "verify download", and then "Firmware Upgrade".
31 - Select "Start Wireless Stack".
30 - Disconnect from the device. 32 - Disconnect from the device.
31 - In the examples folder for stm32wb, modify the memory.x file to match your target device. 33 - In the examples folder for stm32wb, modify the memory.x file to match your target device.
32 - Run this example. 34 - Run this example.
@@ -40,7 +42,10 @@ async fn main(_spawner: Spawner) {
40 let config = Config::default(); 42 let config = Config::default();
41 let mut ipcc = Ipcc::new(p.IPCC, config); 43 let mut ipcc = Ipcc::new(p.IPCC, config);
42 44
43 let mbox = TlMbox::init(&mut ipcc); 45 let rx_irq = interrupt::take!(IPCC_C1_RX);
46 let tx_irq = interrupt::take!(IPCC_C1_TX);
47
48 let mbox = TlMbox::init(&mut ipcc, rx_irq, tx_irq);
44 49
45 loop { 50 loop {
46 let wireless_fw_info = mbox.wireless_fw_info(); 51 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..1008e1e41
--- /dev/null
+++ b/examples/stm32wb/src/bin/tl_mbox_tx_rx.rs
@@ -0,0 +1,97 @@
1#![no_std]
2#![no_main]
3#![feature(type_alias_impl_trait)]
4
5use defmt::*;
6use embassy_executor::Spawner;
7use embassy_stm32::interrupt;
8use embassy_stm32::ipcc::{Config, Ipcc};
9use embassy_stm32::tl_mbox::TlMbox;
10use {defmt_rtt as _, panic_probe as _};
11
12#[embassy_executor::main]
13async fn main(_spawner: Spawner) {
14 /*
15 How to make this work:
16
17 - Obtain a NUCLEO-STM32WB55 from your preferred supplier.
18 - Download and Install STM32CubeProgrammer.
19 - Download stm32wb5x_FUS_fw.bin, stm32wb5x_BLE_Stack_full_fw.bin, and Release_Notes.html from
20 gh:STMicroelectronics/STM32CubeWB@2234d97/Projects/STM32WB_Copro_Wireless_Binaries/STM32WB5x
21 - Open STM32CubeProgrammer
22 - On the right-hand pane, click "firmware upgrade" to upgrade the st-link firmware.
23 - Once complete, click connect to connect to the device.
24 - On the left hand pane, click the RSS signal icon to open "Firmware Upgrade Services".
25 - In the Release_Notes.html, find the memory address that corresponds to your device for the stm32wb5x_FUS_fw.bin file
26 - Select that file, the memory address, "verify download", and then "Firmware Upgrade".
27 - Once complete, in the Release_Notes.html, find the memory address that corresponds to your device for the
28 stm32wb5x_BLE_Stack_full_fw.bin file. It should not be the same memory address.
29 - Select that file, the memory address, "verify download", and then "Firmware Upgrade".
30 - Select "Start Wireless Stack".
31 - Disconnect from the device.
32 - In the examples folder for stm32wb, modify the memory.x file to match your target device.
33 - Run this example.
34
35 Note: extended stack versions are not supported at this time. Do not attempt to install a stack with "extended" in the name.
36 */
37
38 let p = embassy_stm32::init(Default::default());
39 info!("Hello World!");
40
41 let config = Config::default();
42 let mut ipcc = Ipcc::new(p.IPCC, config);
43
44 let rx_irq = interrupt::take!(IPCC_C1_RX);
45 let tx_irq = interrupt::take!(IPCC_C1_TX);
46
47 let mbox = TlMbox::init(&mut ipcc, rx_irq, tx_irq);
48
49 // initialize ble stack, does not return a response
50 mbox.shci_ble_init(&mut ipcc, Default::default());
51
52 info!("waiting for coprocessor to boot");
53 let event_box = mbox.read().await;
54
55 let mut payload = [0u8; 6];
56 event_box.copy_into_slice(&mut payload).unwrap();
57
58 let event_packet = event_box.evt();
59 let kind = event_packet.evt_serial.kind;
60
61 // means recieved SYS event, which indicates in this case that the coprocessor is ready
62 if kind == 0x12 {
63 let code = event_packet.evt_serial.evt.evt_code;
64 let payload_len = event_packet.evt_serial.evt.payload_len;
65
66 info!(
67 "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}",
68 kind,
69 code,
70 payload_len,
71 payload[3..]
72 );
73 }
74
75 mbox.shci_ble_init(&mut ipcc, Default::default());
76
77 info!("resetting BLE");
78 mbox.send_ble_cmd(&mut ipcc, &[0x01, 0x03, 0x0c, 0x00, 0x00]);
79
80 let event_box = mbox.read().await;
81
82 let mut payload = [0u8; 7];
83 event_box.copy_into_slice(&mut payload).unwrap();
84
85 let event_packet = event_box.evt();
86 let kind = event_packet.evt_serial.kind;
87
88 let code = event_packet.evt_serial.evt.evt_code;
89 let payload_len = event_packet.evt_serial.evt.payload_len;
90
91 info!(
92 "==> kind: {:#04x}, code: {:#04x}, payload_length: {}, payload: {:#04x}",
93 kind, code, payload_len, payload
94 );
95
96 loop {}
97}