aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxoviat <[email protected]>2023-06-19 21:17:31 -0500
committerxoviat <[email protected]>2023-06-19 21:17:31 -0500
commit978e7b5e77f86dc82c393442702defa38b516f4b (patch)
treed45f696ffe8f90fcb85182c85766190ae5a0e26c
parent0122b813d3dfe90bad7d307f4f0c7adcbae0a7a5 (diff)
stm32/wpan: fix bugs
-rw-r--r--embassy-stm32-wpan/src/evt.rs8
-rw-r--r--embassy-stm32-wpan/src/mac.rs12
-rw-r--r--embassy-stm32-wpan/src/sys.rs1
3 files changed, 12 insertions, 9 deletions
diff --git a/embassy-stm32-wpan/src/evt.rs b/embassy-stm32-wpan/src/evt.rs
index ee108ec88..47bdc49bf 100644
--- a/embassy-stm32-wpan/src/evt.rs
+++ b/embassy-stm32-wpan/src/evt.rs
@@ -45,15 +45,15 @@ pub struct AsynchEvt {
45 payload: [u8; 1], 45 payload: [u8; 1],
46} 46}
47 47
48#[derive(Copy, Clone, Default)] 48#[derive(Copy, Clone)]
49#[repr(C, packed)] 49#[repr(C, packed)]
50pub struct Evt { 50pub struct Evt {
51 pub evt_code: u8, 51 pub evt_code: u8,
52 pub payload_len: u8, 52 pub payload_len: u8,
53 pub payload: [u8; 1], 53 pub payload: [u8; 255],
54} 54}
55 55
56#[derive(Copy, Clone, Default)] 56#[derive(Copy, Clone)]
57#[repr(C, packed)] 57#[repr(C, packed)]
58pub struct EvtSerial { 58pub struct EvtSerial {
59 pub kind: u8, 59 pub kind: u8,
@@ -75,7 +75,7 @@ pub struct EvtStub {
75/// Be careful that the asynchronous events reported by the CPU2 on the system channel do 75/// Be careful that the asynchronous events reported by the CPU2 on the system channel do
76/// include the header and shall use `EvtPacket` format. Only the command response format on the 76/// include the header and shall use `EvtPacket` format. Only the command response format on the
77/// system channel is different. 77/// system channel is different.
78#[derive(Copy, Clone, Default)] 78#[derive(Copy, Clone)]
79#[repr(C, packed)] 79#[repr(C, packed)]
80pub struct EvtPacket { 80pub struct EvtPacket {
81 pub header: PacketHeader, 81 pub header: PacketHeader,
diff --git a/embassy-stm32-wpan/src/mac.rs b/embassy-stm32-wpan/src/mac.rs
index 9fbf37473..d2be1b85c 100644
--- a/embassy-stm32-wpan/src/mac.rs
+++ b/embassy-stm32-wpan/src/mac.rs
@@ -8,14 +8,13 @@ use embassy_futures::poll_once;
8use embassy_stm32::ipcc::Ipcc; 8use embassy_stm32::ipcc::Ipcc;
9use embassy_sync::waitqueue::AtomicWaker; 9use embassy_sync::waitqueue::AtomicWaker;
10 10
11use crate::channels;
11use crate::cmd::CmdPacket; 12use crate::cmd::CmdPacket;
12use crate::consts::TlPacketType; 13use crate::consts::TlPacketType;
13use crate::evt::{EvtBox, EvtPacket}; 14use crate::evt::{EvtBox, EvtPacket};
14use crate::tables::{ 15use crate::tables::{
15 Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE, 16 Mac802_15_4Table, MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER, TL_MAC_802_15_4_TABLE,
16}; 17};
17use crate::unsafe_linked_list::LinkedListNode;
18use crate::{channels, EVT_QUEUE};
19 18
20static MAC_WAKER: AtomicWaker = AtomicWaker::new(); 19static MAC_WAKER: AtomicWaker = AtomicWaker::new();
21static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); 20static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false);
@@ -27,8 +26,6 @@ pub struct Mac {
27impl Mac { 26impl Mac {
28 pub(crate) fn new() -> Self { 27 pub(crate) fn new() -> Self {
29 unsafe { 28 unsafe {
30 LinkedListNode::init_head(EVT_QUEUE.as_mut_ptr());
31
32 TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table { 29 TL_MAC_802_15_4_TABLE.as_mut_ptr().write_volatile(Mac802_15_4Table {
33 p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(), 30 p_cmdrsp_buffer: MAC_802_15_4_CMD_BUFFER.as_mut_ptr().cast(),
34 p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(), 31 p_notack_buffer: MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr().cast(),
@@ -42,7 +39,12 @@ impl Mac {
42 /// SAFETY: passing a pointer to something other than a managed event packet is UB 39 /// SAFETY: passing a pointer to something other than a managed event packet is UB
43 pub(crate) unsafe fn drop_event_packet(_: *mut EvtPacket) { 40 pub(crate) unsafe fn drop_event_packet(_: *mut EvtPacket) {
44 // Write the ack 41 // Write the ack
45 CmdPacket::write_into(MAC_802_15_4_CMD_BUFFER.as_mut_ptr(), TlPacketType::OtAck, 0, &[]); 42 CmdPacket::write_into(
43 MAC_802_15_4_NOTIF_RSP_EVT_BUFFER.as_mut_ptr() as *mut _,
44 TlPacketType::OtAck,
45 0,
46 &[],
47 );
46 48
47 // Clear the rx flag 49 // Clear the rx flag
48 let _ = poll_once(Ipcc::receive::<bool>( 50 let _ = poll_once(Ipcc::receive::<bool>(
diff --git a/embassy-stm32-wpan/src/sys.rs b/embassy-stm32-wpan/src/sys.rs
index 65a64e090..2b699b725 100644
--- a/embassy-stm32-wpan/src/sys.rs
+++ b/embassy-stm32-wpan/src/sys.rs
@@ -4,6 +4,7 @@ use core::ptr;
4use crate::cmd::CmdPacket; 4use crate::cmd::CmdPacket;
5use crate::consts::TlPacketType; 5use crate::consts::TlPacketType;
6use crate::evt::{CcEvt, EvtBox, EvtPacket}; 6use crate::evt::{CcEvt, EvtBox, EvtPacket};
7#[allow(unused_imports)]
7use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; 8use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode};
8use crate::tables::{SysTable, WirelessFwInfoTable}; 9use crate::tables::{SysTable, WirelessFwInfoTable};
9use crate::unsafe_linked_list::LinkedListNode; 10use crate::unsafe_linked_list::LinkedListNode;