aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32-wpan/src/shci.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-stm32-wpan/src/shci.rs')
-rw-r--r--embassy-stm32-wpan/src/shci.rs18
1 files changed, 17 insertions, 1 deletions
diff --git a/embassy-stm32-wpan/src/shci.rs b/embassy-stm32-wpan/src/shci.rs
index 1946c55fd..2d94a9cda 100644
--- a/embassy-stm32-wpan/src/shci.rs
+++ b/embassy-stm32-wpan/src/shci.rs
@@ -1,6 +1,10 @@
1use core::{mem, slice}; 1use core::sync::atomic::{Ordering, compiler_fence};
2use core::{mem, ptr, slice};
2 3
4use crate::PacketHeader;
5use crate::cmd::CmdPacket;
3use crate::consts::{TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE}; 6use crate::consts::{TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE};
7use crate::evt::{CcEvt, EvtStub};
4 8
5const SHCI_OGF: u16 = 0x3F; 9const SHCI_OGF: u16 = 0x3F;
6 10
@@ -21,6 +25,18 @@ pub enum SchiCommandStatus {
21 ShciFusCmdNotSupported = 0xFF, 25 ShciFusCmdNotSupported = 0xFF,
22} 26}
23 27
28impl SchiCommandStatus {
29 pub unsafe fn from_packet(cmd_buf: *const CmdPacket) -> Result<Self, ()> {
30 let p_cmd_serial = (cmd_buf as *mut u8).add(size_of::<PacketHeader>());
31 let p_evt_payload = p_cmd_serial.add(size_of::<EvtStub>());
32
33 compiler_fence(Ordering::Acquire);
34 let cc_evt = ptr::read_unaligned(p_evt_payload as *const CcEvt);
35
36 cc_evt.payload[0].try_into()
37 }
38}
39
24impl TryFrom<u8> for SchiCommandStatus { 40impl TryFrom<u8> for SchiCommandStatus {
25 type Error = (); 41 type Error = ();
26 42