diff options
| author | xoviat <[email protected]> | 2023-06-19 21:17:31 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-06-19 21:17:31 -0500 |
| commit | 978e7b5e77f86dc82c393442702defa38b516f4b (patch) | |
| tree | d45f696ffe8f90fcb85182c85766190ae5a0e26c | |
| parent | 0122b813d3dfe90bad7d307f4f0c7adcbae0a7a5 (diff) | |
stm32/wpan: fix bugs
| -rw-r--r-- | embassy-stm32-wpan/src/evt.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/mac.rs | 12 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sys.rs | 1 |
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)] |
| 50 | pub struct Evt { | 50 | pub 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)] |
| 58 | pub struct EvtSerial { | 58 | pub 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)] |
| 80 | pub struct EvtPacket { | 80 | pub 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; | |||
| 8 | use embassy_stm32::ipcc::Ipcc; | 8 | use embassy_stm32::ipcc::Ipcc; |
| 9 | use embassy_sync::waitqueue::AtomicWaker; | 9 | use embassy_sync::waitqueue::AtomicWaker; |
| 10 | 10 | ||
| 11 | use crate::channels; | ||
| 11 | use crate::cmd::CmdPacket; | 12 | use crate::cmd::CmdPacket; |
| 12 | use crate::consts::TlPacketType; | 13 | use crate::consts::TlPacketType; |
| 13 | use crate::evt::{EvtBox, EvtPacket}; | 14 | use crate::evt::{EvtBox, EvtPacket}; |
| 14 | use crate::tables::{ | 15 | use 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 | }; |
| 17 | use crate::unsafe_linked_list::LinkedListNode; | ||
| 18 | use crate::{channels, EVT_QUEUE}; | ||
| 19 | 18 | ||
| 20 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); | 19 | static MAC_WAKER: AtomicWaker = AtomicWaker::new(); |
| 21 | static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); | 20 | static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); |
| @@ -27,8 +26,6 @@ pub struct Mac { | |||
| 27 | impl Mac { | 26 | impl 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; | |||
| 4 | use crate::cmd::CmdPacket; | 4 | use crate::cmd::CmdPacket; |
| 5 | use crate::consts::TlPacketType; | 5 | use crate::consts::TlPacketType; |
| 6 | use crate::evt::{CcEvt, EvtBox, EvtPacket}; | 6 | use crate::evt::{CcEvt, EvtBox, EvtPacket}; |
| 7 | #[allow(unused_imports)] | ||
| 7 | use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; | 8 | use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode}; |
| 8 | use crate::tables::{SysTable, WirelessFwInfoTable}; | 9 | use crate::tables::{SysTable, WirelessFwInfoTable}; |
| 9 | use crate::unsafe_linked_list::LinkedListNode; | 10 | use crate::unsafe_linked_list::LinkedListNode; |
