stm32/wpan: fix bugs

This commit is contained in:
xoviat 2023-06-19 21:17:31 -05:00
parent 0122b813d3
commit 978e7b5e77
3 changed files with 12 additions and 9 deletions

View File

@ -45,15 +45,15 @@ pub struct AsynchEvt {
payload: [u8; 1],
}
#[derive(Copy, Clone, Default)]
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct Evt {
pub evt_code: u8,
pub payload_len: u8,
pub payload: [u8; 1],
pub payload: [u8; 255],
}
#[derive(Copy, Clone, Default)]
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct EvtSerial {
pub kind: u8,
@ -75,7 +75,7 @@ pub struct EvtStub {
/// Be careful that the asynchronous events reported by the CPU2 on the system channel do
/// include the header and shall use `EvtPacket` format. Only the command response format on the
/// system channel is different.
#[derive(Copy, Clone, Default)]
#[derive(Copy, Clone)]
#[repr(C, packed)]
pub struct EvtPacket {
pub header: PacketHeader,

View File

@ -8,14 +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::unsafe_linked_list::LinkedListNode;
use crate::{channels, EVT_QUEUE};
static MAC_WAKER: AtomicWaker = AtomicWaker::new();
static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false);
@ -27,8 +26,6 @@ pub struct Mac {
impl Mac {
pub(crate) fn new() -> Self {
unsafe {
LinkedListNode::init_head(EVT_QUEUE.as_mut_ptr());
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(),
@ -42,7 +39,12 @@ impl Mac {
/// 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_CMD_BUFFER.as_mut_ptr(), TlPacketType::OtAck, 0, &[]);
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>(

View File

@ -4,6 +4,7 @@ use core::ptr;
use crate::cmd::CmdPacket;
use crate::consts::TlPacketType;
use crate::evt::{CcEvt, EvtBox, EvtPacket};
#[allow(unused_imports)]
use crate::shci::{SchiCommandStatus, ShciBleInitCmdParam, ShciOpcode};
use crate::tables::{SysTable, WirelessFwInfoTable};
use crate::unsafe_linked_list::LinkedListNode;