diff options
| author | xoviat <[email protected]> | 2023-06-25 16:44:52 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-06-25 16:44:52 +0000 |
| commit | 03e0116a56d7bc4b8eb639fd590eaa186d039b2b (patch) | |
| tree | 7fe23e3a556a06202bf926d6176d39949f4c1ab6 | |
| parent | 4dd48099bee305fc31e47a586f34d09c3ec02673 (diff) | |
| parent | 018622f607a17037903ef7c5592dda762002f89b (diff) | |
Merge pull request #1580 from xoviat/wpan
stm32/wpan: cleanup
| -rw-r--r-- | embassy-stm32-wpan/Cargo.toml | 1 | ||||
| -rw-r--r-- | embassy-stm32-wpan/build.rs | 13 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/consts.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/evt.rs | 33 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lhci.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lib.rs | 26 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/ble.rs (renamed from embassy-stm32-wpan/src/ble.rs) | 25 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac.rs (renamed from embassy-stm32-wpan/src/mac.rs) | 48 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mm.rs (renamed from embassy-stm32-wpan/src/mm.rs) | 23 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mod.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs (renamed from embassy-stm32-wpan/src/sys.rs) | 3 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/tables.rs | 34 | ||||
| -rw-r--r-- | embassy-stm32-wpan/tl_mbox.x.in (renamed from embassy-stm32/tl_mbox.x.in) | 0 | ||||
| -rw-r--r-- | embassy-stm32/build.rs | 10 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/eddystone_beacon.rs | 14 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox_mac.rs | 4 | ||||
| -rw-r--r-- | tests/stm32/src/bin/tl_mbox.rs | 21 |
17 files changed, 146 insertions, 128 deletions
diff --git a/embassy-stm32-wpan/Cargo.toml b/embassy-stm32-wpan/Cargo.toml index 6d78ca577..4b830cab3 100644 --- a/embassy-stm32-wpan/Cargo.toml +++ b/embassy-stm32-wpan/Cargo.toml | |||
| @@ -21,6 +21,7 @@ embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" } | |||
| 21 | defmt = { version = "0.3", optional = true } | 21 | defmt = { version = "0.3", optional = true } |
| 22 | cortex-m = "0.7.6" | 22 | cortex-m = "0.7.6" |
| 23 | heapless = "0.7.16" | 23 | heapless = "0.7.16" |
| 24 | aligned = "0.4.1" | ||
| 24 | 25 | ||
| 25 | bit_field = "0.10.2" | 26 | bit_field = "0.10.2" |
| 26 | stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] } | 27 | stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] } |
diff --git a/embassy-stm32-wpan/build.rs b/embassy-stm32-wpan/build.rs index 4edf73d59..94aac070d 100644 --- a/embassy-stm32-wpan/build.rs +++ b/embassy-stm32-wpan/build.rs | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | use std::env; | 1 | use std::path::PathBuf; |
| 2 | use std::{env, fs}; | ||
| 2 | 3 | ||
| 3 | fn main() { | 4 | fn main() { |
| 4 | match env::vars() | 5 | match env::vars() |
| @@ -10,6 +11,16 @@ fn main() { | |||
| 10 | Err(GetOneError::None) => panic!("No stm32xx Cargo feature enabled"), | 11 | Err(GetOneError::None) => panic!("No stm32xx Cargo feature enabled"), |
| 11 | Err(GetOneError::Multiple) => panic!("Multiple stm32xx Cargo features enabled"), | 12 | Err(GetOneError::Multiple) => panic!("Multiple stm32xx Cargo features enabled"), |
| 12 | } | 13 | } |
| 14 | |||
| 15 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | ||
| 16 | |||
| 17 | // ======== | ||
| 18 | // stm32wb tl_mbox link sections | ||
| 19 | |||
| 20 | let out_file = out_dir.join("tl_mbox.x").to_string_lossy().to_string(); | ||
| 21 | fs::write(out_file, fs::read_to_string("tl_mbox.x.in").unwrap()).unwrap(); | ||
| 22 | println!("cargo:rustc-link-search={}", out_dir.display()); | ||
| 23 | println!("cargo:rerun-if-changed=tl_mbox.x.in"); | ||
| 13 | } | 24 | } |
| 14 | 25 | ||
| 15 | enum GetOneError { | 26 | enum GetOneError { |
diff --git a/embassy-stm32-wpan/src/consts.rs b/embassy-stm32-wpan/src/consts.rs index 9a107306c..f234151d7 100644 --- a/embassy-stm32-wpan/src/consts.rs +++ b/embassy-stm32-wpan/src/consts.rs | |||
| @@ -87,3 +87,7 @@ pub const fn divc(x: usize, y: usize) -> usize { | |||
| 87 | pub const TL_BLE_EVT_CS_PACKET_SIZE: usize = TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE; | 87 | pub const TL_BLE_EVT_CS_PACKET_SIZE: usize = TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE; |
| 88 | #[allow(dead_code)] | 88 | #[allow(dead_code)] |
| 89 | pub const TL_BLE_EVT_CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_BLE_EVT_CS_PACKET_SIZE; | 89 | pub const TL_BLE_EVT_CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_BLE_EVT_CS_PACKET_SIZE; |
| 90 | |||
| 91 | pub const TL_BLEEVT_CC_OPCODE: u8 = 0x0E; | ||
| 92 | pub const TL_BLEEVT_CS_OPCODE: u8 = 0x0F; | ||
| 93 | pub const TL_BLEEVT_VS_OPCODE: u8 = 0xFF; | ||
diff --git a/embassy-stm32-wpan/src/evt.rs b/embassy-stm32-wpan/src/evt.rs index 25249a13a..c6528413d 100644 --- a/embassy-stm32-wpan/src/evt.rs +++ b/embassy-stm32-wpan/src/evt.rs | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | use core::marker::PhantomData; | ||
| 1 | use core::{ptr, slice}; | 2 | use core::{ptr, slice}; |
| 2 | 3 | ||
| 3 | use super::PacketHeader; | 4 | use super::PacketHeader; |
| @@ -93,17 +94,22 @@ impl EvtPacket { | |||
| 93 | } | 94 | } |
| 94 | } | 95 | } |
| 95 | 96 | ||
| 97 | pub trait MemoryManager { | ||
| 98 | unsafe fn drop_event_packet(evt: *mut EvtPacket); | ||
| 99 | } | ||
| 100 | |||
| 96 | /// smart pointer to the [`EvtPacket`] that will dispose of [`EvtPacket`] buffer automatically | 101 | /// smart pointer to the [`EvtPacket`] that will dispose of [`EvtPacket`] buffer automatically |
| 97 | /// on [`Drop`] | 102 | /// on [`Drop`] |
| 98 | #[derive(Debug)] | 103 | #[derive(Debug)] |
| 99 | pub struct EvtBox { | 104 | pub struct EvtBox<T: MemoryManager> { |
| 100 | ptr: *mut EvtPacket, | 105 | ptr: *mut EvtPacket, |
| 106 | mm: PhantomData<T>, | ||
| 101 | } | 107 | } |
| 102 | 108 | ||
| 103 | unsafe impl Send for EvtBox {} | 109 | unsafe impl<T: MemoryManager> Send for EvtBox<T> {} |
| 104 | impl EvtBox { | 110 | impl<T: MemoryManager> EvtBox<T> { |
| 105 | pub(super) fn new(ptr: *mut EvtPacket) -> Self { | 111 | pub(super) fn new(ptr: *mut EvtPacket) -> Self { |
| 106 | Self { ptr } | 112 | Self { ptr, mm: PhantomData } |
| 107 | } | 113 | } |
| 108 | 114 | ||
| 109 | /// Returns information about the event | 115 | /// Returns information about the event |
| @@ -126,9 +132,6 @@ impl EvtBox { | |||
| 126 | } | 132 | } |
| 127 | } | 133 | } |
| 128 | 134 | ||
| 129 | /// writes an underlying [`EvtPacket`] into the provided buffer. | ||
| 130 | /// Returns the number of bytes that were written. | ||
| 131 | /// Returns an error if event kind is unknown or if provided buffer size is not enough. | ||
| 132 | pub fn serial<'a>(&'a self) -> &'a [u8] { | 135 | pub fn serial<'a>(&'a self) -> &'a [u8] { |
| 133 | unsafe { | 136 | unsafe { |
| 134 | let evt_serial: *const EvtSerial = &(*self.ptr).evt_serial; | 137 | let evt_serial: *const EvtSerial = &(*self.ptr).evt_serial; |
| @@ -141,20 +144,8 @@ impl EvtBox { | |||
| 141 | } | 144 | } |
| 142 | } | 145 | } |
| 143 | 146 | ||
| 144 | impl Drop for EvtBox { | 147 | impl<T: MemoryManager> Drop for EvtBox<T> { |
| 145 | fn drop(&mut self) { | 148 | fn drop(&mut self) { |
| 146 | #[cfg(feature = "ble")] | 149 | unsafe { T::drop_event_packet(self.ptr) }; |
| 147 | unsafe { | ||
| 148 | use crate::mm; | ||
| 149 | |||
| 150 | mm::MemoryManager::drop_event_packet(self.ptr) | ||
| 151 | }; | ||
| 152 | |||
| 153 | #[cfg(feature = "mac")] | ||
| 154 | unsafe { | ||
| 155 | use crate::mac; | ||
| 156 | |||
| 157 | mac::Mac::drop_event_packet(self.ptr) | ||
| 158 | } | ||
| 159 | } | 150 | } |
| 160 | } | 151 | } |
diff --git a/embassy-stm32-wpan/src/lhci.rs b/embassy-stm32-wpan/src/lhci.rs index 62116a695..89f204f99 100644 --- a/embassy-stm32-wpan/src/lhci.rs +++ b/embassy-stm32-wpan/src/lhci.rs | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | use core::ptr; | ||
| 2 | |||
| 1 | use crate::cmd::CmdPacket; | 3 | use crate::cmd::CmdPacket; |
| 2 | use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; | 4 | use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; |
| 3 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; | 5 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; |
| 4 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable}; | 6 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable, TL_DEVICE_INFO_TABLE}; |
| 5 | use crate::TL_REF_TABLE; | ||
| 6 | 7 | ||
| 7 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; | 8 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; |
| 8 | const LHCI_OPCODE_C1_DEVICE_INF: u16 = 0xfd62; | 9 | const LHCI_OPCODE_C1_DEVICE_INF: u16 = 0xfd62; |
| @@ -38,7 +39,7 @@ impl Default for LhciC1DeviceInformationCcrp { | |||
| 38 | safe_boot_info_table, | 39 | safe_boot_info_table, |
| 39 | rss_info_table, | 40 | rss_info_table, |
| 40 | wireless_fw_info_table, | 41 | wireless_fw_info_table, |
| 41 | } = unsafe { &*(*TL_REF_TABLE.as_ptr()).device_info_table }.clone(); | 42 | } = unsafe { ptr::read_volatile(TL_DEVICE_INFO_TABLE.as_ptr()) }; |
| 42 | 43 | ||
| 43 | let device_id = stm32_device_signature::device_id(); | 44 | let device_id = stm32_device_signature::device_id(); |
| 44 | let uid96_0 = (device_id[3] as u32) << 24 | 45 | let uid96_0 = (device_id[3] as u32) << 24 |
| @@ -105,7 +106,7 @@ impl LhciC1DeviceInformationCcrp { | |||
| 105 | let self_ptr: *const LhciC1DeviceInformationCcrp = self; | 106 | let self_ptr: *const LhciC1DeviceInformationCcrp = self; |
| 106 | let self_buf = self_ptr.cast(); | 107 | let self_buf = self_ptr.cast(); |
| 107 | 108 | ||
| 108 | core::ptr::copy(self_buf, evt_cc_payload_buf, self_size); | 109 | ptr::copy(self_buf, evt_cc_payload_buf, self_size); |
| 109 | } | 110 | } |
| 110 | } | 111 | } |
| 111 | } | 112 | } |
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index bf0f0466e..99c610583 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs | |||
| @@ -11,26 +11,24 @@ use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | |||
| 11 | use embassy_stm32::interrupt; | 11 | use embassy_stm32::interrupt; |
| 12 | use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler}; | 12 | use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 13 | use embassy_stm32::peripherals::IPCC; | 13 | use embassy_stm32::peripherals::IPCC; |
| 14 | use mm::MemoryManager; | 14 | use sub::mm::MemoryManager; |
| 15 | use sys::Sys; | 15 | use sub::sys::Sys; |
| 16 | use tables::*; | 16 | use tables::*; |
| 17 | use unsafe_linked_list::LinkedListNode; | 17 | use unsafe_linked_list::LinkedListNode; |
| 18 | 18 | ||
| 19 | #[cfg(feature = "ble")] | ||
| 20 | pub mod ble; | ||
| 21 | pub mod channels; | 19 | pub mod channels; |
| 22 | pub mod cmd; | 20 | pub mod cmd; |
| 23 | pub mod consts; | 21 | pub mod consts; |
| 24 | pub mod evt; | 22 | pub mod evt; |
| 25 | pub mod lhci; | 23 | pub mod lhci; |
| 26 | #[cfg(feature = "mac")] | ||
| 27 | pub mod mac; | ||
| 28 | pub mod mm; | ||
| 29 | pub mod shci; | 24 | pub mod shci; |
| 30 | pub mod sys; | 25 | pub mod sub; |
| 31 | pub mod tables; | 26 | pub mod tables; |
| 32 | pub mod unsafe_linked_list; | 27 | pub mod unsafe_linked_list; |
| 33 | 28 | ||
| 29 | #[cfg(feature = "ble")] | ||
| 30 | pub use crate::sub::ble::hci; | ||
| 31 | |||
| 34 | type PacketHeader = LinkedListNode; | 32 | type PacketHeader = LinkedListNode; |
| 35 | 33 | ||
| 36 | pub struct TlMbox<'d> { | 34 | pub struct TlMbox<'d> { |
| @@ -39,9 +37,9 @@ pub struct TlMbox<'d> { | |||
| 39 | pub sys_subsystem: Sys, | 37 | pub sys_subsystem: Sys, |
| 40 | pub mm_subsystem: MemoryManager, | 38 | pub mm_subsystem: MemoryManager, |
| 41 | #[cfg(feature = "ble")] | 39 | #[cfg(feature = "ble")] |
| 42 | pub ble_subsystem: ble::Ble, | 40 | pub ble_subsystem: sub::ble::Ble, |
| 43 | #[cfg(feature = "mac")] | 41 | #[cfg(feature = "mac")] |
| 44 | pub mac_subsystem: mac::Mac, | 42 | pub mac_subsystem: sub::mac::Mac, |
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | impl<'d> TlMbox<'d> { | 45 | impl<'d> TlMbox<'d> { |
| @@ -128,12 +126,12 @@ impl<'d> TlMbox<'d> { | |||
| 128 | 126 | ||
| 129 | Self { | 127 | Self { |
| 130 | _ipcc: ipcc, | 128 | _ipcc: ipcc, |
| 131 | sys_subsystem: sys::Sys::new(), | 129 | sys_subsystem: sub::sys::Sys::new(), |
| 132 | #[cfg(feature = "ble")] | 130 | #[cfg(feature = "ble")] |
| 133 | ble_subsystem: ble::Ble::new(), | 131 | ble_subsystem: sub::ble::Ble::new(), |
| 134 | #[cfg(feature = "mac")] | 132 | #[cfg(feature = "mac")] |
| 135 | mac_subsystem: mac::Mac::new(), | 133 | mac_subsystem: sub::mac::Mac::new(), |
| 136 | mm_subsystem: mm::MemoryManager::new(), | 134 | mm_subsystem: sub::mm::MemoryManager::new(), |
| 137 | } | 135 | } |
| 138 | } | 136 | } |
| 139 | } | 137 | } |
diff --git a/embassy-stm32-wpan/src/ble.rs b/embassy-stm32-wpan/src/sub/ble.rs index 619cd66a0..cd32692e1 100644 --- a/embassy-stm32-wpan/src/ble.rs +++ b/embassy-stm32-wpan/src/sub/ble.rs | |||
| @@ -1,14 +1,16 @@ | |||
| 1 | use core::marker::PhantomData; | 1 | use core::marker::PhantomData; |
| 2 | use core::ptr; | ||
| 2 | 3 | ||
| 3 | use embassy_stm32::ipcc::Ipcc; | 4 | use embassy_stm32::ipcc::Ipcc; |
| 4 | use hci::Opcode; | 5 | use hci::Opcode; |
| 5 | 6 | ||
| 6 | use crate::channels; | ||
| 7 | use crate::cmd::CmdPacket; | 7 | use crate::cmd::CmdPacket; |
| 8 | use crate::consts::TlPacketType; | 8 | use crate::consts::{TlPacketType, TL_BLEEVT_CC_OPCODE, TL_BLEEVT_CS_OPCODE}; |
| 9 | use crate::evt::EvtBox; | 9 | use crate::evt::{EvtBox, EvtPacket, EvtStub}; |
| 10 | use crate::sub::mm; | ||
| 10 | use crate::tables::{BleTable, BLE_CMD_BUFFER, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE}; | 11 | use crate::tables::{BleTable, BLE_CMD_BUFFER, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE}; |
| 11 | use crate::unsafe_linked_list::LinkedListNode; | 12 | use crate::unsafe_linked_list::LinkedListNode; |
| 13 | use crate::{channels, evt}; | ||
| 12 | 14 | ||
| 13 | pub struct Ble { | 15 | pub struct Ble { |
| 14 | phantom: PhantomData<Ble>, | 16 | phantom: PhantomData<Ble>, |
| @@ -30,7 +32,7 @@ impl Ble { | |||
| 30 | Self { phantom: PhantomData } | 32 | Self { phantom: PhantomData } |
| 31 | } | 33 | } |
| 32 | /// `HW_IPCC_BLE_EvtNot` | 34 | /// `HW_IPCC_BLE_EvtNot` |
| 33 | pub async fn tl_read(&self) -> EvtBox { | 35 | pub async fn tl_read(&self) -> EvtBox<Self> { |
| 34 | Ipcc::receive(channels::cpu2::IPCC_BLE_EVENT_CHANNEL, || unsafe { | 36 | Ipcc::receive(channels::cpu2::IPCC_BLE_EVENT_CHANNEL, || unsafe { |
| 35 | if let Some(node_ptr) = LinkedListNode::remove_head(EVT_QUEUE.as_mut_ptr()) { | 37 | if let Some(node_ptr) = LinkedListNode::remove_head(EVT_QUEUE.as_mut_ptr()) { |
| 36 | Some(EvtBox::new(node_ptr.cast())) | 38 | Some(EvtBox::new(node_ptr.cast())) |
| @@ -63,6 +65,21 @@ impl Ble { | |||
| 63 | } | 65 | } |
| 64 | } | 66 | } |
| 65 | 67 | ||
| 68 | impl evt::MemoryManager for Ble { | ||
| 69 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | ||
| 70 | unsafe fn drop_event_packet(evt: *mut EvtPacket) { | ||
| 71 | let stub = unsafe { | ||
| 72 | let p_evt_stub = &(*evt).evt_serial as *const _ as *const EvtStub; | ||
| 73 | |||
| 74 | ptr::read_volatile(p_evt_stub) | ||
| 75 | }; | ||
| 76 | |||
| 77 | if !(stub.evt_code == TL_BLEEVT_CS_OPCODE || stub.evt_code == TL_BLEEVT_CC_OPCODE) { | ||
| 78 | mm::MemoryManager::drop_event_packet(evt); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 66 | pub extern crate stm32wb_hci as hci; | 83 | pub extern crate stm32wb_hci as hci; |
| 67 | 84 | ||
| 68 | impl hci::Controller for Ble { | 85 | impl hci::Controller for Ble { |
diff --git a/embassy-stm32-wpan/src/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index d2be1b85c..fd8af8609 100644 --- a/embassy-stm32-wpan/src/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs | |||
| @@ -8,13 +8,13 @@ use embassy_futures::poll_once; | |||
| 8 | use embassy_stm32::ipcc::Ipcc; | 8 | use embassy_stm32::ipcc::Ipcc; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::channels; | ||
| 12 | use crate::cmd::CmdPacket; | 11 | use crate::cmd::CmdPacket; |
| 13 | use crate::consts::TlPacketType; | 12 | use crate::consts::TlPacketType; |
| 14 | use crate::evt::{EvtBox, EvtPacket}; | 13 | use crate::evt::{EvtBox, EvtPacket}; |
| 15 | use crate::tables::{ | 14 | use crate::tables::{ |
| 16 | Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE, | 15 | Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE, |
| 17 | }; | 16 | }; |
| 17 | use crate::{channels, evt}; | ||
| 18 | 18 | ||
| 19 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); | 19 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); |
| 20 | static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); | 20 | static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); |
| @@ -36,31 +36,10 @@ impl Mac { | |||
| 36 | Self { phantom: PhantomData } | 36 | Self { phantom: PhantomData } |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | ||
| 40 | pub(crate) unsafe fn drop_event_packet(_: *mut EvtPacket) { | ||
| 41 | // Write the ack | ||
| 42 | CmdPacket::write_into( | ||
| 43 | MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _, | ||
| 44 | TlPacketType::OtAck, | ||
| 45 | 0, | ||
| 46 | &[], | ||
| 47 | ); | ||
| 48 | |||
| 49 | // Clear the rx flag | ||
| 50 | let _ = poll_once(Ipcc::receive::<bool>( | ||
| 51 | channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL, | ||
| 52 | || None, | ||
| 53 | )); | ||
| 54 | |||
| 55 | // Allow a new read call | ||
| 56 | MAC_EVT_OUT.store(false, Ordering::SeqCst); | ||
| 57 | MAC_WAKER.wake(); | ||
| 58 | } | ||
| 59 | |||
| 60 | /// `HW_IPCC_MAC_802_15_4_EvtNot` | 39 | /// `HW_IPCC_MAC_802_15_4_EvtNot` |
| 61 | /// | 40 | /// |
| 62 | /// This function will stall if the previous `EvtBox` has not been dropped | 41 | /// This function will stall if the previous `EvtBox` has not been dropped |
| 63 | pub async fn read(&self) -> EvtBox { | 42 | pub async fn read(&self) -> EvtBox<Self> { |
| 64 | // Wait for the last event box to be dropped | 43 | // Wait for the last event box to be dropped |
| 65 | poll_fn(|cx| { | 44 | poll_fn(|cx| { |
| 66 | MAC_WAKER.register(cx.waker()); | 45 | MAC_WAKER.register(cx.waker()); |
| @@ -109,3 +88,26 @@ impl Mac { | |||
| 109 | .await; | 88 | .await; |
| 110 | } | 89 | } |
| 111 | } | 90 | } |
| 91 | |||
| 92 | impl evt::MemoryManager for Mac { | ||
| 93 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | ||
| 94 | unsafe fn drop_event_packet(_: *mut EvtPacket) { | ||
| 95 | // Write the ack | ||
| 96 | CmdPacket::write_into( | ||
| 97 | MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _, | ||
| 98 | TlPacketType::OtAck, | ||
| 99 | 0, | ||
| 100 | &[], | ||
| 101 | ); | ||
| 102 | |||
| 103 | // Clear the rx flag | ||
| 104 | let _ = poll_once(Ipcc::receive::<bool>( | ||
| 105 | channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL, | ||
| 106 | || None, | ||
| 107 | )); | ||
| 108 | |||
| 109 | // Allow a new read call | ||
| 110 | MAC_EVT_OUT.store(false, Ordering::SeqCst); | ||
| 111 | MAC_WAKER.wake(); | ||
| 112 | } | ||
| 113 | } | ||
diff --git a/embassy-stm32-wpan/src/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs index 047fddcd4..1f2ecac2e 100644 --- a/embassy-stm32-wpan/src/mm.rs +++ b/embassy-stm32-wpan/src/sub/mm.rs | |||
| @@ -8,13 +8,13 @@ use cortex_m::interrupt; | |||
| 8 | use embassy_stm32::ipcc::Ipcc; | 8 | use embassy_stm32::ipcc::Ipcc; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::channels; | ||
| 12 | use crate::consts::POOL_SIZE; | 11 | use crate::consts::POOL_SIZE; |
| 13 | use crate::evt::EvtPacket; | 12 | use crate::evt::EvtPacket; |
| 14 | use crate::tables::{ | 13 | use crate::tables::{ |
| 15 | MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE, | 14 | MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE, |
| 16 | }; | 15 | }; |
| 17 | use crate::unsafe_linked_list::LinkedListNode; | 16 | use crate::unsafe_linked_list::LinkedListNode; |
| 17 | use crate::{channels, evt}; | ||
| 18 | 18 | ||
| 19 | static MM_WAKER: AtomicWaker = AtomicWaker::new(); | 19 | static MM_WAKER: AtomicWaker = AtomicWaker::new(); |
| 20 | static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 20 | static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| @@ -43,16 +43,6 @@ impl MemoryManager { | |||
| 43 | Self { phantom: PhantomData } | 43 | Self { phantom: PhantomData } |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | #[allow(dead_code)] | ||
| 47 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | ||
| 48 | pub(crate) unsafe fn drop_event_packet(evt: *mut EvtPacket) { | ||
| 49 | interrupt::free(|_| unsafe { | ||
| 50 | LinkedListNode::insert_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), evt as *mut _); | ||
| 51 | }); | ||
| 52 | |||
| 53 | MM_WAKER.wake(); | ||
| 54 | } | ||
| 55 | |||
| 56 | pub async fn run_queue(&self) { | 46 | pub async fn run_queue(&self) { |
| 57 | loop { | 47 | loop { |
| 58 | poll_fn(|cx| unsafe { | 48 | poll_fn(|cx| unsafe { |
| @@ -77,3 +67,14 @@ impl MemoryManager { | |||
| 77 | } | 67 | } |
| 78 | } | 68 | } |
| 79 | } | 69 | } |
| 70 | |||
| 71 | impl evt::MemoryManager for MemoryManager { | ||
| 72 | /// SAFETY: passing a pointer to something other than a managed event packet is UB | ||
| 73 | unsafe fn drop_event_packet(evt: *mut EvtPacket) { | ||
| 74 | interrupt::free(|_| unsafe { | ||
| 75 | LinkedListNode::insert_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), evt as *mut _); | ||
| 76 | }); | ||
| 77 | |||
| 78 | MM_WAKER.wake(); | ||
| 79 | } | ||
| 80 | } | ||
diff --git a/embassy-stm32-wpan/src/sub/mod.rs b/embassy-stm32-wpan/src/sub/mod.rs new file mode 100644 index 000000000..bee3dbdf1 --- /dev/null +++ b/embassy-stm32-wpan/src/sub/mod.rs | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #[cfg(feature = "ble")] | ||
| 2 | pub mod ble; | ||
| 3 | #[cfg(feature = "mac")] | ||
| 4 | pub mod mac; | ||
| 5 | pub mod mm; | ||
| 6 | pub mod sys; | ||
diff --git a/embassy-stm32-wpan/src/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index 2b699b725..af652860d 100644 --- a/embassy-stm32-wpan/src/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
| @@ -6,6 +6,7 @@ use crate::consts::TlPacketType; | |||
| 6 | use crate::evt::{CcEvt, EvtBox, EvtPacket}; | 6 | use crate::evt::{CcEvt, EvtBox, EvtPacket}; |
| 7 | #[allow(unused_imports)] | 7 | #[allow(unused_imports)] |
| 8 | use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; | 8 | use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; |
| 9 | use crate::sub::mm; | ||
| 9 | use crate::tables::{SysTable, WirelessFwInfoTable}; | 10 | use crate::tables::{SysTable, WirelessFwInfoTable}; |
| 10 | use crate::unsafe_linked_list::LinkedListNode; | 11 | use crate::unsafe_linked_list::LinkedListNode; |
| 11 | use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; | 12 | use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; |
| @@ -73,7 +74,7 @@ impl Sys { | |||
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | /// `HW_IPCC_SYS_EvtNot` | 76 | /// `HW_IPCC_SYS_EvtNot` |
| 76 | pub async fn read(&self) -> EvtBox { | 77 | pub async fn read(&self) -> EvtBox<mm::MemoryManager> { |
| 77 | Ipcc::receive(channels::cpu2::IPCC_SYSTEM_EVENT_CHANNEL, || unsafe { | 78 | Ipcc::receive(channels::cpu2::IPCC_SYSTEM_EVENT_CHANNEL, || unsafe { |
| 78 | if let Some(node_ptr) = LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr()) { | 79 | if let Some(node_ptr) = LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr()) { |
| 79 | Some(EvtBox::new(node_ptr.cast())) | 80 | Some(EvtBox::new(node_ptr.cast())) |
diff --git a/embassy-stm32-wpan/src/tables.rs b/embassy-stm32-wpan/src/tables.rs index 3f26282c6..1b5dcdf2e 100644 --- a/embassy-stm32-wpan/src/tables.rs +++ b/embassy-stm32-wpan/src/tables.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | use core::mem::MaybeUninit; | 1 | use core::mem::MaybeUninit; |
| 2 | 2 | ||
| 3 | use aligned::{Aligned, A4}; | ||
| 3 | use bit_field::BitField; | 4 | use bit_field::BitField; |
| 4 | 5 | ||
| 5 | use crate::cmd::{AclDataPacket, CmdPacket}; | 6 | use crate::cmd::{AclDataPacket, CmdPacket}; |
| @@ -164,9 +165,6 @@ pub struct Mac802_15_4Table { | |||
| 164 | pub evt_queue: *const u8, | 165 | pub evt_queue: *const u8, |
| 165 | } | 166 | } |
| 166 | 167 | ||
| 167 | #[repr(C, align(4))] | ||
| 168 | pub struct AlignedData<const L: usize>([u8; L]); | ||
| 169 | |||
| 170 | /// Reference table. Contains pointers to all other tables. | 168 | /// Reference table. Contains pointers to all other tables. |
| 171 | #[derive(Debug, Copy, Clone)] | 169 | #[derive(Debug, Copy, Clone)] |
| 172 | #[repr(C)] | 170 | #[repr(C)] |
| @@ -222,10 +220,9 @@ pub static mut FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit | |||
| 222 | #[link_section = "MB_MEM1"] | 220 | #[link_section = "MB_MEM1"] |
| 223 | pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 221 | pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| 224 | 222 | ||
| 225 | const CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE; | ||
| 226 | |||
| 227 | #[link_section = "MB_MEM2"] | 223 | #[link_section = "MB_MEM2"] |
| 228 | pub static mut CS_BUFFER: MaybeUninit<AlignedData<CS_BUFFER_SIZE>> = MaybeUninit::uninit(); | 224 | pub static mut CS_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> = |
| 225 | MaybeUninit::uninit(); | ||
| 229 | 226 | ||
| 230 | #[link_section = "MB_MEM2"] | 227 | #[link_section = "MB_MEM2"] |
| 231 | pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 228 | pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| @@ -239,34 +236,29 @@ pub static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::unin | |||
| 239 | pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 236 | pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 240 | 237 | ||
| 241 | #[cfg(feature = "mac")] | 238 | #[cfg(feature = "mac")] |
| 242 | const MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 243 | |||
| 244 | #[cfg(feature = "mac")] | ||
| 245 | #[link_section = "MB_MEM2"] | 239 | #[link_section = "MB_MEM2"] |
| 246 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<AlignedData<MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE>> = | 240 | pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit< |
| 247 | MaybeUninit::uninit(); | 241 | Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>, |
| 242 | > = MaybeUninit::uninit(); | ||
| 248 | 243 | ||
| 249 | #[link_section = "MB_MEM2"] | 244 | #[link_section = "MB_MEM2"] |
| 250 | pub static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit(); | 245 | pub static mut EVT_POOL: MaybeUninit<Aligned<A4, [u8; POOL_SIZE]>> = MaybeUninit::uninit(); |
| 251 | 246 | ||
| 252 | #[link_section = "MB_MEM2"] | 247 | #[link_section = "MB_MEM2"] |
| 253 | pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 248 | pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 254 | 249 | ||
| 255 | const SYS_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 256 | |||
| 257 | #[link_section = "MB_MEM2"] | 250 | #[link_section = "MB_MEM2"] |
| 258 | pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<AlignedData<SYS_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit(); | 251 | pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 252 | MaybeUninit::uninit(); | ||
| 259 | 253 | ||
| 260 | #[link_section = "MB_MEM1"] | 254 | #[link_section = "MB_MEM1"] |
| 261 | pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 255 | pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 262 | 256 | ||
| 263 | const BLE_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255; | ||
| 264 | |||
| 265 | #[link_section = "MB_MEM2"] | 257 | #[link_section = "MB_MEM2"] |
| 266 | pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<AlignedData<BLE_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit(); | 258 | pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 267 | 259 | MaybeUninit::uninit(); | |
| 268 | const HCI_ACL_DATA_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + 5 + 251; | ||
| 269 | 260 | ||
| 270 | #[link_section = "MB_MEM2"] | 261 | #[link_section = "MB_MEM2"] |
| 271 | // fuck these "magic" numbers from ST ---v---v | 262 | // fuck these "magic" numbers from ST ---v---v |
| 272 | pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; HCI_ACL_DATA_BUFFER_SIZE]> = MaybeUninit::uninit(); | 263 | pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> = |
| 264 | MaybeUninit::uninit(); | ||
diff --git a/embassy-stm32/tl_mbox.x.in b/embassy-stm32-wpan/tl_mbox.x.in index b6eecb429..b6eecb429 100644 --- a/embassy-stm32/tl_mbox.x.in +++ b/embassy-stm32-wpan/tl_mbox.x.in | |||
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index f71074bcf..40103d322 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -911,16 +911,6 @@ fn main() { | |||
| 911 | println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]); | 911 | println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]); |
| 912 | } | 912 | } |
| 913 | 913 | ||
| 914 | // ======== | ||
| 915 | // stm32wb tl_mbox link sections | ||
| 916 | |||
| 917 | if chip_name.starts_with("stm32wb") { | ||
| 918 | let out_file = out_dir.join("tl_mbox.x").to_string_lossy().to_string(); | ||
| 919 | fs::write(out_file, fs::read_to_string("tl_mbox.x.in").unwrap()).unwrap(); | ||
| 920 | println!("cargo:rustc-link-search={}", out_dir.display()); | ||
| 921 | println!("cargo:rerun-if-changed=tl_mbox.x.in"); | ||
| 922 | } | ||
| 923 | |||
| 924 | // ======= | 914 | // ======= |
| 925 | // Features for targeting groups of chips | 915 | // Features for targeting groups of chips |
| 926 | 916 | ||
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs index fdd5be4a2..b99f8cb2e 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs | |||
| @@ -8,15 +8,15 @@ use defmt::*; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::bind_interrupts; | 9 | use embassy_stm32::bind_interrupts; |
| 10 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 10 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 11 | use embassy_stm32_wpan::ble::hci::host::uart::UartHci; | 11 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 12 | use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 12 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 13 | use embassy_stm32_wpan::ble::hci::types::AdvertisingType; | 13 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 14 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ | 14 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ |
| 15 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 15 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, |
| 16 | }; | 16 | }; |
| 17 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; | 17 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; |
| 18 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 19 | use embassy_stm32_wpan::ble::hci::BdAddr; | 19 | use embassy_stm32_wpan::hci::BdAddr; |
| 20 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 20 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 21 | use embassy_stm32_wpan::TlMbox; | 21 | use embassy_stm32_wpan::TlMbox; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac.rs b/examples/stm32wb/src/bin/tl_mbox_mac.rs index afd319a41..f67be4682 100644 --- a/examples/stm32wb/src/bin/tl_mbox_mac.rs +++ b/examples/stm32wb/src/bin/tl_mbox_mac.rs | |||
| @@ -49,7 +49,9 @@ async fn main(_spawner: Spawner) { | |||
| 49 | let sys_event = mbox.sys_subsystem.read().await; | 49 | let sys_event = mbox.sys_subsystem.read().await; |
| 50 | info!("sys event: {}", sys_event.payload()); | 50 | info!("sys event: {}", sys_event.payload()); |
| 51 | 51 | ||
| 52 | mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; | 52 | let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; |
| 53 | info!("initialized mac: {}", result); | ||
| 54 | |||
| 53 | // | 55 | // |
| 54 | // info!("starting ble..."); | 56 | // info!("starting ble..."); |
| 55 | // mbox.ble_subsystem.t_write(0x0c, &[]).await; | 57 | // mbox.ble_subsystem.t_write(0x0c, &[]).await; |
diff --git a/tests/stm32/src/bin/tl_mbox.rs b/tests/stm32/src/bin/tl_mbox.rs index 76c736a5b..af3832709 100644 --- a/tests/stm32/src/bin/tl_mbox.rs +++ b/tests/stm32/src/bin/tl_mbox.rs | |||
| @@ -12,17 +12,18 @@ use common::*; | |||
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_stm32::bind_interrupts; | 13 | use embassy_stm32::bind_interrupts; |
| 14 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 14 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 15 | use embassy_stm32_wpan::ble::hci::host::uart::UartHci; | 15 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 16 | use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 16 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 17 | use embassy_stm32_wpan::ble::hci::types::AdvertisingType; | 17 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 18 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ | 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ |
| 19 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 19 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, |
| 20 | }; | 20 | }; |
| 21 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; | 21 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; |
| 22 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | 22 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 23 | use embassy_stm32_wpan::ble::hci::BdAddr; | 23 | use embassy_stm32_wpan::hci::BdAddr; |
| 24 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 24 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 25 | use embassy_stm32_wpan::{mm, TlMbox}; | 25 | use embassy_stm32_wpan::sub::mm; |
| 26 | use embassy_stm32_wpan::TlMbox; | ||
| 26 | use {defmt_rtt as _, panic_probe as _}; | 27 | use {defmt_rtt as _, panic_probe as _}; |
| 27 | 28 | ||
| 28 | bind_interrupts!(struct Irqs{ | 29 | bind_interrupts!(struct Irqs{ |
| @@ -38,14 +39,14 @@ async fn run_mm_queue(memory_manager: mm::MemoryManager) { | |||
| 38 | } | 39 | } |
| 39 | 40 | ||
| 40 | #[embassy_executor::main] | 41 | #[embassy_executor::main] |
| 41 | async fn main(_spawner: Spawner) { | 42 | async fn main(spawner: Spawner) { |
| 42 | let p = embassy_stm32::init(config()); | 43 | let p = embassy_stm32::init(config()); |
| 43 | info!("Hello World!"); | 44 | info!("Hello World!"); |
| 44 | 45 | ||
| 45 | let config = Config::default(); | 46 | let config = Config::default(); |
| 46 | let mut mbox = TlMbox::init(p.IPCC, Irqs, config); | 47 | let mut mbox = TlMbox::init(p.IPCC, Irqs, config); |
| 47 | 48 | ||
| 48 | // spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); | 49 | spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); |
| 49 | 50 | ||
| 50 | let sys_event = mbox.sys_subsystem.read().await; | 51 | let sys_event = mbox.sys_subsystem.read().await; |
| 51 | info!("sys event: {}", sys_event.payload()); | 52 | info!("sys event: {}", sys_event.payload()); |
