Revert "Merge branch 'tl_mbox' into ipcc"
This reverts commit859e539f85, reversing changes made to984cd47b41.
This commit is contained in:
		@@ -110,16 +110,6 @@ unstable-pac = []
 | 
			
		||||
# Implement embedded-hal-async traits if `nightly` is set as well.
 | 
			
		||||
unstable-traits = ["embedded-hal-1", "dep:embedded-hal-nb"]
 | 
			
		||||
 | 
			
		||||
# stm32wb specific
 | 
			
		||||
# support for wireless stacks
 | 
			
		||||
ble = []
 | 
			
		||||
thread = []
 | 
			
		||||
lld-tests = []
 | 
			
		||||
ble-lld = []
 | 
			
		||||
mac-802_15_4 = []
 | 
			
		||||
zigbee = []
 | 
			
		||||
traces = []
 | 
			
		||||
 | 
			
		||||
# Chip-selection features
 | 
			
		||||
stm32c011d6 = [ "stm32-metapac/stm32c011d6" ]
 | 
			
		||||
stm32c011f4 = [ "stm32-metapac/stm32c011f4" ]
 | 
			
		||||
 
 | 
			
		||||
@@ -65,15 +65,4 @@ impl Ble {
 | 
			
		||||
 | 
			
		||||
        Ipcc::c1_set_flag_channel(channels::cpu1::IPCC_BLE_CMD_CHANNEL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub(crate) fn send_acl_data() {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            (*(*TL_REF_TABLE.assume_init().ble_table).phci_acl_data_buffer)
 | 
			
		||||
                .acl_data_serial
 | 
			
		||||
                .ty = TlPacketType::AclData as u8;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Ipcc::c1_set_flag_channel(channels::Cpu1Channel::HciAclData.into());
 | 
			
		||||
        Ipcc::c1_set_tx_channel(channels::Cpu1Channel::HciAclData.into(), true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -49,104 +49,56 @@
 | 
			
		||||
//!  |                                                 |
 | 
			
		||||
//!
 | 
			
		||||
 | 
			
		||||
pub mod cpu1 {
 | 
			
		||||
    use crate::ipcc::IpccChannel;
 | 
			
		||||
 | 
			
		||||
pub enum Cpu1Channel {
 | 
			
		||||
    BleCmd,
 | 
			
		||||
    SystemCmdRsp,
 | 
			
		||||
    #[cfg(feature = "thread")]
 | 
			
		||||
    ThreadOtCmdRsp,
 | 
			
		||||
    #[cfg(feature = "zigbee")]
 | 
			
		||||
    ZigbeeCmdAppli,
 | 
			
		||||
    MmReleaseBuffer,
 | 
			
		||||
    #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
    Mac802_15_4cmdRsp,
 | 
			
		||||
    #[cfg(feature = "thread")]
 | 
			
		||||
    ThreadCliCmd,
 | 
			
		||||
    #[cfg(feature = "lld-tests")]
 | 
			
		||||
    LldTestsCliCmd,
 | 
			
		||||
    #[cfg(feature = "ble-lld")]
 | 
			
		||||
    BleLldCmd,
 | 
			
		||||
    HciAclData,
 | 
			
		||||
    // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_BLE_CMD_CHANNEL: IpccChannel = IpccChannel::Channel1;
 | 
			
		||||
    // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_SYSTEM_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel2;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_THREAD_OT_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_ZIGBEE_CMD_APPLI_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_MAC_802_15_4_CMD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_MM_RELEASE_BUFFER_CHANNEL: IpccChannel = IpccChannel::Channel4;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_THREAD_CLI_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_LLDTESTS_CLI_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_BLE_LLD_CMD_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_HCI_ACL_DATA_CHANNEL: IpccChannel = IpccChannel::Channel6;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<Cpu1Channel> for IpccChannel {
 | 
			
		||||
    fn from(value: Cpu1Channel) -> Self {
 | 
			
		||||
        match value {
 | 
			
		||||
            Cpu1Channel::BleCmd => IpccChannel::Channel1,
 | 
			
		||||
            Cpu1Channel::SystemCmdRsp => IpccChannel::Channel2,
 | 
			
		||||
            #[cfg(feature = "thread")]
 | 
			
		||||
            Cpu1Channel::ThreadOtCmdRsp => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "zigbee")]
 | 
			
		||||
            Cpu1Channel::ZigbeeCmdAppli => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
            Cpu1Channel::Mac802_15_4cmdRsp => IpccChannel::Channel3,
 | 
			
		||||
            Cpu1Channel::MmReleaseBuffer => IpccChannel::Channel4,
 | 
			
		||||
            #[cfg(feature = "thread")]
 | 
			
		||||
            Cpu1Channel::ThreadCliCmd => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "lld-tests")]
 | 
			
		||||
            Cpu1Channel::LldTestsCliCmd => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "ble-lld")]
 | 
			
		||||
            Cpu1Channel::BleLldCmd => IpccChannel::Channel5,
 | 
			
		||||
            Cpu1Channel::HciAclData => IpccChannel::Channel6,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
pub mod cpu2 {
 | 
			
		||||
    use crate::ipcc::IpccChannel;
 | 
			
		||||
 | 
			
		||||
pub enum Cpu2Channel {
 | 
			
		||||
    BleEvent,
 | 
			
		||||
    SystemEvent,
 | 
			
		||||
    #[cfg(feature = "thread")]
 | 
			
		||||
    ThreadNotifAck,
 | 
			
		||||
    #[cfg(feature = "zigbee")]
 | 
			
		||||
    ZigbeeAppliNotifAck,
 | 
			
		||||
    #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
    Mac802_15_4NotifAck,
 | 
			
		||||
    #[cfg(feature = "lld-tests")]
 | 
			
		||||
    LldTestsM0Cmd,
 | 
			
		||||
    #[cfg(feature = "ble-lld")]
 | 
			
		||||
    BleLldM0Cmd,
 | 
			
		||||
    #[cfg(feature = "traces")]
 | 
			
		||||
    Traces,
 | 
			
		||||
    #[cfg(feature = "thread")]
 | 
			
		||||
    ThreadCliNotifAck,
 | 
			
		||||
    #[cfg(feature = "lld-tests")]
 | 
			
		||||
    LldTestsCliRsp,
 | 
			
		||||
    #[cfg(feature = "ble-lld")]
 | 
			
		||||
    BleLldCliRsp,
 | 
			
		||||
    #[cfg(feature = "ble-lld")]
 | 
			
		||||
    BleLldRsp,
 | 
			
		||||
    #[cfg(feature = "zigbee")]
 | 
			
		||||
    ZigbeeM0Request,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl From<Cpu2Channel> for IpccChannel {
 | 
			
		||||
    fn from(value: Cpu2Channel) -> Self {
 | 
			
		||||
        match value {
 | 
			
		||||
            Cpu2Channel::BleEvent => IpccChannel::Channel1,
 | 
			
		||||
            Cpu2Channel::SystemEvent => IpccChannel::Channel2,
 | 
			
		||||
            #[cfg(feature = "thread")]
 | 
			
		||||
            Cpu2Channel::ThreadNotifAck => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "zigbee")]
 | 
			
		||||
            Cpu2Channel::ZigbeeAppliNotifAck => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
            Cpu2Channel::Mac802_15_4NotifAck => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "lld-tests")]
 | 
			
		||||
            Cpu2Channel::LldTestsM0Cmd => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "ble-lld")]
 | 
			
		||||
            Cpu2Channel::BleLldM0Cmd => IpccChannel::Channel3,
 | 
			
		||||
            #[cfg(feature = "traces")]
 | 
			
		||||
            Cpu2Channel::Traces => IpccChannel::Channel4,
 | 
			
		||||
            #[cfg(feature = "thread")]
 | 
			
		||||
            Cpu2Channel::ThreadCliNotifAck => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "lld-tests")]
 | 
			
		||||
            Cpu2Channel::LldTestsCliRsp => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "ble-lld")]
 | 
			
		||||
            Cpu2Channel::BleLldCliRsp => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "ble-lld")]
 | 
			
		||||
            Cpu2Channel::BleLldRsp => IpccChannel::Channel5,
 | 
			
		||||
            #[cfg(feature = "zigbee")]
 | 
			
		||||
            Cpu2Channel::ZigbeeM0Request => IpccChannel::Channel5,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    pub const IPCC_BLE_EVENT_CHANNEL: IpccChannel = IpccChannel::Channel1;
 | 
			
		||||
    pub const IPCC_SYSTEM_EVENT_CHANNEL: IpccChannel = IpccChannel::Channel2;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_THREAD_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_LDDTESTS_M0_CMD_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_BLE_LLD_M0_CMD_CHANNEL: IpccChannel = IpccChannel::Channel3;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_TRACES_CHANNEL: IpccChannel = IpccChannel::Channel4;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_LLDTESTS_CLI_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_BLE_LLD_CLI_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_BLE_LLD_RSP_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
    #[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
    pub const IPCC_ZIGBEE_M0_REQUEST_CHANNEL: IpccChannel = IpccChannel::Channel5;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,82 +0,0 @@
 | 
			
		||||
use core::mem::MaybeUninit;
 | 
			
		||||
 | 
			
		||||
use embassy_futures::block_on;
 | 
			
		||||
 | 
			
		||||
use super::cmd::{CmdPacket, CmdSerial};
 | 
			
		||||
use super::consts::TlPacketType;
 | 
			
		||||
use super::evt::{EvtBox, EvtPacket};
 | 
			
		||||
use super::unsafe_linked_list::LinkedListNode;
 | 
			
		||||
use super::{
 | 
			
		||||
    channels, Mac802_15_4Table, EVT_QUEUE, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_CHANNEL,
 | 
			
		||||
    TL_MAC_802_15_4_TABLE, TL_REF_TABLE,
 | 
			
		||||
};
 | 
			
		||||
use crate::ipcc::Ipcc;
 | 
			
		||||
 | 
			
		||||
pub struct Mac802_15_4;
 | 
			
		||||
 | 
			
		||||
impl Mac802_15_4 {
 | 
			
		||||
    pub(crate) fn init(ipcc: &mut Ipcc) -> Self {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            LinkedListNode::init_head(EVT_QUEUE.as_mut_ptr());
 | 
			
		||||
 | 
			
		||||
            TL_MAC_802_15_4_TABLE = MaybeUninit::new(Mac802_15_4Table {
 | 
			
		||||
                pcmd_rsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(),
 | 
			
		||||
                pnotack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(),
 | 
			
		||||
                evt_queue: EVT_QUEUE.as_ptr().cast(),
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), true);
 | 
			
		||||
 | 
			
		||||
        Self
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub(crate) fn notif_evt_handler(ipcc: &mut Ipcc) {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            let notif_buffer: *mut EvtPacket = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pnotack_buffer.cast();
 | 
			
		||||
            let event = EvtBox::new(notif_buffer);
 | 
			
		||||
 | 
			
		||||
            block_on(TL_CHANNEL.send(event));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub(crate) fn cmd_evt_handler(ipcc: &mut Ipcc) {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            let _notif_buffer = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer;
 | 
			
		||||
 | 
			
		||||
            // NOTE: ST's HAL does nothing with this buffer, ??????
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ipcc.c1_set_tx_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into(), false);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub(crate) fn send_cmd(ipcc: &mut Ipcc, buf: &[u8]) {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            let pcmd_buffer: *mut CmdPacket = (*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer.cast();
 | 
			
		||||
            let pcmd_serial: *mut CmdSerial = &mut (*pcmd_buffer).cmd_serial;
 | 
			
		||||
            let pcmd_serial_buf: *mut u8 = pcmd_serial.cast();
 | 
			
		||||
 | 
			
		||||
            core::ptr::copy(buf.as_ptr(), pcmd_serial_buf, buf.len());
 | 
			
		||||
 | 
			
		||||
            let cmd_packet: &mut CmdPacket =
 | 
			
		||||
                &mut *(*TL_REF_TABLE.assume_init().mac_802_15_4_table).pcmd_rsp_buffer.cast();
 | 
			
		||||
            cmd_packet.cmd_serial.ty = TlPacketType::OtCmd as u8;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ipcc.c1_set_flag_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into());
 | 
			
		||||
        ipcc.c1_set_tx_channel(channels::Cpu1Channel::Mac802_15_4cmdRsp.into(), true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub(crate) fn send_ack(ipcc: &mut Ipcc) {
 | 
			
		||||
        // TODO
 | 
			
		||||
        unsafe {
 | 
			
		||||
            let packet: &mut CmdPacket = &mut *(*TL_REF_TABLE.assume_init().mac_802_15_4_table).pnotack_buffer.cast();
 | 
			
		||||
            packet.cmd_serial.ty = TlPacketType::OtAck as u8;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ipcc.c1_clear_flag_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into());
 | 
			
		||||
        ipcc.c1_set_rx_channel(channels::Cpu2Channel::Mac802_15_4NotifAck.into(), true);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -11,7 +11,7 @@ use crate::ipcc::Ipcc;
 | 
			
		||||
pub struct MemoryManager;
 | 
			
		||||
 | 
			
		||||
impl MemoryManager {
 | 
			
		||||
    pub fn init() -> Self {
 | 
			
		||||
    pub fn new() -> Self {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            LinkedListNode::init_head(FREE_BUFF_QUEUE.as_mut_ptr());
 | 
			
		||||
            LinkedListNode::init_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr());
 | 
			
		||||
 
 | 
			
		||||
@@ -5,12 +5,9 @@ use embassy_cortex_m::interrupt::{Interrupt, InterruptExt};
 | 
			
		||||
use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
 | 
			
		||||
use embassy_sync::channel::Channel;
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "ble")]
 | 
			
		||||
use self::ble::Ble;
 | 
			
		||||
use self::cmd::{AclDataPacket, CmdPacket};
 | 
			
		||||
use self::evt::{CsEvt, EvtBox};
 | 
			
		||||
#[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
use self::mac_802_15_4::Mac802_15_4;
 | 
			
		||||
use self::mm::MemoryManager;
 | 
			
		||||
use self::shci::{shci_ble_init, ShciBleInitCmdParam};
 | 
			
		||||
use self::sys::Sys;
 | 
			
		||||
@@ -18,6 +15,7 @@ use self::unsafe_linked_list::LinkedListNode;
 | 
			
		||||
use crate::interrupt;
 | 
			
		||||
use crate::ipcc::{Config, Ipcc};
 | 
			
		||||
 | 
			
		||||
mod ble;
 | 
			
		||||
mod channels;
 | 
			
		||||
mod cmd;
 | 
			
		||||
mod consts;
 | 
			
		||||
@@ -27,11 +25,6 @@ mod shci;
 | 
			
		||||
mod sys;
 | 
			
		||||
mod unsafe_linked_list;
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "ble")]
 | 
			
		||||
mod ble;
 | 
			
		||||
#[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
mod mac_802_15_4;
 | 
			
		||||
 | 
			
		||||
pub type PacketHeader = LinkedListNode;
 | 
			
		||||
 | 
			
		||||
const TL_PACKET_HEADER_SIZE: usize = core::mem::size_of::<PacketHeader>();
 | 
			
		||||
@@ -219,8 +212,8 @@ struct TracesTable {
 | 
			
		||||
 | 
			
		||||
#[repr(C, packed)]
 | 
			
		||||
struct Mac802_15_4Table {
 | 
			
		||||
    pcmd_rsp_buffer: *mut u8,
 | 
			
		||||
    pnotack_buffer: *mut u8,
 | 
			
		||||
    pcmd_rsp_buffer: *const u8,
 | 
			
		||||
    pnotack_buffer: *const u8,
 | 
			
		||||
    evt_queue: *const u8,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -240,7 +233,6 @@ pub struct RefTable {
 | 
			
		||||
    ble_lld_table: *const BleLldTable,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// -------------------- reference table --------------------
 | 
			
		||||
#[link_section = "TL_REF_TABLE"]
 | 
			
		||||
pub static mut TL_REF_TABLE: MaybeUninit<RefTable> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
@@ -274,50 +266,38 @@ static mut TL_MAC_802_15_4_TABLE: MaybeUninit<Mac802_15_4Table> = MaybeUninit::u
 | 
			
		||||
#[link_section = "MB_MEM1"]
 | 
			
		||||
static mut TL_ZIGBEE_TABLE: MaybeUninit<ZigbeeTable> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
// -------------------- tables --------------------
 | 
			
		||||
#[allow(dead_code)] // Not used currently but reserved
 | 
			
		||||
#[link_section = "MB_MEM1"]
 | 
			
		||||
static mut FREE_BUFF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
// not in shared RAM
 | 
			
		||||
static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut CS_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]> =
 | 
			
		||||
    MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM1"]
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
// not in shared RAM
 | 
			
		||||
static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
// -------------------- app tables --------------------
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut SYS_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> =
 | 
			
		||||
    MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> =
 | 
			
		||||
    MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "ble")]
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut BLE_SPARE_EVT_BUF: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]> =
 | 
			
		||||
    MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[cfg(feature = "ble")]
 | 
			
		||||
#[link_section = "MB_MEM1"]
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
 | 
			
		||||
 | 
			
		||||
#[link_section = "MB_MEM2"]
 | 
			
		||||
@@ -327,14 +307,10 @@ static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; TL_PACKET_HEADER_SIZE + 5 + 251
 | 
			
		||||
// TODO: get a better size, this is a placeholder
 | 
			
		||||
pub(crate) static TL_CHANNEL: Channel<CriticalSectionRawMutex, EvtBox, 5> = Channel::new();
 | 
			
		||||
 | 
			
		||||
pub struct TlMbox;
 | 
			
		||||
 | 
			
		||||
pub enum MailboxTarget {
 | 
			
		||||
    Sys,
 | 
			
		||||
    #[cfg(feature = "ble")]
 | 
			
		||||
    Ble,
 | 
			
		||||
    #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
    Mac802_15_4,
 | 
			
		||||
pub struct TlMbox {
 | 
			
		||||
    _sys: Sys,
 | 
			
		||||
    _ble: Ble,
 | 
			
		||||
    _mm: MemoryManager,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl TlMbox {
 | 
			
		||||
@@ -380,14 +356,9 @@ impl TlMbox {
 | 
			
		||||
 | 
			
		||||
        Ipcc::init(config);
 | 
			
		||||
 | 
			
		||||
        Sys::init();
 | 
			
		||||
        MemoryManager::init();
 | 
			
		||||
 | 
			
		||||
        #[cfg(feature = "ble")]
 | 
			
		||||
        Ble::init();
 | 
			
		||||
 | 
			
		||||
        #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
        Mac802_15_4::init();
 | 
			
		||||
        let _sys = Sys::new();
 | 
			
		||||
        let _ble = Ble::new();
 | 
			
		||||
        let _mm = MemoryManager::new();
 | 
			
		||||
 | 
			
		||||
        // enable interrupts
 | 
			
		||||
        unsafe { crate::interrupt::IPCC_C1_RX::steal() }.unpend();
 | 
			
		||||
@@ -396,7 +367,7 @@ impl TlMbox {
 | 
			
		||||
        unsafe { crate::interrupt::IPCC_C1_RX::steal() }.enable();
 | 
			
		||||
        unsafe { crate::interrupt::IPCC_C1_TX::steal() }.enable();
 | 
			
		||||
 | 
			
		||||
        Self
 | 
			
		||||
        TlMbox { _sys, _ble, _mm }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn wireless_fw_info(&self) -> Option<WirelessFwInfoTable> {
 | 
			
		||||
@@ -410,30 +381,17 @@ impl TlMbox {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[cfg(feature = "ble")]
 | 
			
		||||
    pub fn shci_ble_init(&self, param: ShciBleInitCmdParam) {
 | 
			
		||||
        shci_ble_init(param);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn send_cmd(&self, buf: &[u8], target: MailboxTarget) {
 | 
			
		||||
        match target {
 | 
			
		||||
            MailboxTarget::Sys => Sys::send_cmd(buf),
 | 
			
		||||
            #[cfg(feature = "ble")]
 | 
			
		||||
            MailboxTarget::Ble => Ble::send_cmd(buf),
 | 
			
		||||
            #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
            MailboxTarget::Mac802_15_4 => Mac802_15_4::send_cmd(buf),
 | 
			
		||||
        }
 | 
			
		||||
    pub fn send_ble_cmd(&self, buf: &[u8]) {
 | 
			
		||||
        ble::Ble::send_cmd(buf);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub fn send_ack(&self, target: MailboxTarget) {
 | 
			
		||||
        match target {
 | 
			
		||||
            #[cfg(feature = "ble")]
 | 
			
		||||
            MailboxTarget::Ble => Ble::send_acl_data(),
 | 
			
		||||
            #[cfg(feature = "mac-802_15_4")]
 | 
			
		||||
            MailboxTarget::Mac802_15_4 => Mac802_15_4::send_ack(),
 | 
			
		||||
            MailboxTarget::Sys => { /* does nothing */ }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    // pub fn send_sys_cmd(&self, buf: &[u8]) {
 | 
			
		||||
    //     sys::Sys::send_cmd(buf);
 | 
			
		||||
    // }
 | 
			
		||||
 | 
			
		||||
    pub async fn read(&self) -> EvtBox {
 | 
			
		||||
        TL_CHANNEL.recv().await
 | 
			
		||||
 
 | 
			
		||||
@@ -70,6 +70,7 @@ impl Sys {
 | 
			
		||||
    #[allow(dead_code)]
 | 
			
		||||
    pub(crate) fn send_cmd(buf: &[u8]) {
 | 
			
		||||
        unsafe {
 | 
			
		||||
            // TODO: check this
 | 
			
		||||
            let cmd_buffer = &mut *(*TL_REF_TABLE.assume_init().sys_table).pcmd_buffer;
 | 
			
		||||
            let cmd_serial: *mut CmdSerial = &mut cmd_buffer.cmd_serial;
 | 
			
		||||
            let cmd_serial_buf = cmd_serial.cast();
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user