diff options
Diffstat (limited to 'embassy-stm32-wpan/src/shci.rs')
| -rw-r--r-- | embassy-stm32-wpan/src/shci.rs | 18 |
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 @@ | |||
| 1 | use core::{mem, slice}; | 1 | use core::sync::atomic::{Ordering, compiler_fence}; |
| 2 | use core::{mem, ptr, slice}; | ||
| 2 | 3 | ||
| 4 | use crate::PacketHeader; | ||
| 5 | use crate::cmd::CmdPacket; | ||
| 3 | use crate::consts::{TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE}; | 6 | use crate::consts::{TL_CS_EVT_SIZE, TL_EVT_HEADER_SIZE, TL_PACKET_HEADER_SIZE}; |
| 7 | use crate::evt::{CcEvt, EvtStub}; | ||
| 4 | 8 | ||
| 5 | const SHCI_OGF: u16 = 0x3F; | 9 | const SHCI_OGF: u16 = 0x3F; |
| 6 | 10 | ||
| @@ -21,6 +25,18 @@ pub enum SchiCommandStatus { | |||
| 21 | ShciFusCmdNotSupported = 0xFF, | 25 | ShciFusCmdNotSupported = 0xFF, |
| 22 | } | 26 | } |
| 23 | 27 | ||
| 28 | impl 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 | |||
| 24 | impl TryFrom<u8> for SchiCommandStatus { | 40 | impl TryFrom<u8> for SchiCommandStatus { |
| 25 | type Error = (); | 41 | type Error = (); |
| 26 | 42 | ||
