diff options
| -rw-r--r-- | embassy-stm32-wpan/src/cmd.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/consts.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lib.rs | 40 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mm.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs | 19 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/tables.rs | 92 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox_mac.rs | 12 |
8 files changed, 119 insertions, 71 deletions
diff --git a/embassy-stm32-wpan/src/cmd.rs b/embassy-stm32-wpan/src/cmd.rs index 8428b6ffc..928357384 100644 --- a/embassy-stm32-wpan/src/cmd.rs +++ b/embassy-stm32-wpan/src/cmd.rs | |||
| @@ -37,7 +37,7 @@ pub struct CmdSerialStub { | |||
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | #[derive(Copy, Clone, Default)] | 39 | #[derive(Copy, Clone, Default)] |
| 40 | #[repr(C, packed(4))] | 40 | #[repr(C, packed)] |
| 41 | pub struct CmdPacket { | 41 | pub struct CmdPacket { |
| 42 | pub header: PacketHeader, | 42 | pub header: PacketHeader, |
| 43 | pub cmdserial: CmdSerial, | 43 | pub cmdserial: CmdSerial, |
diff --git a/embassy-stm32-wpan/src/consts.rs b/embassy-stm32-wpan/src/consts.rs index f234151d7..1c84addb1 100644 --- a/embassy-stm32-wpan/src/consts.rs +++ b/embassy-stm32-wpan/src/consts.rs | |||
| @@ -79,6 +79,7 @@ pub const CFG_TL_BLE_MOST_EVENT_PAYLOAD_SIZE: usize = 255; | |||
| 79 | pub const TL_BLE_EVENT_FRAME_SIZE: usize = TL_EVT_HEADER_SIZE + CFG_TL_BLE_MOST_EVENT_PAYLOAD_SIZE; | 79 | pub const TL_BLE_EVENT_FRAME_SIZE: usize = TL_EVT_HEADER_SIZE + CFG_TL_BLE_MOST_EVENT_PAYLOAD_SIZE; |
| 80 | 80 | ||
| 81 | pub const POOL_SIZE: usize = CFG_TL_BLE_EVT_QUEUE_LENGTH * 4 * divc(TL_PACKET_HEADER_SIZE + TL_BLE_EVENT_FRAME_SIZE, 4); | 81 | pub const POOL_SIZE: usize = CFG_TL_BLE_EVT_QUEUE_LENGTH * 4 * divc(TL_PACKET_HEADER_SIZE + TL_BLE_EVENT_FRAME_SIZE, 4); |
| 82 | pub const C_SIZE_CMD_STRING: usize = 256; | ||
| 82 | 83 | ||
| 83 | pub const fn divc(x: usize, y: usize) -> usize { | 84 | pub const fn divc(x: usize, y: usize) -> usize { |
| 84 | (x + y - 1) / y | 85 | (x + y - 1) / y |
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index 99c610583..3a45c5978 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs | |||
| @@ -60,9 +60,9 @@ impl<'d> TlMbox<'d> { | |||
| 60 | mem_manager_table: TL_MEM_MANAGER_TABLE.as_ptr(), | 60 | mem_manager_table: TL_MEM_MANAGER_TABLE.as_ptr(), |
| 61 | traces_table: TL_TRACES_TABLE.as_ptr(), | 61 | traces_table: TL_TRACES_TABLE.as_ptr(), |
| 62 | mac_802_15_4_table: TL_MAC_802_15_4_TABLE.as_ptr(), | 62 | mac_802_15_4_table: TL_MAC_802_15_4_TABLE.as_ptr(), |
| 63 | // zigbee_table: TL_ZIGBEE_TABLE.as_ptr(), | 63 | zigbee_table: TL_ZIGBEE_TABLE.as_ptr(), |
| 64 | // lld_tests_table: TL_LLD_TESTS_TABLE.as_ptr(), | 64 | lld_tests_table: TL_LLD_TESTS_TABLE.as_ptr(), |
| 65 | // ble_lld_table: TL_BLE_LLD_TABLE.as_ptr(), | 65 | ble_lld_table: TL_BLE_LLD_TABLE.as_ptr(), |
| 66 | }); | 66 | }); |
| 67 | 67 | ||
| 68 | TL_SYS_TABLE | 68 | TL_SYS_TABLE |
| @@ -87,15 +87,15 @@ impl<'d> TlMbox<'d> { | |||
| 87 | TL_MAC_802_15_4_TABLE | 87 | TL_MAC_802_15_4_TABLE |
| 88 | .as_mut_ptr() | 88 | .as_mut_ptr() |
| 89 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 89 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 90 | // TL_ZIGBEE_TABLE | 90 | TL_ZIGBEE_TABLE |
| 91 | // .as_mut_ptr() | 91 | .as_mut_ptr() |
| 92 | // .write_volatile(MaybeUninit::zeroed().assume_init()); | 92 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 93 | // TL_LLD_TESTS_TABLE | 93 | TL_LLD_TESTS_TABLE |
| 94 | // .as_mut_ptr() | 94 | .as_mut_ptr() |
| 95 | // .write_volatile(MaybeUninit::zeroed().assume_init()); | 95 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 96 | // TL_BLE_LLD_TABLE | 96 | TL_BLE_LLD_TABLE |
| 97 | // .as_mut_ptr() | 97 | .as_mut_ptr() |
| 98 | // .write_volatile(MaybeUninit::zeroed().assume_init()); | 98 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 99 | 99 | ||
| 100 | EVT_POOL | 100 | EVT_POOL |
| 101 | .as_mut_ptr() | 101 | .as_mut_ptr() |
| @@ -103,18 +103,30 @@ impl<'d> TlMbox<'d> { | |||
| 103 | SYS_SPARE_EVT_BUF | 103 | SYS_SPARE_EVT_BUF |
| 104 | .as_mut_ptr() | 104 | .as_mut_ptr() |
| 105 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 105 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 106 | BLE_SPARE_EVT_BUF | 106 | CS_BUFFER |
| 107 | .as_mut_ptr() | 107 | .as_mut_ptr() |
| 108 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 108 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 109 | 109 | ||
| 110 | #[cfg(feature = "ble")] | ||
| 110 | { | 111 | { |
| 112 | BLE_SPARE_EVT_BUF | ||
| 113 | .as_mut_ptr() | ||
| 114 | .write_volatile(MaybeUninit::zeroed().assume_init()); | ||
| 115 | |||
| 111 | BLE_CMD_BUFFER | 116 | BLE_CMD_BUFFER |
| 112 | .as_mut_ptr() | 117 | .as_mut_ptr() |
| 113 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 118 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 114 | HCI_ACL_DATA_BUFFER | 119 | HCI_ACL_DATA_BUFFER |
| 115 | .as_mut_ptr() | 120 | .as_mut_ptr() |
| 116 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 121 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 117 | CS_BUFFER | 122 | } |
| 123 | |||
| 124 | #[cfg(feature = "mac")] | ||
| 125 | { | ||
| 126 | MAC_802_15_4_CMD_BUFFER | ||
| 127 | .as_mut_ptr() | ||
| 128 | .write_volatile(MaybeUninit::zeroed().assume_init()); | ||
| 129 | MAC_802_15_4_NOTIF_RSP_EVT_BUFFER | ||
| 118 | .as_mut_ptr() | 130 | .as_mut_ptr() |
| 119 | .write_volatile(MaybeUninit::zeroed().assume_init()); | 131 | .write_volatile(MaybeUninit::zeroed().assume_init()); |
| 120 | } | 132 | } |
diff --git a/embassy-stm32-wpan/src/sub/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index fd8af8609..f7a59b0e4 100644 --- a/embassy-stm32-wpan/src/sub/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs | |||
| @@ -11,9 +11,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 11 | use crate::cmd::CmdPacket; | 11 | use crate::cmd::CmdPacket; |
| 12 | use crate::consts::TlPacketType; | 12 | use crate::consts::TlPacketType; |
| 13 | use crate::evt::{EvtBox, EvtPacket}; | 13 | use crate::evt::{EvtBox, EvtPacket}; |
| 14 | use crate::tables::{ | 14 | use crate::tables::{MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER}; |
| 15 | Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE, | ||
| 16 | }; | ||
| 17 | use crate::{channels, evt}; | 15 | use crate::{channels, evt}; |
| 18 | 16 | ||
| 19 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); | 17 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); |
| @@ -25,14 +23,6 @@ pub struct Mac { | |||
| 25 | 23 | ||
| 26 | impl Mac { | 24 | impl Mac { |
| 27 | pub(crate) fn new() -> Self { | 25 | pub(crate) fn new() -> Self { |
| 28 | unsafe { | ||
| 29 | TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table { | ||
| 30 | p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(), | ||
| 31 | p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(), | ||
| 32 | evt_queue: ptr::null_mut(), | ||
| 33 | }); | ||
| 34 | } | ||
| 35 | |||
| 36 | Self { phantom: PhantomData } | 26 | Self { phantom: PhantomData } |
| 37 | } | 27 | } |
| 38 | 28 | ||
diff --git a/embassy-stm32-wpan/src/sub/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs index 1f2ecac2e..da05ad1dd 100644 --- a/embassy-stm32-wpan/src/sub/mm.rs +++ b/embassy-stm32-wpan/src/sub/mm.rs | |||
| @@ -4,20 +4,21 @@ use core::marker::PhantomData; | |||
| 4 | use core::mem::MaybeUninit; | 4 | use core::mem::MaybeUninit; |
| 5 | use core::task::Poll; | 5 | use core::task::Poll; |
| 6 | 6 | ||
| 7 | use aligned::{Aligned, A4}; | ||
| 7 | use cortex_m::interrupt; | 8 | use cortex_m::interrupt; |
| 8 | use embassy_stm32::ipcc::Ipcc; | 9 | use embassy_stm32::ipcc::Ipcc; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 10 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 11 | ||
| 11 | use crate::consts::POOL_SIZE; | 12 | use crate::consts::POOL_SIZE; |
| 12 | use crate::evt::EvtPacket; | 13 | use crate::evt::EvtPacket; |
| 13 | use crate::tables::{ | 14 | #[cfg(feature = "ble")] |
| 14 | MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE, | 15 | use crate::tables::BLE_SPARE_EVT_BUF; |
| 15 | }; | 16 | use crate::tables::{MemManagerTable, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE}; |
| 16 | use crate::unsafe_linked_list::LinkedListNode; | 17 | use crate::unsafe_linked_list::LinkedListNode; |
| 17 | use crate::{channels, evt}; | 18 | use crate::{channels, evt}; |
| 18 | 19 | ||
| 19 | static MM_WAKER: AtomicWaker = AtomicWaker::new(); | 20 | static MM_WAKER: AtomicWaker = AtomicWaker::new(); |
| 20 | static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 21 | static mut LOCAL_FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 21 | 22 | ||
| 22 | pub struct MemoryManager { | 23 | pub struct MemoryManager { |
| 23 | phantom: PhantomData<MemoryManager>, | 24 | phantom: PhantomData<MemoryManager>, |
| @@ -30,7 +31,10 @@ impl MemoryManager { | |||
| 30 | LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()); | 31 | LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()); |
| 31 | 32 | ||
| 32 | TL_MEM_MANAGER_TABLE.as_mut_ptr().write_volatile(MemManagerTable { | 33 | TL_MEM_MANAGER_TABLE.as_mut_ptr().write_volatile(MemManagerTable { |
| 34 | #[cfg(feature = "ble")] | ||
| 33 | spare_ble_buffer: BLE_SPARE_EVT_BUF.as_ptr().cast(), | 35 | spare_ble_buffer: BLE_SPARE_EVT_BUF.as_ptr().cast(), |
| 36 | #[cfg(not(feature = "ble"))] | ||
| 37 | spare_ble_buffer: core::ptr::null(), | ||
| 34 | spare_sys_buffer: SYS_SPARE_EVT_BUF.as_ptr().cast(), | 38 | spare_sys_buffer: SYS_SPARE_EVT_BUF.as_ptr().cast(), |
| 35 | blepool: EVT_POOL.as_ptr().cast(), | 39 | blepool: EVT_POOL.as_ptr().cast(), |
| 36 | blepoolsize: POOL_SIZE as u32, | 40 | blepoolsize: POOL_SIZE as u32, |
diff --git a/embassy-stm32-wpan/src/sub/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index af652860d..caa4845f2 100644 --- a/embassy-stm32-wpan/src/sub/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
| @@ -65,6 +65,25 @@ impl Sys { | |||
| 65 | 65 | ||
| 66 | #[cfg(feature = "mac")] | 66 | #[cfg(feature = "mac")] |
| 67 | pub async fn shci_c2_mac_802_15_4_init(&self) -> SchiCommandStatus { | 67 | pub async fn shci_c2_mac_802_15_4_init(&self) -> SchiCommandStatus { |
| 68 | use crate::tables::{ | ||
| 69 | Mac802_15_4Table, TracesTable, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, | ||
| 70 | TL_MAC_802_15_4_TABLE, TL_TRACES_TABLE, TRACES_EVT_QUEUE, | ||
| 71 | }; | ||
| 72 | |||
| 73 | unsafe { | ||
| 74 | LinkedListNode::init_head(TRACES_EVT_QUEUE.as_mut_ptr() as *mut _); | ||
| 75 | |||
| 76 | TL_TRACES_TABLE.as_mut_ptr().write_volatile(TracesTable { | ||
| 77 | traces_queue: TRACES_EVT_QUEUE.as_ptr() as *const _, | ||
| 78 | }); | ||
| 79 | |||
| 80 | TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table { | ||
| 81 | p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(), | ||
| 82 | p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(), | ||
| 83 | evt_queue: core::ptr::null_mut(), | ||
| 84 | }); | ||
| 85 | }; | ||
| 86 | |||
| 68 | self.write_and_get_response(ShciOpcode::Mac802_15_4Init, &[]).await | 87 | self.write_and_get_response(ShciOpcode::Mac802_15_4Init, &[]).await |
| 69 | } | 88 | } |
| 70 | 89 | ||
diff --git a/embassy-stm32-wpan/src/tables.rs b/embassy-stm32-wpan/src/tables.rs index 1b5dcdf2e..f2c250527 100644 --- a/embassy-stm32-wpan/src/tables.rs +++ b/embassy-stm32-wpan/src/tables.rs | |||
| @@ -4,6 +4,8 @@ use aligned::{Aligned, A4}; | |||
| 4 | use bit_field::BitField; | 4 | use bit_field::BitField; |
| 5 | 5 | ||
| 6 | use crate::cmd::{AclDataPacket, CmdPacket}; | 6 | use crate::cmd::{AclDataPacket, CmdPacket}; |
| 7 | #[cfg(feature = "mac")] | ||
| 8 | use crate::consts::C_SIZE_CMD_STRING; | ||
| 7 | use crate::consts::{POOL_SIZE, TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE}; | 9 | use crate::consts::{POOL_SIZE, TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE}; |
| 8 | use crate::unsafe_linked_list::LinkedListNode; | 10 | use crate::unsafe_linked_list::LinkedListNode; |
| 9 | 11 | ||
| @@ -80,7 +82,7 @@ impl WirelessFwInfoTable { | |||
| 80 | } | 82 | } |
| 81 | 83 | ||
| 82 | #[derive(Debug, Clone)] | 84 | #[derive(Debug, Clone)] |
| 83 | #[repr(C, align(4))] | 85 | #[repr(C)] |
| 84 | pub struct DeviceInfoTable { | 86 | pub struct DeviceInfoTable { |
| 85 | pub safe_boot_info_table: SafeBootInfoTable, | 87 | pub safe_boot_info_table: SafeBootInfoTable, |
| 86 | pub rss_info_table: RssInfoTable, | 88 | pub rss_info_table: RssInfoTable, |
| @@ -88,7 +90,7 @@ pub struct DeviceInfoTable { | |||
| 88 | } | 90 | } |
| 89 | 91 | ||
| 90 | #[derive(Debug)] | 92 | #[derive(Debug)] |
| 91 | #[repr(C, align(4))] | 93 | #[repr(C)] |
| 92 | pub struct BleTable { | 94 | pub struct BleTable { |
| 93 | pub pcmd_buffer: *mut CmdPacket, | 95 | pub pcmd_buffer: *mut CmdPacket, |
| 94 | pub pcs_buffer: *const u8, | 96 | pub pcs_buffer: *const u8, |
| @@ -97,16 +99,15 @@ pub struct BleTable { | |||
| 97 | } | 99 | } |
| 98 | 100 | ||
| 99 | #[derive(Debug)] | 101 | #[derive(Debug)] |
| 100 | #[repr(C, align(4))] | 102 | #[repr(C)] |
| 101 | pub struct ThreadTable { | 103 | pub struct ThreadTable { |
| 102 | pub nostack_buffer: *const u8, | 104 | pub nostack_buffer: *const u8, |
| 103 | pub clicmdrsp_buffer: *const u8, | 105 | pub clicmdrsp_buffer: *const u8, |
| 104 | pub otcmdrsp_buffer: *const u8, | 106 | pub otcmdrsp_buffer: *const u8, |
| 105 | } | 107 | } |
| 106 | 108 | ||
| 107 | // TODO: use later | ||
| 108 | #[derive(Debug)] | 109 | #[derive(Debug)] |
| 109 | #[repr(C, align(4))] | 110 | #[repr(C)] |
| 110 | pub struct LldTestsTable { | 111 | pub struct LldTestsTable { |
| 111 | pub clicmdrsp_buffer: *const u8, | 112 | pub clicmdrsp_buffer: *const u8, |
| 112 | pub m0cmd_buffer: *const u8, | 113 | pub m0cmd_buffer: *const u8, |
| @@ -114,7 +115,7 @@ pub struct LldTestsTable { | |||
| 114 | 115 | ||
| 115 | // TODO: use later | 116 | // TODO: use later |
| 116 | #[derive(Debug)] | 117 | #[derive(Debug)] |
| 117 | #[repr(C, align(4))] | 118 | #[repr(C)] |
| 118 | pub struct BleLldTable { | 119 | pub struct BleLldTable { |
| 119 | pub cmdrsp_buffer: *const u8, | 120 | pub cmdrsp_buffer: *const u8, |
| 120 | pub m0cmd_buffer: *const u8, | 121 | pub m0cmd_buffer: *const u8, |
| @@ -122,7 +123,7 @@ pub struct BleLldTable { | |||
| 122 | 123 | ||
| 123 | // TODO: use later | 124 | // TODO: use later |
| 124 | #[derive(Debug)] | 125 | #[derive(Debug)] |
| 125 | #[repr(C, align(4))] | 126 | #[repr(C)] |
| 126 | pub struct ZigbeeTable { | 127 | pub struct ZigbeeTable { |
| 127 | pub notif_m0_to_m4_buffer: *const u8, | 128 | pub notif_m0_to_m4_buffer: *const u8, |
| 128 | pub appli_cmd_m4_to_m0_bufer: *const u8, | 129 | pub appli_cmd_m4_to_m0_bufer: *const u8, |
| @@ -130,14 +131,14 @@ pub struct ZigbeeTable { | |||
| 130 | } | 131 | } |
| 131 | 132 | ||
| 132 | #[derive(Debug)] | 133 | #[derive(Debug)] |
| 133 | #[repr(C, align(4))] | 134 | #[repr(C)] |
| 134 | pub struct SysTable { | 135 | pub struct SysTable { |
| 135 | pub pcmd_buffer: *mut CmdPacket, | 136 | pub pcmd_buffer: *mut CmdPacket, |
| 136 | pub sys_queue: *const LinkedListNode, | 137 | pub sys_queue: *const LinkedListNode, |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 139 | #[derive(Debug)] | 140 | #[derive(Debug)] |
| 140 | #[repr(C, align(4))] | 141 | #[repr(C)] |
| 141 | pub struct MemManagerTable { | 142 | pub struct MemManagerTable { |
| 142 | pub spare_ble_buffer: *const u8, | 143 | pub spare_ble_buffer: *const u8, |
| 143 | pub spare_sys_buffer: *const u8, | 144 | pub spare_sys_buffer: *const u8, |
| @@ -152,13 +153,13 @@ pub struct MemManagerTable { | |||
| 152 | } | 153 | } |
| 153 | 154 | ||
| 154 | #[derive(Debug)] | 155 | #[derive(Debug)] |
| 155 | #[repr(C, align(4))] | 156 | #[repr(C)] |
| 156 | pub struct TracesTable { | 157 | pub struct TracesTable { |
| 157 | pub traces_queue: *const u8, | 158 | pub traces_queue: *const u8, |
| 158 | } | 159 | } |
| 159 | 160 | ||
| 160 | #[derive(Debug)] | 161 | #[derive(Debug)] |
| 161 | #[repr(C, align(4))] | 162 | #[repr(C)] |
| 162 | pub struct Mac802_15_4Table { | 163 | pub struct Mac802_15_4Table { |
| 163 | pub p_cmdrsp_buffer: *const u8, | 164 | pub p_cmdrsp_buffer: *const u8, |
| 164 | pub p_notack_buffer: *const u8, | 165 | pub p_notack_buffer: *const u8, |
| @@ -176,6 +177,9 @@ pub struct RefTable { | |||
| 176 | pub mem_manager_table: *const MemManagerTable, | 177 | pub mem_manager_table: *const MemManagerTable, |
| 177 | pub traces_table: *const TracesTable, | 178 | pub traces_table: *const TracesTable, |
| 178 | pub mac_802_15_4_table: *const Mac802_15_4Table, | 179 | pub mac_802_15_4_table: *const Mac802_15_4Table, |
| 180 | pub zigbee_table: *const ZigbeeTable, | ||
| 181 | pub lld_tests_table: *const LldTestsTable, | ||
| 182 | pub ble_lld_table: *const BleLldTable, | ||
| 179 | } | 183 | } |
| 180 | 184 | ||
| 181 | // --------------------- ref table --------------------- | 185 | // --------------------- ref table --------------------- |
| @@ -183,57 +187,57 @@ pub struct RefTable { | |||
| 183 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); | 187 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); |
| 184 | 188 | ||
| 185 | #[link_section = "MB_MEM1"] | 189 | #[link_section = "MB_MEM1"] |
| 186 | pub static mut TL_DEVICE_INFO_TABLE: MaybeUninit<DeviceInfoTable> = MaybeUninit::uninit(); | 190 | pub static mut TL_DEVICE_INFO_TABLE: Aligned<A4, MaybeUninit<DeviceInfoTable>> = Aligned(MaybeUninit::uninit()); |
| 187 | 191 | ||
| 188 | #[link_section = "MB_MEM1"] | 192 | #[link_section = "MB_MEM1"] |
| 189 | pub static mut TL_BLE_TABLE: MaybeUninit<BleTable> = MaybeUninit::uninit(); | 193 | pub static mut TL_BLE_TABLE: Aligned<A4, MaybeUninit<BleTable>> = Aligned(MaybeUninit::uninit()); |
| 190 | 194 | ||
| 191 | #[link_section = "MB_MEM1"] | 195 | #[link_section = "MB_MEM1"] |
| 192 | pub static mut TL_THREAD_TABLE: MaybeUninit<ThreadTable> = MaybeUninit::uninit(); | 196 | pub static mut TL_THREAD_TABLE: Aligned<A4, MaybeUninit<ThreadTable>> = Aligned(MaybeUninit::uninit()); |
| 193 | 197 | ||
| 194 | // #[link_section = "MB_MEM1"] | 198 | #[link_section = "MB_MEM1"] |
| 195 | // pub static mut TL_LLD_TESTS_TABLE: MaybeUninit<LldTestTable> = MaybeUninit::uninit(); | 199 | pub static mut TL_LLD_TESTS_TABLE: Aligned<A4, MaybeUninit<LldTestsTable>> = Aligned(MaybeUninit::uninit()); |
| 196 | 200 | ||
| 197 | // #[link_section = "MB_MEM1"] | 201 | #[link_section = "MB_MEM1"] |
| 198 | // pub static mut TL_BLE_LLD_TABLE: MaybeUninit<BleLldTable> = MaybeUninit::uninit(); | 202 | pub static mut TL_BLE_LLD_TABLE: Aligned<A4, MaybeUninit<BleLldTable>> = Aligned(MaybeUninit::uninit()); |
| 199 | 203 | ||
| 200 | #[link_section = "MB_MEM1"] | 204 | #[link_section = "MB_MEM1"] |
| 201 | pub static mut TL_SYS_TABLE: MaybeUninit<SysTable> = MaybeUninit::uninit(); | 205 | pub static mut TL_SYS_TABLE: Aligned<A4, MaybeUninit<SysTable>> = Aligned(MaybeUninit::uninit()); |
| 202 | 206 | ||
| 203 | #[link_section = "MB_MEM1"] | 207 | #[link_section = "MB_MEM1"] |
| 204 | pub static mut TL_MEM_MANAGER_TABLE: MaybeUninit<MemManagerTable> = MaybeUninit::uninit(); | 208 | pub static mut TL_MEM_MANAGER_TABLE: Aligned<A4, MaybeUninit<MemManagerTable>> = Aligned(MaybeUninit::uninit()); |
| 205 | 209 | ||
| 206 | #[link_section = "MB_MEM1"] | 210 | #[link_section = "MB_MEM1"] |
| 207 | pub static mut TL_TRACES_TABLE: MaybeUninit<TracesTable> = MaybeUninit::uninit(); | 211 | pub static mut TL_TRACES_TABLE: Aligned<A4, MaybeUninit<TracesTable>> = Aligned(MaybeUninit::uninit()); |
| 208 | 212 | ||
| 209 | #[link_section = "MB_MEM1"] | 213 | #[link_section = "MB_MEM1"] |
| 210 | pub static mut TL_MAC_802_15_4_TABLE: MaybeUninit<Mac802_15_4Table> = MaybeUninit::uninit(); | 214 | pub static mut TL_MAC_802_15_4_TABLE: Aligned<A4, MaybeUninit<Mac802_15_4Table>> = Aligned(MaybeUninit::uninit()); |
| 211 | 215 | ||
| 212 | // #[link_section = "MB_MEM1"] | 216 | #[link_section = "MB_MEM1"] |
| 213 | // pub static mut TL_ZIGBEE_TABLE: MaybeUninit<ZigbeeTable> = MaybeUninit::uninit(); | 217 | pub static mut TL_ZIGBEE_TABLE: Aligned<A4, MaybeUninit<ZigbeeTable>> = Aligned(MaybeUninit::uninit()); |
| 214 | 218 | ||
| 215 | // --------------------- tables --------------------- | 219 | // --------------------- tables --------------------- |
| 216 | #[link_section = "MB_MEM1"] | 220 | #[link_section = "MB_MEM1"] |
| 217 | pub static mut FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 221 | pub static mut FREE_BUF_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 218 | 222 | ||
| 219 | #[allow(dead_code)] | 223 | #[allow(dead_code)] |
| 220 | #[link_section = "MB_MEM1"] | 224 | #[link_section = "MB_MEM1"] |
| 221 | pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 225 | pub static mut TRACES_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 222 | 226 | ||
| 223 | #[link_section = "MB_MEM2"] | 227 | #[link_section = "MB_MEM2"] |
| 224 | pub static mut CS_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> = | 228 | pub static mut CS_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> = |
| 225 | MaybeUninit::uninit(); | 229 | Aligned(MaybeUninit::uninit()); |
| 226 | 230 | ||
| 227 | #[link_section = "MB_MEM2"] | 231 | #[link_section = "MB_MEM2"] |
| 228 | pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 232 | pub static mut EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 229 | 233 | ||
| 230 | #[link_section = "MB_MEM2"] | 234 | #[link_section = "MB_MEM2"] |
| 231 | pub static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 235 | pub static mut SYSTEM_EVT_QUEUE: Aligned<A4, MaybeUninit<LinkedListNode>> = Aligned(MaybeUninit::uninit()); |
| 232 | 236 | ||
| 233 | // --------------------- app tables --------------------- | 237 | // --------------------- app tables --------------------- |
| 234 | #[cfg(feature = "mac")] | 238 | #[cfg(feature = "mac")] |
| 235 | #[link_section = "MB_MEM2"] | 239 | #[link_section = "MB_MEM2"] |
| 236 | pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 240 | pub static mut MAC_802_15_4_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); |
| 237 | 241 | ||
| 238 | #[cfg(feature = "mac")] | 242 | #[cfg(feature = "mac")] |
| 239 | #[link_section = "MB_MEM2"] | 243 | #[link_section = "MB_MEM2"] |
| @@ -242,23 +246,31 @@ pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit< | |||
| 242 | > = MaybeUninit::uninit(); | 246 | > = MaybeUninit::uninit(); |
| 243 | 247 | ||
| 244 | #[link_section = "MB_MEM2"] | 248 | #[link_section = "MB_MEM2"] |
| 245 | pub static mut EVT_POOL: MaybeUninit<Aligned<A4, [u8; POOL_SIZE]>> = MaybeUninit::uninit(); | 249 | pub static mut EVT_POOL: Aligned<A4, MaybeUninit<[u8; POOL_SIZE]>> = Aligned(MaybeUninit::uninit()); |
| 250 | |||
| 251 | #[link_section = "MB_MEM2"] | ||
| 252 | pub static mut SYS_CMD_BUF: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); | ||
| 246 | 253 | ||
| 247 | #[link_section = "MB_MEM2"] | 254 | #[link_section = "MB_MEM2"] |
| 248 | pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 255 | pub static mut SYS_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 256 | Aligned(MaybeUninit::uninit()); | ||
| 249 | 257 | ||
| 258 | #[cfg(feature = "mac")] | ||
| 250 | #[link_section = "MB_MEM2"] | 259 | #[link_section = "MB_MEM2"] |
| 251 | pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = | 260 | pub static mut MAC_802_15_4_CNFINDNOT: Aligned<A4, MaybeUninit<[u8; C_SIZE_CMD_STRING]>> = |
| 252 | MaybeUninit::uninit(); | 261 | Aligned(MaybeUninit::uninit()); |
| 253 | 262 | ||
| 263 | #[cfg(feature = "ble")] | ||
| 254 | #[link_section = "MB_MEM1"] | 264 | #[link_section = "MB_MEM1"] |
| 255 | pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 265 | pub static mut BLE_CMD_BUFFER: Aligned<A4, MaybeUninit<CmdPacket>> = Aligned(MaybeUninit::uninit()); |
| 256 | 266 | ||
| 267 | #[cfg(feature = "ble")] | ||
| 257 | #[link_section = "MB_MEM2"] | 268 | #[link_section = "MB_MEM2"] |
| 258 | pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = | 269 | pub static mut BLE_SPARE_EVT_BUF: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> = |
| 259 | MaybeUninit::uninit(); | 270 | Aligned(MaybeUninit::uninit()); |
| 260 | 271 | ||
| 272 | #[cfg(feature = "ble")] | ||
| 261 | #[link_section = "MB_MEM2"] | 273 | #[link_section = "MB_MEM2"] |
| 262 | // fuck these "magic" numbers from ST ---v---v | 274 | // fuck these "magic" numbers from ST ---v---v |
| 263 | pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> = | 275 | pub static mut HCI_ACL_DATA_BUFFER: Aligned<A4, MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> = |
| 264 | MaybeUninit::uninit(); | 276 | Aligned(MaybeUninit::uninit()); |
diff --git a/examples/stm32wb/src/bin/tl_mbox_mac.rs b/examples/stm32wb/src/bin/tl_mbox_mac.rs index f67be4682..5931c392b 100644 --- a/examples/stm32wb/src/bin/tl_mbox_mac.rs +++ b/examples/stm32wb/src/bin/tl_mbox_mac.rs | |||
| @@ -6,6 +6,7 @@ use defmt::*; | |||
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::bind_interrupts; | 7 | use embassy_stm32::bind_interrupts; |
| 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 8 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 9 | use embassy_stm32_wpan::sub::mm; | ||
| 9 | use embassy_stm32_wpan::TlMbox; | 10 | use embassy_stm32_wpan::TlMbox; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| 11 | 12 | ||
| @@ -14,8 +15,13 @@ bind_interrupts!(struct Irqs{ | |||
| 14 | IPCC_C1_TX => TransmitInterruptHandler; | 15 | IPCC_C1_TX => TransmitInterruptHandler; |
| 15 | }); | 16 | }); |
| 16 | 17 | ||
| 18 | #[embassy_executor::task] | ||
| 19 | async fn run_mm_queue(memory_manager: mm::MemoryManager) { | ||
| 20 | memory_manager.run_queue().await; | ||
| 21 | } | ||
| 22 | |||
| 17 | #[embassy_executor::main] | 23 | #[embassy_executor::main] |
| 18 | async fn main(_spawner: Spawner) { | 24 | async fn main(spawner: Spawner) { |
| 19 | /* | 25 | /* |
| 20 | How to make this work: | 26 | How to make this work: |
| 21 | 27 | ||
| @@ -46,9 +52,13 @@ async fn main(_spawner: Spawner) { | |||
| 46 | let config = Config::default(); | 52 | let config = Config::default(); |
| 47 | let mbox = TlMbox::init(p.IPCC, Irqs, config); | 53 | let mbox = TlMbox::init(p.IPCC, Irqs, config); |
| 48 | 54 | ||
| 55 | spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap(); | ||
| 56 | |||
| 49 | let sys_event = mbox.sys_subsystem.read().await; | 57 | let sys_event = mbox.sys_subsystem.read().await; |
| 50 | info!("sys event: {}", sys_event.payload()); | 58 | info!("sys event: {}", sys_event.payload()); |
| 51 | 59 | ||
| 60 | core::mem::drop(sys_event); | ||
| 61 | |||
| 52 | let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; | 62 | let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await; |
| 53 | info!("initialized mac: {}", result); | 63 | info!("initialized mac: {}", result); |
| 54 | 64 | ||
