diff options
| author | goueslati <[email protected]> | 2023-05-26 11:26:58 +0100 |
|---|---|---|
| committer | goueslati <[email protected]> | 2023-05-26 11:26:58 +0100 |
| commit | 66304a102d628f2e61f9e38bb95eb11a2663335d (patch) | |
| tree | 8fc7ebe914afb54dd37e46e910a49fb4a4efa928 | |
| parent | 859e539f85c7f4770050cc11f83fe1f6d040cd1d (diff) | |
Revert "Merge branch 'tl_mbox' into ipcc"
This reverts commit 859e539f85c7f4770050cc11f83fe1f6d040cd1d, reversing
changes made to 984cd47b417a7bab986ff11b589b88fcae2940b9.
| -rw-r--r-- | embassy-stm32/Cargo.toml | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/ble.rs | 11 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/channels.rs | 144 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/mac_802_15_4.rs | 82 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/mm.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/mod.rs | 90 | ||||
| -rw-r--r-- | embassy-stm32/src/tl_mbox/sys.rs | 1 |
7 files changed, 74 insertions, 266 deletions
diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 653f328c4..0d7e03bf5 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml | |||
| @@ -110,16 +110,6 @@ unstable-pac = [] | |||
| 110 | # Implement embedded-hal-async traits if `nightly` is set as well. | 110 | # Implement embedded-hal-async traits if `nightly` is set as well. |
| 111 | unstable-traits = ["embedded-hal-1", "dep:embedded-hal-nb"] | 111 | unstable-traits = ["embedded-hal-1", "dep:embedded-hal-nb"] |
| 112 | 112 | ||
| 113 | # stm32wb specific | ||
| 114 | # support for wireless stacks | ||
| 115 | ble = [] | ||
| 116 | thread = [] | ||
| 117 | lld-tests = [] | ||
| 118 | ble-lld = [] | ||
| 119 | mac-802_15_4 = [] | ||
| 120 | zigbee = [] | ||
| 121 | traces = [] | ||
| 122 | |||
| 123 | # Chip-selection features | 113 | # Chip-selection features |
| 124 | stm32c011d6 = [ "stm32-metapac/stm32c011d6" ] | 114 | stm32c011d6 = [ "stm32-metapac/stm32c011d6" ] |
| 125 | stm32c011f4 = [ "stm32-metapac/stm32c011f4" ] | 115 | stm32c011f4 = [ "stm32-metapac/stm32c011f4" ] |
diff --git a/embassy-stm32/src/tl_mbox/ble.rs b/embassy-stm32/src/tl_mbox/ble.rs index 0699d1867..5cc0bb200 100644 --- a/embassy-stm32/src/tl_mbox/ble.rs +++ b/embassy-stm32/src/tl_mbox/ble.rs | |||
| @@ -65,15 +65,4 @@ impl Ble { | |||
| 65 | 65 | ||
| 66 | Ipcc::c1_set_flag_channel(channels::cpu1::IPCC_BLE_CMD_CHANNEL); | 66 | Ipcc::c1_set_flag_channel(channels::cpu1::IPCC_BLE_CMD_CHANNEL); |
| 67 | } | 67 | } |
| 68 | |||
| 69 | pub(crate) fn send_acl_data() { | ||
| 70 | unsafe { | ||
| 71 | (*(*TL_REF_TABLE.assume_init().ble_table).phci_acl_data_buffer) | ||
| 72 | .acl_data_serial | ||
| 73 | .ty = TlPacketType::AclData as u8; | ||
| 74 | } | ||
| 75 | |||
| 76 | Ipcc::c1_set_flag_channel(channels::Cpu1Channel::HciAclData.into()); | ||
| 77 | Ipcc::c1_set_tx_channel(channels::Cpu1Channel::HciAclData.into(), true); | ||
| 78 | } | ||
| 79 | } | 68 | } |
diff --git a/embassy-stm32/src/tl_mbox/channels.rs b/embassy-stm32/src/tl_mbox/channels.rs index 94e97230f..aaa6ce177 100644 --- a/embassy-stm32/src/tl_mbox/channels.rs +++ b/embassy-stm32/src/tl_mbox/channels.rs | |||
| @@ -49,104 +49,56 @@ | |||
| 49 | //! | | | 49 | //! | | |
| 50 | //! | 50 | //! |
| 51 | 51 | ||
| 52 | use crate::ipcc::IpccChannel; | 52 | pub mod cpu1 { |
| 53 | use crate::ipcc::IpccChannel; | ||
| 53 | 54 | ||
| 54 | pub enum Cpu1Channel { | 55 | // Not used currently but reserved |
| 55 | BleCmd, | 56 | pub const IPCC_BLE_CMD_CHANNEL: IpccChannel = IpccChannel::Channel1; |
| 56 | SystemCmdRsp, | 57 | // Not used currently but reserved |
| 57 | #[cfg(feature = "thread")] | 58 | pub const IPCC_SYSTEM_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel2; |
| 58 | ThreadOtCmdRsp, | 59 | #[allow(dead_code)] // Not used currently but reserved |
| 59 | #[cfg(feature = "zigbee")] | 60 | pub const IPCC_THREAD_OT_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 60 | ZigbeeCmdAppli, | 61 | #[allow(dead_code)] // Not used currently but reserved |
| 61 | MmReleaseBuffer, | 62 | pub const IPCC_ZIGBEE_CMD_APPLI_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 62 | #[cfg(feature = "mac-802_15_4")] | 63 | #[allow(dead_code)] // Not used currently but reserved |
| 63 | Mac802_15_4cmdRsp, | 64 | pub const IPCC_MAC_802_15_4_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 64 | #[cfg(feature = "thread")] | 65 | // Not used currently but reserved |
| 65 | ThreadCliCmd, | 66 | pub const IPCC_MM_RELEASE_BUFFER_CHANNEL: IpccChannel = IpccChannel::Channel4; |
| 66 | #[cfg(feature = "lld-tests")] | 67 | #[allow(dead_code)] // Not used currently but reserved |
| 67 | LldTestsCliCmd, | 68 | pub const IPCC_THREAD_CLI_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 68 | #[cfg(feature = "ble-lld")] | 69 | #[allow(dead_code)] // Not used currently but reserved |
| 69 | BleLldCmd, | 70 | pub const IPCC_LLDTESTS_CLI_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 70 | HciAclData, | 71 | #[allow(dead_code)] // Not used currently but reserved |
| 72 | pub const IPCC_BLE_LLD_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5; | ||
| 73 | #[allow(dead_code)] // Not used currently but reserved | ||
| 74 | pub const IPCC_HCI_ACL_DATA_CHANNEL: IpccChannel = IpccChannel::Channel6; | ||
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | impl From<Cpu1Channel> for IpccChannel { | 77 | pub mod cpu2 { |
| 74 | fn from(value: Cpu1Channel) -> Self { | 78 | use crate::ipcc::IpccChannel; |
| 75 | match value { | ||
| 76 | Cpu1Channel::BleCmd => IpccChannel::Channel1, | ||
| 77 | Cpu1Channel::SystemCmdRsp => IpccChannel::Channel2, | ||
| 78 | #[cfg(feature = "thread")] | ||
| 79 | Cpu1Channel::ThreadOtCmdRsp => IpccChannel::Channel3, | ||
| 80 | #[cfg(feature = "zigbee")] | ||
| 81 | Cpu1Channel::ZigbeeCmdAppli => IpccChannel::Channel3, | ||
| 82 | #[cfg(feature = "mac-802_15_4")] | ||
| 83 | Cpu1Channel::Mac802_15_4cmdRsp => IpccChannel::Channel3, | ||
| 84 | Cpu1Channel::MmReleaseBuffer => IpccChannel::Channel4, | ||
| 85 | #[cfg(feature = "thread")] | ||
| 86 | Cpu1Channel::ThreadCliCmd => IpccChannel::Channel5, | ||
| 87 | #[cfg(feature = "lld-tests")] | ||
| 88 | Cpu1Channel::LldTestsCliCmd => IpccChannel::Channel5, | ||
| 89 | #[cfg(feature = "ble-lld")] | ||
| 90 | Cpu1Channel::BleLldCmd => IpccChannel::Channel5, | ||
| 91 | Cpu1Channel::HciAclData => IpccChannel::Channel6, | ||
| 92 | } | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | pub enum Cpu2Channel { | ||
| 97 | BleEvent, | ||
| 98 | SystemEvent, | ||
| 99 | #[cfg(feature = "thread")] | ||
| 100 | ThreadNotifAck, | ||
| 101 | #[cfg(feature = "zigbee")] | ||
| 102 | ZigbeeAppliNotifAck, | ||
| 103 | #[cfg(feature = "mac-802_15_4")] | ||
| 104 | Mac802_15_4NotifAck, | ||
| 105 | #[cfg(feature = "lld-tests")] | ||
| 106 | LldTestsM0Cmd, | ||
| 107 | #[cfg(feature = "ble-lld")] | ||
| 108 | BleLldM0Cmd, | ||
| 109 | #[cfg(feature = "traces")] | ||
| 110 | Traces, | ||
| 111 | #[cfg(feature = "thread")] | ||
| 112 | ThreadCliNotifAck, | ||
| 113 | #[cfg(feature = "lld-tests")] | ||
| 114 | LldTestsCliRsp, | ||
| 115 | #[cfg(feature = "ble-lld")] | ||
| 116 | BleLldCliRsp, | ||
| 117 | #[cfg(feature = "ble-lld")] | ||
| 118 | BleLldRsp, | ||
| 119 | #[cfg(feature = "zigbee")] | ||
| 120 | ZigbeeM0Request, | ||
| 121 | } | ||
| 122 | 79 | ||
| 123 | impl From<Cpu2Channel> for IpccChannel { | 80 | pub const IPCC_BLE_EVENT_CHANNEL: IpccChannel = IpccChannel::Channel1; |
| 124 | fn from(value: Cpu2Channel) -> Self { | 81 | pub const IPCC_SYSTEM_EVENT_CHANNEL: IpccChannel = IpccChannel::Channel2; |
| 125 | match value { | 82 | #[allow(dead_code)] // Not used currently but reserved |
| 126 | Cpu2Channel::BleEvent => IpccChannel::Channel1, | 83 | pub const IPCC_THREAD_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 127 | Cpu2Channel::SystemEvent => IpccChannel::Channel2, | 84 | #[allow(dead_code)] // Not used currently but reserved |
| 128 | #[cfg(feature = "thread")] | 85 | pub const IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 129 | Cpu2Channel::ThreadNotifAck => IpccChannel::Channel3, | 86 | #[allow(dead_code)] // Not used currently but reserved |
| 130 | #[cfg(feature = "zigbee")] | 87 | pub const IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 131 | Cpu2Channel::ZigbeeAppliNotifAck => IpccChannel::Channel3, | 88 | #[allow(dead_code)] // Not used currently but reserved |
| 132 | #[cfg(feature = "mac-802_15_4")] | 89 | pub const IPCC_LDDTESTS_M0_CMD_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 133 | Cpu2Channel::Mac802_15_4NotifAck => IpccChannel::Channel3, | 90 | #[allow(dead_code)] // Not used currently but reserved |
| 134 | #[cfg(feature = "lld-tests")] | 91 | pub const IPCC_BLE_LLD_M0_CMD_CHANNEL: IpccChannel = IpccChannel::Channel3; |
| 135 | Cpu2Channel::LldTestsM0Cmd => IpccChannel::Channel3, | 92 | #[allow(dead_code)] // Not used currently but reserved |
| 136 | #[cfg(feature = "ble-lld")] | 93 | pub const IPCC_TRACES_CHANNEL: IpccChannel = IpccChannel::Channel4; |
| 137 | Cpu2Channel::BleLldM0Cmd => IpccChannel::Channel3, | 94 | #[allow(dead_code)] // Not used currently but reserved |
| 138 | #[cfg(feature = "traces")] | 95 | pub const IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 139 | Cpu2Channel::Traces => IpccChannel::Channel4, | 96 | #[allow(dead_code)] // Not used currently but reserved |
| 140 | #[cfg(feature = "thread")] | 97 | pub const IPCC_LLDTESTS_CLI_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 141 | Cpu2Channel::ThreadCliNotifAck => IpccChannel::Channel5, | 98 | #[allow(dead_code)] // Not used currently but reserved |
| 142 | #[cfg(feature = "lld-tests")] | 99 | pub const IPCC_BLE_LLD_CLI_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 143 | Cpu2Channel::LldTestsCliRsp => IpccChannel::Channel5, | 100 | #[allow(dead_code)] // Not used currently but reserved |
| 144 | #[cfg(feature = "ble-lld")] | 101 | pub const IPCC_BLE_LLD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 145 | Cpu2Channel::BleLldCliRsp => IpccChannel::Channel5, | 102 | #[allow(dead_code)] // Not used currently but reserved |
| 146 | #[cfg(feature = "ble-lld")] | 103 | pub const IPCC_ZIGBEE_M0_REQUEST_CHANNEL: IpccChannel = IpccChannel::Channel5; |
| 147 | Cpu2Channel::BleLldRsp => IpccChannel::Channel5, | ||
| 148 | #[cfg(feature = "zigbee")] | ||
| 149 | Cpu2Channel::ZigbeeM0Request => IpccChannel::Channel5, | ||
| 150 | } | ||
| 151 | } | ||
| 152 | } | 104 | } |
diff --git a/embassy-stm32/src/tl_mbox/mac_802_15_4.rs b/embassy-stm32/src/tl_mbox/mac_802_15_4.rs deleted file mode 100644 index 19f951130..000000000 --- a/embassy-stm32/src/tl_mbox/mac_802_15_4.rs +++ /dev/null | |||
| @@ -1,82 +0,0 @@ | |||
| 1 | use core::mem::MaybeUninit; | ||
| 2 | |||
| 3 | use embassy_futures::block_on; | ||
| 4 | |||
| 5 | use super::cmd::{CmdPacket, CmdSerial}; | ||
| 6 | use super::consts::TlPacketType; | ||
| 7 | use super::evt::{EvtBox, EvtPacket}; | ||
| 8 | use super::unsafe_linked_list::LinkedListNode; | ||
| 9 | use super::{ | ||
| 10 | channels, Mac802_15_4Table, EVT_QUEUE, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_CHANNEL, | ||
| 11 | TL_MAC_802_15_4_TABLE, TL_REF_TABLE, | ||
| 12 | }; | ||
| 13 | use crate::ipcc::Ipcc; | ||
| 14 | |||
| 15 | pub struct Mac802_15_4; | ||
| 16 | |||
| 17 | impl Mac802_15_4 { | ||
| 18 | pub(crate) fn init(ipcc: &mut Ipcc) -> Self { | ||
| 19 | unsafe { | ||
| 20 | LinkedListNode::init_head(EVT_QUEUE.as_mut_ptr()); | ||
| 21 | |||
| 22 | TL_MAC_802_15_4_TABLE = MaybeUninit::new(Mac802_15_4Table { | ||
| 23 | pcmd_rsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(), | ||
| 24 | pnotack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(), | ||
| 25 | evt_queue: EVT_QUEUE.as_ptr().cast(), | ||
| 26 | }); | ||
| 27 | } | ||
| 28 | |||
| 29 | ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), true); | ||
| 30 | |||
| 31 | Self | ||
| 32 | } | ||
| 33 | |||
| 34 | pub(crate) fn notif_evt_handler(ipcc: &mut Ipcc) { | ||
| 35 | unsafe { | ||
| 36 | let notif_buffer: *mut EvtPacket = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pnotack_buffer.cast(); | ||
| 37 | let event = EvtBox::new(notif_buffer); | ||
| 38 | |||
| 39 | block_on(TL_CHANNEL.send(event)); | ||
| 40 | } | ||
| 41 | |||
| 42 | ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), false); | ||
| 43 | } | ||
| 44 | |||
| 45 | pub(crate) fn cmd_evt_handler(ipcc: &mut Ipcc) { | ||
| 46 | unsafe { | ||
| 47 | let _notif_buffer = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer; | ||
| 48 | |||
| 49 | // NOTE: ST's HAL does nothing with this buffer, ?????? | ||
| 50 | } | ||
| 51 | |||
| 52 | ipcc.c1_set_tx_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into(), false); | ||
| 53 | } | ||
| 54 | |||
| 55 | pub(crate) fn send_cmd(ipcc: &mut Ipcc, buf: &[u8]) { | ||
| 56 | unsafe { | ||
| 57 | let pcmd_buffer: *mut CmdPacket = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer.cast(); | ||
| 58 | let pcmd_serial: *mut CmdSerial = &mut (*pcmd_buffer).cmd_serial; | ||
| 59 | let pcmd_serial_buf: *mut u8 = pcmd_serial.cast(); | ||
| 60 | |||
| 61 | core::ptr::copy(buf.as_ptr(), pcmd_serial_buf, buf.len()); | ||
| 62 | |||
| 63 | let cmd_packet: &mut CmdPacket = | ||
| 64 | &mut *(*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer.cast(); | ||
| 65 | cmd_packet.cmd_serial.ty = TlPacketType::OtCmd as u8; | ||
| 66 | } | ||
| 67 | |||
| 68 | ipcc.c1_set_flag_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into()); | ||
| 69 | ipcc.c1_set_tx_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into(), true); | ||
| 70 | } | ||
| 71 | |||
| 72 | pub(crate) fn send_ack(ipcc: &mut Ipcc) { | ||
| 73 | // TODO | ||
| 74 | unsafe { | ||
| 75 | let packet: &mut CmdPacket = &mut *(*TL_REF_TABLE.assume_init().mac_802_15_4_table).pnotack_buffer.cast(); | ||
| 76 | packet.cmd_serial.ty = TlPacketType::OtAck as u8; | ||
| 77 | } | ||
| 78 | |||
| 79 | ipcc.c1_clear_flag_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into()); | ||
| 80 | ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), true); | ||
| 81 | } | ||
| 82 | } | ||
diff --git a/embassy-stm32/src/tl_mbox/mm.rs b/embassy-stm32/src/tl_mbox/mm.rs index cb161ce58..6e0818cf1 100644 --- a/embassy-stm32/src/tl_mbox/mm.rs +++ b/embassy-stm32/src/tl_mbox/mm.rs | |||
| @@ -11,7 +11,7 @@ use crate::ipcc::Ipcc; | |||
| 11 | pub struct MemoryManager; | 11 | pub struct MemoryManager; |
| 12 | 12 | ||
| 13 | impl MemoryManager { | 13 | impl MemoryManager { |
| 14 | pub fn init() -> Self { | 14 | pub fn new() -> Self { |
| 15 | unsafe { | 15 | unsafe { |
| 16 | LinkedListNode::init_head(FREE_BUFF_QUEUE.as_mut_ptr()); | 16 | LinkedListNode::init_head(FREE_BUFF_QUEUE.as_mut_ptr()); |
| 17 | LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()); | 17 | LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr()); |
diff --git a/embassy-stm32/src/tl_mbox/mod.rs b/embassy-stm32/src/tl_mbox/mod.rs index fe366f6d8..1c927efa0 100644 --- a/embassy-stm32/src/tl_mbox/mod.rs +++ b/embassy-stm32/src/tl_mbox/mod.rs | |||
| @@ -5,12 +5,9 @@ use embassy_cortex_m::interrupt::{Interrupt, InterruptExt}; | |||
| 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; | 5 | use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex; |
| 6 | use embassy_sync::channel::Channel; | 6 | use embassy_sync::channel::Channel; |
| 7 | 7 | ||
| 8 | #[cfg(feature = "ble")] | ||
| 9 | use self::ble::Ble; | 8 | use self::ble::Ble; |
| 10 | use self::cmd::{AclDataPacket, CmdPacket}; | 9 | use self::cmd::{AclDataPacket, CmdPacket}; |
| 11 | use self::evt::{CsEvt, EvtBox}; | 10 | use self::evt::{CsEvt, EvtBox}; |
| 12 | #[cfg(feature = "mac-802_15_4")] | ||
| 13 | use self::mac_802_15_4::Mac802_15_4; | ||
| 14 | use self::mm::MemoryManager; | 11 | use self::mm::MemoryManager; |
| 15 | use self::shci::{shci_ble_init, ShciBleInitCmdParam}; | 12 | use self::shci::{shci_ble_init, ShciBleInitCmdParam}; |
| 16 | use self::sys::Sys; | 13 | use self::sys::Sys; |
| @@ -18,6 +15,7 @@ use self::unsafe_linked_list::LinkedListNode; | |||
| 18 | use crate::interrupt; | 15 | use crate::interrupt; |
| 19 | use crate::ipcc::{Config, Ipcc}; | 16 | use crate::ipcc::{Config, Ipcc}; |
| 20 | 17 | ||
| 18 | mod ble; | ||
| 21 | mod channels; | 19 | mod channels; |
| 22 | mod cmd; | 20 | mod cmd; |
| 23 | mod consts; | 21 | mod consts; |
| @@ -27,11 +25,6 @@ mod shci; | |||
| 27 | mod sys; | 25 | mod sys; |
| 28 | mod unsafe_linked_list; | 26 | mod unsafe_linked_list; |
| 29 | 27 | ||
| 30 | #[cfg(feature = "ble")] | ||
| 31 | mod ble; | ||
| 32 | #[cfg(feature = "mac-802_15_4")] | ||
| 33 | mod mac_802_15_4; | ||
| 34 | |||
| 35 | pub type PacketHeader = LinkedListNode; | 28 | pub type PacketHeader = LinkedListNode; |
| 36 | 29 | ||
| 37 | const TL_PACKET_HEADER_SIZE: usize = core::mem::size_of::<PacketHeader>(); | 30 | const TL_PACKET_HEADER_SIZE: usize = core::mem::size_of::<PacketHeader>(); |
| @@ -219,8 +212,8 @@ struct TracesTable { | |||
| 219 | 212 | ||
| 220 | #[repr(C, packed)] | 213 | #[repr(C, packed)] |
| 221 | struct Mac802_15_4Table { | 214 | struct Mac802_15_4Table { |
| 222 | pcmd_rsp_buffer: *mut u8, | 215 | pcmd_rsp_buffer: *const u8, |
| 223 | pnotack_buffer: *mut u8, | 216 | pnotack_buffer: *const u8, |
| 224 | evt_queue: *const u8, | 217 | evt_queue: *const u8, |
| 225 | } | 218 | } |
| 226 | 219 | ||
| @@ -240,7 +233,6 @@ pub struct RefTable { | |||
| 240 | ble_lld_table: *const BleLldTable, | 233 | ble_lld_table: *const BleLldTable, |
| 241 | } | 234 | } |
| 242 | 235 | ||
| 243 | // -------------------- reference table -------------------- | ||
| 244 | #[link_section = "TL_REF_TABLE"] | 236 | #[link_section = "TL_REF_TABLE"] |
| 245 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); | 237 | pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit(); |
| 246 | 238 | ||
| @@ -274,50 +266,38 @@ static mut TL_MAC_802_15_4_TABLE: MaybeUninit<Mac802_15_4Table> = MaybeUninit::u | |||
| 274 | #[link_section = "MB_MEM1"] | 266 | #[link_section = "MB_MEM1"] |
| 275 | static mut TL_ZIGBEE_TABLE: MaybeUninit<ZigbeeTable> = MaybeUninit::uninit(); | 267 | static mut TL_ZIGBEE_TABLE: MaybeUninit<ZigbeeTable> = MaybeUninit::uninit(); |
| 276 | 268 | ||
| 277 | // -------------------- tables -------------------- | 269 | #[allow(dead_code)] // Not used currently but reserved |
| 278 | #[link_section = "MB_MEM1"] | 270 | #[link_section = "MB_MEM1"] |
| 279 | static mut FREE_BUFF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 271 | static mut FREE_BUFF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| 280 | 272 | ||
| 273 | // not in shared RAM | ||
| 274 | static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | ||
| 275 | |||
| 281 | #[link_section = "MB_MEM2"] | 276 | #[link_section = "MB_MEM2"] |
| 282 | static mut CS_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]> = | 277 | static mut CS_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]> = |
| 283 | MaybeUninit::uninit(); | 278 | MaybeUninit::uninit(); |
| 284 | 279 | ||
| 285 | #[link_section = "MB_MEM1"] | 280 | #[link_section = "MB_MEM2"] |
| 286 | static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 281 | static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| 287 | 282 | ||
| 288 | #[link_section = "MB_MEM2"] | 283 | #[link_section = "MB_MEM2"] |
| 289 | static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | 284 | static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); |
| 290 | 285 | ||
| 291 | // not in shared RAM | ||
| 292 | static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit(); | ||
| 293 | |||
| 294 | // -------------------- app tables -------------------- | ||
| 295 | #[link_section = "MB_MEM2"] | ||
| 296 | static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit(); | ||
| 297 | |||
| 298 | #[link_section = "MB_MEM2"] | 286 | #[link_section = "MB_MEM2"] |
| 299 | static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 287 | static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 300 | 288 | ||
| 301 | #[link_section = "MB_MEM2"] | 289 | #[link_section = "MB_MEM2"] |
| 302 | static mut SYS_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 290 | static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit(); |
| 303 | MaybeUninit::uninit(); | ||
| 304 | |||
| 305 | #[cfg(feature = "mac-802_15_4")] | ||
| 306 | #[link_section = "MB_MEM2"] | ||
| 307 | static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | ||
| 308 | 291 | ||
| 309 | #[cfg(feature = "mac-802_15_4")] | ||
| 310 | #[link_section = "MB_MEM2"] | 292 | #[link_section = "MB_MEM2"] |
| 311 | static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 293 | static mut SYS_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = |
| 312 | MaybeUninit::uninit(); | 294 | MaybeUninit::uninit(); |
| 313 | 295 | ||
| 314 | #[cfg(feature = "ble")] | ||
| 315 | #[link_section = "MB_MEM2"] | 296 | #[link_section = "MB_MEM2"] |
| 316 | static mut BLE_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = | 297 | static mut BLE_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> = |
| 317 | MaybeUninit::uninit(); | 298 | MaybeUninit::uninit(); |
| 318 | 299 | ||
| 319 | #[cfg(feature = "ble")] | 300 | #[link_section = "MB_MEM2"] |
| 320 | #[link_section = "MB_MEM1"] | ||
| 321 | static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); | 301 | static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit(); |
| 322 | 302 | ||
| 323 | #[link_section = "MB_MEM2"] | 303 | #[link_section = "MB_MEM2"] |
| @@ -327,14 +307,10 @@ static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251 | |||
| 327 | // TODO: get a better size, this is a placeholder | 307 | // TODO: get a better size, this is a placeholder |
| 328 | pub(crate) static TL_CHANNEL: Channel<CriticalSectionRawMutex, EvtBox, 5> = Channel::new(); | 308 | pub(crate) static TL_CHANNEL: Channel<CriticalSectionRawMutex, EvtBox, 5> = Channel::new(); |
| 329 | 309 | ||
| 330 | pub struct TlMbox; | 310 | pub struct TlMbox { |
| 331 | 311 | _sys: Sys, | |
| 332 | pub enum MailboxTarget { | 312 | _ble: Ble, |
| 333 | Sys, | 313 | _mm: MemoryManager, |
| 334 | #[cfg(feature = "ble")] | ||
| 335 | Ble, | ||
| 336 | #[cfg(feature = "mac-802_15_4")] | ||
| 337 | Mac802_15_4, | ||
| 338 | } | 314 | } |
| 339 | 315 | ||
| 340 | impl TlMbox { | 316 | impl TlMbox { |
| @@ -380,14 +356,9 @@ impl TlMbox { | |||
| 380 | 356 | ||
| 381 | Ipcc::init(config); | 357 | Ipcc::init(config); |
| 382 | 358 | ||
| 383 | Sys::init(); | 359 | let _sys = Sys::new(); |
| 384 | MemoryManager::init(); | 360 | let _ble = Ble::new(); |
| 385 | 361 | let _mm = MemoryManager::new(); | |
| 386 | #[cfg(feature = "ble")] | ||
| 387 | Ble::init(); | ||
| 388 | |||
| 389 | #[cfg(feature = "mac-802_15_4")] | ||
| 390 | Mac802_15_4::init(); | ||
| 391 | 362 | ||
| 392 | // enable interrupts | 363 | // enable interrupts |
| 393 | unsafe { crate::interrupt::IPCC_C1_RX::steal() }.unpend(); | 364 | unsafe { crate::interrupt::IPCC_C1_RX::steal() }.unpend(); |
| @@ -396,7 +367,7 @@ impl TlMbox { | |||
| 396 | unsafe { crate::interrupt::IPCC_C1_RX::steal() }.enable(); | 367 | unsafe { crate::interrupt::IPCC_C1_RX::steal() }.enable(); |
| 397 | unsafe { crate::interrupt::IPCC_C1_TX::steal() }.enable(); | 368 | unsafe { crate::interrupt::IPCC_C1_TX::steal() }.enable(); |
| 398 | 369 | ||
| 399 | Self | 370 | TlMbox { _sys, _ble, _mm } |
| 400 | } | 371 | } |
| 401 | 372 | ||
| 402 | pub fn wireless_fw_info(&self) -> Option<WirelessFwInfoTable> { | 373 | pub fn wireless_fw_info(&self) -> Option<WirelessFwInfoTable> { |
| @@ -410,30 +381,17 @@ impl TlMbox { | |||
| 410 | } | 381 | } |
| 411 | } | 382 | } |
| 412 | 383 | ||
| 413 | #[cfg(feature = "ble")] | ||
| 414 | pub fn shci_ble_init(&self, param: ShciBleInitCmdParam) { | 384 | pub fn shci_ble_init(&self, param: ShciBleInitCmdParam) { |
| 415 | shci_ble_init(param); | 385 | shci_ble_init(param); |
| 416 | } | 386 | } |
| 417 | 387 | ||
| 418 | pub fn send_cmd(&self, buf: &[u8], target: MailboxTarget) { | 388 | pub fn send_ble_cmd(&self, buf: &[u8]) { |
| 419 | match target { | 389 | ble::Ble::send_cmd(buf); |
| 420 | MailboxTarget::Sys => Sys::send_cmd(buf), | ||
| 421 | #[cfg(feature = "ble")] | ||
| 422 | MailboxTarget::Ble => Ble::send_cmd(buf), | ||
| 423 | #[cfg(feature = "mac-802_15_4")] | ||
| 424 | MailboxTarget::Mac802_15_4 => Mac802_15_4::send_cmd(buf), | ||
| 425 | } | ||
| 426 | } | 390 | } |
| 427 | 391 | ||
| 428 | pub fn send_ack(&self, target: MailboxTarget) { | 392 | // pub fn send_sys_cmd(&self, buf: &[u8]) { |
| 429 | match target { | 393 | // sys::Sys::send_cmd(buf); |
| 430 | #[cfg(feature = "ble")] | 394 | // } |
| 431 | MailboxTarget::Ble => Ble::send_acl_data(), | ||
| 432 | #[cfg(feature = "mac-802_15_4")] | ||
| 433 | MailboxTarget::Mac802_15_4 => Mac802_15_4::send_ack(), | ||
| 434 | MailboxTarget::Sys => { /* does nothing */ } | ||
| 435 | } | ||
| 436 | } | ||
| 437 | 395 | ||
| 438 | pub async fn read(&self) -> EvtBox { | 396 | pub async fn read(&self) -> EvtBox { |
| 439 | TL_CHANNEL.recv().await | 397 | TL_CHANNEL.recv().await |
diff --git a/embassy-stm32/src/tl_mbox/sys.rs b/embassy-stm32/src/tl_mbox/sys.rs index 4ffbe8e6a..79e257148 100644 --- a/embassy-stm32/src/tl_mbox/sys.rs +++ b/embassy-stm32/src/tl_mbox/sys.rs | |||
| @@ -70,6 +70,7 @@ impl Sys { | |||
| 70 | #[allow(dead_code)] | 70 | #[allow(dead_code)] |
| 71 | pub(crate) fn send_cmd(buf: &[u8]) { | 71 | pub(crate) fn send_cmd(buf: &[u8]) { |
| 72 | unsafe { | 72 | unsafe { |
| 73 | // TODO: check this | ||
| 73 | let cmd_buffer = &mut *(*TL_REF_TABLE.assume_init().sys_table).pcmd_buffer; | 74 | let cmd_buffer = &mut *(*TL_REF_TABLE.assume_init().sys_table).pcmd_buffer; |
| 74 | let cmd_serial: *mut CmdSerial = &mut cmd_buffer.cmd_serial; | 75 | let cmd_serial: *mut CmdSerial = &mut cmd_buffer.cmd_serial; |
| 75 | let cmd_serial_buf = cmd_serial.cast(); | 76 | let cmd_serial_buf = cmd_serial.cast(); |
