mirror of
https://github.com/embassy-rs/embassy.git
synced 2024-10-30 13:50:53 +00:00
commit
03e0116a56
@ -21,6 +21,7 @@ embassy-embedded-hal = { version = "0.1.0", path = "../embassy-embedded-hal" }
|
||||
defmt = { version = "0.3", optional = true }
|
||||
cortex-m = "0.7.6"
|
||||
heapless = "0.7.16"
|
||||
aligned = "0.4.1"
|
||||
|
||||
bit_field = "0.10.2"
|
||||
stm32-device-signature = { version = "0.3.3", features = ["stm32wb5x"] }
|
||||
|
@ -1,4 +1,5 @@
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() {
|
||||
match env::vars()
|
||||
@ -10,6 +11,16 @@ fn main() {
|
||||
Err(GetOneError::None) => panic!("No stm32xx Cargo feature enabled"),
|
||||
Err(GetOneError::Multiple) => panic!("Multiple stm32xx Cargo features enabled"),
|
||||
}
|
||||
|
||||
let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
|
||||
// ========
|
||||
// stm32wb tl_mbox link sections
|
||||
|
||||
let out_file = out_dir.join("tl_mbox.x").to_string_lossy().to_string();
|
||||
fs::write(out_file, fs::read_to_string("tl_mbox.x.in").unwrap()).unwrap();
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rerun-if-changed=tl_mbox.x.in");
|
||||
}
|
||||
|
||||
enum GetOneError {
|
||||
|
@ -87,3 +87,7 @@ pub const fn divc(x: usize, y: usize) -> usize {
|
||||
pub const TL_BLE_EVT_CS_PACKET_SIZE: usize = TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE;
|
||||
#[allow(dead_code)]
|
||||
pub const TL_BLE_EVT_CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_BLE_EVT_CS_PACKET_SIZE;
|
||||
|
||||
pub const TL_BLEEVT_CC_OPCODE: u8 = 0x0E;
|
||||
pub const TL_BLEEVT_CS_OPCODE: u8 = 0x0F;
|
||||
pub const TL_BLEEVT_VS_OPCODE: u8 = 0xFF;
|
||||
|
@ -1,3 +1,4 @@
|
||||
use core::marker::PhantomData;
|
||||
use core::{ptr, slice};
|
||||
|
||||
use super::PacketHeader;
|
||||
@ -93,17 +94,22 @@ impl EvtPacket {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait MemoryManager {
|
||||
unsafe fn drop_event_packet(evt: *mut EvtPacket);
|
||||
}
|
||||
|
||||
/// smart pointer to the [`EvtPacket`] that will dispose of [`EvtPacket`] buffer automatically
|
||||
/// on [`Drop`]
|
||||
#[derive(Debug)]
|
||||
pub struct EvtBox {
|
||||
pub struct EvtBox<T: MemoryManager> {
|
||||
ptr: *mut EvtPacket,
|
||||
mm: PhantomData<T>,
|
||||
}
|
||||
|
||||
unsafe impl Send for EvtBox {}
|
||||
impl EvtBox {
|
||||
unsafe impl<T: MemoryManager> Send for EvtBox<T> {}
|
||||
impl<T: MemoryManager> EvtBox<T> {
|
||||
pub(super) fn new(ptr: *mut EvtPacket) -> Self {
|
||||
Self { ptr }
|
||||
Self { ptr, mm: PhantomData }
|
||||
}
|
||||
|
||||
/// Returns information about the event
|
||||
@ -126,9 +132,6 @@ impl EvtBox {
|
||||
}
|
||||
}
|
||||
|
||||
/// writes an underlying [`EvtPacket`] into the provided buffer.
|
||||
/// Returns the number of bytes that were written.
|
||||
/// Returns an error if event kind is unknown or if provided buffer size is not enough.
|
||||
pub fn serial<'a>(&'a self) -> &'a [u8] {
|
||||
unsafe {
|
||||
let evt_serial: *const EvtSerial = &(*self.ptr).evt_serial;
|
||||
@ -141,20 +144,8 @@ impl EvtBox {
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for EvtBox {
|
||||
impl<T: MemoryManager> Drop for EvtBox<T> {
|
||||
fn drop(&mut self) {
|
||||
#[cfg(feature = "ble")]
|
||||
unsafe {
|
||||
use crate::mm;
|
||||
|
||||
mm::MemoryManager::drop_event_packet(self.ptr)
|
||||
};
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
unsafe {
|
||||
use crate::mac;
|
||||
|
||||
mac::Mac::drop_event_packet(self.ptr)
|
||||
}
|
||||
unsafe { T::drop_event_packet(self.ptr) };
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
use core::ptr;
|
||||
|
||||
use crate::cmd::CmdPacket;
|
||||
use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE};
|
||||
use crate::evt::{CcEvt, EvtPacket, EvtSerial};
|
||||
use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable};
|
||||
use crate::TL_REF_TABLE;
|
||||
use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable, TL_DEVICE_INFO_TABLE};
|
||||
|
||||
const TL_BLEEVT_CC_OPCODE: u8 = 0x0e;
|
||||
const LHCI_OPCODE_C1_DEVICE_INF: u16 = 0xfd62;
|
||||
@ -38,7 +39,7 @@ impl Default for LhciC1DeviceInformationCcrp {
|
||||
safe_boot_info_table,
|
||||
rss_info_table,
|
||||
wireless_fw_info_table,
|
||||
} = unsafe { &*(*TL_REF_TABLE.as_ptr()).device_info_table }.clone();
|
||||
} = unsafe { ptr::read_volatile(TL_DEVICE_INFO_TABLE.as_ptr()) };
|
||||
|
||||
let device_id = stm32_device_signature::device_id();
|
||||
let uid96_0 = (device_id[3] as u32) << 24
|
||||
@ -105,7 +106,7 @@ impl LhciC1DeviceInformationCcrp {
|
||||
let self_ptr: *const LhciC1DeviceInformationCcrp = self;
|
||||
let self_buf = self_ptr.cast();
|
||||
|
||||
core::ptr::copy(self_buf, evt_cc_payload_buf, self_size);
|
||||
ptr::copy(self_buf, evt_cc_payload_buf, self_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,26 +11,24 @@ use embassy_hal_common::{into_ref, Peripheral, PeripheralRef};
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32::peripherals::IPCC;
|
||||
use mm::MemoryManager;
|
||||
use sys::Sys;
|
||||
use sub::mm::MemoryManager;
|
||||
use sub::sys::Sys;
|
||||
use tables::*;
|
||||
use unsafe_linked_list::LinkedListNode;
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
pub mod ble;
|
||||
pub mod channels;
|
||||
pub mod cmd;
|
||||
pub mod consts;
|
||||
pub mod evt;
|
||||
pub mod lhci;
|
||||
#[cfg(feature = "mac")]
|
||||
pub mod mac;
|
||||
pub mod mm;
|
||||
pub mod shci;
|
||||
pub mod sys;
|
||||
pub mod sub;
|
||||
pub mod tables;
|
||||
pub mod unsafe_linked_list;
|
||||
|
||||
#[cfg(feature = "ble")]
|
||||
pub use crate::sub::ble::hci;
|
||||
|
||||
type PacketHeader = LinkedListNode;
|
||||
|
||||
pub struct TlMbox<'d> {
|
||||
@ -39,9 +37,9 @@ pub struct TlMbox<'d> {
|
||||
pub sys_subsystem: Sys,
|
||||
pub mm_subsystem: MemoryManager,
|
||||
#[cfg(feature = "ble")]
|
||||
pub ble_subsystem: ble::Ble,
|
||||
pub ble_subsystem: sub::ble::Ble,
|
||||
#[cfg(feature = "mac")]
|
||||
pub mac_subsystem: mac::Mac,
|
||||
pub mac_subsystem: sub::mac::Mac,
|
||||
}
|
||||
|
||||
impl<'d> TlMbox<'d> {
|
||||
@ -128,12 +126,12 @@ impl<'d> TlMbox<'d> {
|
||||
|
||||
Self {
|
||||
_ipcc: ipcc,
|
||||
sys_subsystem: sys::Sys::new(),
|
||||
sys_subsystem: sub::sys::Sys::new(),
|
||||
#[cfg(feature = "ble")]
|
||||
ble_subsystem: ble::Ble::new(),
|
||||
ble_subsystem: sub::ble::Ble::new(),
|
||||
#[cfg(feature = "mac")]
|
||||
mac_subsystem: mac::Mac::new(),
|
||||
mm_subsystem: mm::MemoryManager::new(),
|
||||
mac_subsystem: sub::mac::Mac::new(),
|
||||
mm_subsystem: sub::mm::MemoryManager::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,16 @@
|
||||
use core::marker::PhantomData;
|
||||
use core::ptr;
|
||||
|
||||
use embassy_stm32::ipcc::Ipcc;
|
||||
use hci::Opcode;
|
||||
|
||||
use crate::channels;
|
||||
use crate::cmd::CmdPacket;
|
||||
use crate::consts::TlPacketType;
|
||||
use crate::evt::EvtBox;
|
||||
use crate::consts::{TlPacketType, TL_BLEEVT_CC_OPCODE, TL_BLEEVT_CS_OPCODE};
|
||||
use crate::evt::{EvtBox, EvtPacket, EvtStub};
|
||||
use crate::sub::mm;
|
||||
use crate::tables::{BleTable, BLE_CMD_BUFFER, CS_BUFFER, EVT_QUEUE, HCI_ACL_DATA_BUFFER, TL_BLE_TABLE};
|
||||
use crate::unsafe_linked_list::LinkedListNode;
|
||||
use crate::{channels, evt};
|
||||
|
||||
pub struct Ble {
|
||||
phantom: PhantomData<Ble>,
|
||||
@ -30,7 +32,7 @@ impl Ble {
|
||||
Self { phantom: PhantomData }
|
||||
}
|
||||
/// `HW_IPCC_BLE_EvtNot`
|
||||
pub async fn tl_read(&self) -> EvtBox {
|
||||
pub async fn tl_read(&self) -> EvtBox<Self> {
|
||||
Ipcc::receive(channels::cpu2::IPCC_BLE_EVENT_CHANNEL, || unsafe {
|
||||
if let Some(node_ptr) = LinkedListNode::remove_head(EVT_QUEUE.as_mut_ptr()) {
|
||||
Some(EvtBox::new(node_ptr.cast()))
|
||||
@ -63,6 +65,21 @@ impl Ble {
|
||||
}
|
||||
}
|
||||
|
||||
impl evt::MemoryManager for Ble {
|
||||
/// SAFETY: passing a pointer to something other than a managed event packet is UB
|
||||
unsafe fn drop_event_packet(evt: *mut EvtPacket) {
|
||||
let stub = unsafe {
|
||||
let p_evt_stub = &(*evt).evt_serial as *const _ as *const EvtStub;
|
||||
|
||||
ptr::read_volatile(p_evt_stub)
|
||||
};
|
||||
|
||||
if !(stub.evt_code == TL_BLEEVT_CS_OPCODE || stub.evt_code == TL_BLEEVT_CC_OPCODE) {
|
||||
mm::MemoryManager::drop_event_packet(evt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub extern crate stm32wb_hci as hci;
|
||||
|
||||
impl hci::Controller for Ble {
|
@ -8,13 +8,13 @@ use embassy_futures::poll_once;
|
||||
use embassy_stm32::ipcc::Ipcc;
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use crate::channels;
|
||||
use crate::cmd::CmdPacket;
|
||||
use crate::consts::TlPacketType;
|
||||
use crate::evt::{EvtBox, EvtPacket};
|
||||
use crate::tables::{
|
||||
Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE,
|
||||
};
|
||||
use crate::{channels, evt};
|
||||
|
||||
static MAC_WAKER: AtomicWaker = AtomicWaker::new();
|
||||
static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false);
|
||||
@ -36,31 +36,10 @@ impl Mac {
|
||||
Self { phantom: PhantomData }
|
||||
}
|
||||
|
||||
/// SAFETY: passing a pointer to something other than a managed event packet is UB
|
||||
pub(crate) unsafe fn drop_event_packet(_: *mut EvtPacket) {
|
||||
// Write the ack
|
||||
CmdPacket::write_into(
|
||||
MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _,
|
||||
TlPacketType::OtAck,
|
||||
0,
|
||||
&[],
|
||||
);
|
||||
|
||||
// Clear the rx flag
|
||||
let _ = poll_once(Ipcc::receive::<bool>(
|
||||
channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL,
|
||||
|| None,
|
||||
));
|
||||
|
||||
// Allow a new read call
|
||||
MAC_EVT_OUT.store(false, Ordering::SeqCst);
|
||||
MAC_WAKER.wake();
|
||||
}
|
||||
|
||||
/// `HW_IPCC_MAC_802_15_4_EvtNot`
|
||||
///
|
||||
/// This function will stall if the previous `EvtBox` has not been dropped
|
||||
pub async fn read(&self) -> EvtBox {
|
||||
pub async fn read(&self) -> EvtBox<Self> {
|
||||
// Wait for the last event box to be dropped
|
||||
poll_fn(|cx| {
|
||||
MAC_WAKER.register(cx.waker());
|
||||
@ -109,3 +88,26 @@ impl Mac {
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
impl evt::MemoryManager for Mac {
|
||||
/// SAFETY: passing a pointer to something other than a managed event packet is UB
|
||||
unsafe fn drop_event_packet(_: *mut EvtPacket) {
|
||||
// Write the ack
|
||||
CmdPacket::write_into(
|
||||
MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _,
|
||||
TlPacketType::OtAck,
|
||||
0,
|
||||
&[],
|
||||
);
|
||||
|
||||
// Clear the rx flag
|
||||
let _ = poll_once(Ipcc::receive::<bool>(
|
||||
channels::cpu2::IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL,
|
||||
|| None,
|
||||
));
|
||||
|
||||
// Allow a new read call
|
||||
MAC_EVT_OUT.store(false, Ordering::SeqCst);
|
||||
MAC_WAKER.wake();
|
||||
}
|
||||
}
|
@ -8,13 +8,13 @@ use cortex_m::interrupt;
|
||||
use embassy_stm32::ipcc::Ipcc;
|
||||
use embassy_sync::waitqueue::AtomicWaker;
|
||||
|
||||
use crate::channels;
|
||||
use crate::consts::POOL_SIZE;
|
||||
use crate::evt::EvtPacket;
|
||||
use crate::tables::{
|
||||
MemManagerTable, BLE_SPARE_EVT_BUF, EVT_POOL, FREE_BUF_QUEUE, SYS_SPARE_EVT_BUF, TL_MEM_MANAGER_TABLE,
|
||||
};
|
||||
use crate::unsafe_linked_list::LinkedListNode;
|
||||
use crate::{channels, evt};
|
||||
|
||||
static MM_WAKER: AtomicWaker = AtomicWaker::new();
|
||||
static mut LOCAL_FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
@ -43,16 +43,6 @@ impl MemoryManager {
|
||||
Self { phantom: PhantomData }
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
/// SAFETY: passing a pointer to something other than a managed event packet is UB
|
||||
pub(crate) unsafe fn drop_event_packet(evt: *mut EvtPacket) {
|
||||
interrupt::free(|_| unsafe {
|
||||
LinkedListNode::insert_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), evt as *mut _);
|
||||
});
|
||||
|
||||
MM_WAKER.wake();
|
||||
}
|
||||
|
||||
pub async fn run_queue(&self) {
|
||||
loop {
|
||||
poll_fn(|cx| unsafe {
|
||||
@ -77,3 +67,14 @@ impl MemoryManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl evt::MemoryManager for MemoryManager {
|
||||
/// SAFETY: passing a pointer to something other than a managed event packet is UB
|
||||
unsafe fn drop_event_packet(evt: *mut EvtPacket) {
|
||||
interrupt::free(|_| unsafe {
|
||||
LinkedListNode::insert_head(LOCAL_FREE_BUF_QUEUE.as_mut_ptr(), evt as *mut _);
|
||||
});
|
||||
|
||||
MM_WAKER.wake();
|
||||
}
|
||||
}
|
6
embassy-stm32-wpan/src/sub/mod.rs
Normal file
6
embassy-stm32-wpan/src/sub/mod.rs
Normal file
@ -0,0 +1,6 @@
|
||||
#[cfg(feature = "ble")]
|
||||
pub mod ble;
|
||||
#[cfg(feature = "mac")]
|
||||
pub mod mac;
|
||||
pub mod mm;
|
||||
pub mod sys;
|
@ -6,6 +6,7 @@ use crate::consts::TlPacketType;
|
||||
use crate::evt::{CcEvt, EvtBox, EvtPacket};
|
||||
#[allow(unused_imports)]
|
||||
use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode};
|
||||
use crate::sub::mm;
|
||||
use crate::tables::{SysTable, WirelessFwInfoTable};
|
||||
use crate::unsafe_linked_list::LinkedListNode;
|
||||
use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE};
|
||||
@ -73,7 +74,7 @@ impl Sys {
|
||||
}
|
||||
|
||||
/// `HW_IPCC_SYS_EvtNot`
|
||||
pub async fn read(&self) -> EvtBox {
|
||||
pub async fn read(&self) -> EvtBox<mm::MemoryManager> {
|
||||
Ipcc::receive(channels::cpu2::IPCC_SYSTEM_EVENT_CHANNEL, || unsafe {
|
||||
if let Some(node_ptr) = LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr()) {
|
||||
Some(EvtBox::new(node_ptr.cast()))
|
@ -1,5 +1,6 @@
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
use aligned::{Aligned, A4};
|
||||
use bit_field::BitField;
|
||||
|
||||
use crate::cmd::{AclDataPacket, CmdPacket};
|
||||
@ -164,9 +165,6 @@ pub struct Mac802_15_4Table {
|
||||
pub evt_queue: *const u8,
|
||||
}
|
||||
|
||||
#[repr(C, align(4))]
|
||||
pub struct AlignedData<const L: usize>([u8; L]);
|
||||
|
||||
/// Reference table. Contains pointers to all other tables.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
#[repr(C)]
|
||||
@ -222,10 +220,9 @@ pub static mut FREE_BUF_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut TRACES_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
|
||||
const CS_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE;
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut CS_BUFFER: MaybeUninit<AlignedData<CS_BUFFER_SIZE>> = MaybeUninit::uninit();
|
||||
pub static mut CS_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + TL_CS_EVT_SIZE]>> =
|
||||
MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::uninit();
|
||||
@ -238,35 +235,30 @@ pub static mut SYSTEM_EVT_QUEUE: MaybeUninit<LinkedListNode> = MaybeUninit::unin
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut MAC_802_15_4_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
const MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255;
|
||||
|
||||
#[cfg(feature = "mac")]
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<AlignedData<MAC_802_15_4_NOTIF_RSP_EVT_BUFFER_SIZE>> =
|
||||
MaybeUninit::uninit();
|
||||
pub static mut MAC_802_15_4_NOTIF_RSP_EVT_BUFFER: MaybeUninit<
|
||||
Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>,
|
||||
> = MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut EVT_POOL: MaybeUninit<[u8; POOL_SIZE]> = MaybeUninit::uninit();
|
||||
pub static mut EVT_POOL: MaybeUninit<Aligned<A4, [u8; POOL_SIZE]>> = MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut SYS_CMD_BUF: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
|
||||
const SYS_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255;
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<AlignedData<SYS_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit();
|
||||
pub static mut SYS_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM1"]
|
||||
pub static mut BLE_CMD_BUFFER: MaybeUninit<CmdPacket> = MaybeUninit::uninit();
|
||||
|
||||
const BLE_SPARE_EVT_BUF_SIZE: usize = TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255;
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<AlignedData<BLE_SPARE_EVT_BUF_SIZE>> = MaybeUninit::uninit();
|
||||
|
||||
const HCI_ACL_DATA_BUFFER_SIZE: usize = TL_PACKET_HEADER_SIZE + 5 + 251;
|
||||
pub static mut BLE_SPARE_EVT_BUF: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + TL_EVT_HEADER_SIZE + 255]>> =
|
||||
MaybeUninit::uninit();
|
||||
|
||||
#[link_section = "MB_MEM2"]
|
||||
// fuck these "magic" numbers from ST ---v---v
|
||||
pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<[u8; HCI_ACL_DATA_BUFFER_SIZE]> = MaybeUninit::uninit();
|
||||
pub static mut HCI_ACL_DATA_BUFFER: MaybeUninit<Aligned<A4, [u8; TL_PACKET_HEADER_SIZE + 5 + 251]>> =
|
||||
MaybeUninit::uninit();
|
||||
|
@ -911,16 +911,6 @@ fn main() {
|
||||
println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]);
|
||||
}
|
||||
|
||||
// ========
|
||||
// stm32wb tl_mbox link sections
|
||||
|
||||
if chip_name.starts_with("stm32wb") {
|
||||
let out_file = out_dir.join("tl_mbox.x").to_string_lossy().to_string();
|
||||
fs::write(out_file, fs::read_to_string("tl_mbox.x.in").unwrap()).unwrap();
|
||||
println!("cargo:rustc-link-search={}", out_dir.display());
|
||||
println!("cargo:rerun-if-changed=tl_mbox.x.in");
|
||||
}
|
||||
|
||||
// =======
|
||||
// Features for targeting groups of chips
|
||||
|
||||
|
@ -8,15 +8,15 @@ use defmt::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32_wpan::ble::hci::host::uart::UartHci;
|
||||
use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType};
|
||||
use embassy_stm32_wpan::ble::hci::types::AdvertisingType;
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{
|
||||
use embassy_stm32_wpan::hci::host::uart::UartHci;
|
||||
use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType};
|
||||
use embassy_stm32_wpan::hci::types::AdvertisingType;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{
|
||||
AdvertisingDataType, DiscoverableParameters, GapCommands, Role,
|
||||
};
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands;
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel};
|
||||
use embassy_stm32_wpan::ble::hci::BdAddr;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel};
|
||||
use embassy_stm32_wpan::hci::BdAddr;
|
||||
use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp;
|
||||
use embassy_stm32_wpan::TlMbox;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
@ -49,7 +49,9 @@ async fn main(_spawner: Spawner) {
|
||||
let sys_event = mbox.sys_subsystem.read().await;
|
||||
info!("sys event: {}", sys_event.payload());
|
||||
|
||||
mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
|
||||
let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
|
||||
info!("initialized mac: {}", result);
|
||||
|
||||
//
|
||||
// info!("starting ble...");
|
||||
// mbox.ble_subsystem.t_write(0x0c, &[]).await;
|
||||
|
@ -12,17 +12,18 @@ use common::*;
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32_wpan::ble::hci::host::uart::UartHci;
|
||||
use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType};
|
||||
use embassy_stm32_wpan::ble::hci::types::AdvertisingType;
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{
|
||||
use embassy_stm32_wpan::hci::host::uart::UartHci;
|
||||
use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType};
|
||||
use embassy_stm32_wpan::hci::types::AdvertisingType;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{
|
||||
AdvertisingDataType, DiscoverableParameters, GapCommands, Role,
|
||||
};
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands;
|
||||
use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel};
|
||||
use embassy_stm32_wpan::ble::hci::BdAddr;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands;
|
||||
use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel};
|
||||
use embassy_stm32_wpan::hci::BdAddr;
|
||||
use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp;
|
||||
use embassy_stm32_wpan::{mm, TlMbox};
|
||||
use embassy_stm32_wpan::sub::mm;
|
||||
use embassy_stm32_wpan::TlMbox;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
bind_interrupts!(struct Irqs{
|
||||
@ -38,14 +39,14 @@ async fn run_mm_queue(memory_manager: mm::MemoryManager) {
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
async fn main(spawner: Spawner) {
|
||||
let p = embassy_stm32::init(config());
|
||||
info!("Hello World!");
|
||||
|
||||
let config = Config::default();
|
||||
let mut mbox = TlMbox::init(p.IPCC, Irqs, config);
|
||||
|
||||
// spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
|
||||
spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
|
||||
|
||||
let sys_event = mbox.sys_subsystem.read().await;
|
||||
info!("sys event: {}", sys_event.payload());
|
||||
|
Loading…
Reference in New Issue
Block a user