diff options
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs | 19 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/tl_mbox_mac.rs | 12 |
3 files changed, 30 insertions, 9 deletions
diff --git a/embassy-stm32-wpan/src/sub/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index fd8af8609..62612dbfb 100644 --- a/embassy-stm32-wpan/src/sub/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs | |||
| @@ -25,14 +25,6 @@ pub struct Mac { | |||
| 25 | 25 | ||
| 26 | impl Mac { | 26 | impl Mac { |
| 27 | pub(crate) fn new() -> Self { | 27 | 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 } | 28 | Self { phantom: PhantomData } |
| 37 | } | 29 | } |
| 38 | 30 | ||
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/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 | ||
