mac: move table initialization after sys ready
This commit is contained in:
parent
735d676a72
commit
c1bf5aee24
3 changed files with 30 additions and 9 deletions
|
@ -25,14 +25,6 @@ pub struct Mac {
|
|||
|
||||
impl Mac {
|
||||
pub(crate) fn new() -> Self {
|
||||
unsafe {
|
||||
TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table {
|
||||
p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(),
|
||||
p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(),
|
||||
evt_queue: ptr::null_mut(),
|
||||
});
|
||||
}
|
||||
|
||||
Self { phantom: PhantomData }
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,25 @@ impl Sys {
|
|||
|
||||
#[cfg(feature = "mac")]
|
||||
pub async fn shci_c2_mac_802_15_4_init(&self) -> SchiCommandStatus {
|
||||
use crate::tables::{
|
||||
Mac802_15_4Table, TracesTable, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER,
|
||||
TL_MAC_802_15_4_TABLE, TL_TRACES_TABLE, TRACES_EVT_QUEUE,
|
||||
};
|
||||
|
||||
unsafe {
|
||||
LinkedListNode::init_head(TRACES_EVT_QUEUE.as_mut_ptr() as *mut _);
|
||||
|
||||
TL_TRACES_TABLE.as_mut_ptr().write_volatile(TracesTable {
|
||||
traces_queue: TRACES_EVT_QUEUE.as_ptr() as *const _,
|
||||
});
|
||||
|
||||
TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table {
|
||||
p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(),
|
||||
p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(),
|
||||
evt_queue: core::ptr::null_mut(),
|
||||
});
|
||||
};
|
||||
|
||||
self.write_and_get_response(ShciOpcode::Mac802_15_4Init, &[]).await
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use defmt::*;
|
|||
use embassy_executor::Spawner;
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler};
|
||||
use embassy_stm32_wpan::sub::mm;
|
||||
use embassy_stm32_wpan::TlMbox;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
|
@ -14,8 +15,13 @@ bind_interrupts!(struct Irqs{
|
|||
IPCC_C1_TX => TransmitInterruptHandler;
|
||||
});
|
||||
|
||||
#[embassy_executor::task]
|
||||
async fn run_mm_queue(memory_manager: mm::MemoryManager) {
|
||||
memory_manager.run_queue().await;
|
||||
}
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(_spawner: Spawner) {
|
||||
async fn main(spawner: Spawner) {
|
||||
/*
|
||||
How to make this work:
|
||||
|
||||
|
@ -46,9 +52,13 @@ async fn main(_spawner: Spawner) {
|
|||
let config = Config::default();
|
||||
let mbox = TlMbox::init(p.IPCC, Irqs, config);
|
||||
|
||||
spawner.spawn(run_mm_queue(mbox.mm_subsystem)).unwrap();
|
||||
|
||||
let sys_event = mbox.sys_subsystem.read().await;
|
||||
info!("sys event: {}", sys_event.payload());
|
||||
|
||||
core::mem::drop(sys_event);
|
||||
|
||||
let result = mbox.sys_subsystem.shci_c2_mac_802_15_4_init().await;
|
||||
info!("initialized mac: {}", result);
|
||||
|
||||
|
|
Loading…
Reference in a new issue