diff options
Diffstat (limited to 'embassy-stm32-wpan/src/sub/sys.rs')
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/embassy-stm32-wpan/src/sub/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index bd2ea3f74..fcc2c651e 100644 --- a/embassy-stm32-wpan/src/sub/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
| @@ -10,6 +10,7 @@ use crate::tables::{SysTable, WirelessFwInfoTable}; | |||
| 10 | use crate::unsafe_linked_list::LinkedListNode; | 10 | use crate::unsafe_linked_list::LinkedListNode; |
| 11 | use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; | 11 | use crate::{channels, Ipcc, SYSTEM_EVT_QUEUE, SYS_CMD_BUF, TL_DEVICE_INFO_TABLE, TL_SYS_TABLE}; |
| 12 | 12 | ||
| 13 | /// A guard that, once constructed, allows for sys commands to be sent to CPU2. | ||
| 13 | pub struct Sys { | 14 | pub struct Sys { |
| 14 | _private: (), | 15 | _private: (), |
| 15 | } | 16 | } |
| @@ -86,12 +87,21 @@ impl Sys { | |||
| 86 | self.write_and_get_response(ShciOpcode::Mac802_15_4Init, &[]).await | 87 | self.write_and_get_response(ShciOpcode::Mac802_15_4Init, &[]).await |
| 87 | } | 88 | } |
| 88 | 89 | ||
| 90 | /// Send a request to CPU2 to initialise the BLE stack. | ||
| 91 | /// | ||
| 92 | /// This must be called before any BLE commands are sent via the BLE channel (according to | ||
| 93 | /// AN5289, Figures 65 and 66). It should only be called after CPU2 sends a system event, via | ||
| 94 | /// `HW_IPCC_SYS_EvtNot`, aka `IoBusCallBackUserEvt` (as detailed in Figure 65), aka [read]. | ||
| 89 | #[cfg(feature = "ble")] | 95 | #[cfg(feature = "ble")] |
| 90 | pub async fn shci_c2_ble_init(&self, param: ShciBleInitCmdParam) -> Result<SchiCommandStatus, ()> { | 96 | pub async fn shci_c2_ble_init(&self, param: ShciBleInitCmdParam) -> Result<SchiCommandStatus, ()> { |
| 91 | self.write_and_get_response(ShciOpcode::BleInit, param.payload()).await | 97 | self.write_and_get_response(ShciOpcode::BleInit, param.payload()).await |
| 92 | } | 98 | } |
| 93 | 99 | ||
| 94 | /// `HW_IPCC_SYS_EvtNot` | 100 | /// `HW_IPCC_SYS_EvtNot` |
| 101 | /// | ||
| 102 | /// This method takes the place of the `HW_IPCC_SYS_EvtNot`/`SysUserEvtRx`/`APPE_SysUserEvtRx`, | ||
| 103 | /// as the embassy implementation avoids the need to call C public bindings, and instead | ||
| 104 | /// handles the event channels directly. | ||
| 95 | pub async fn read(&self) -> EvtBox<mm::MemoryManager> { | 105 | pub async fn read(&self) -> EvtBox<mm::MemoryManager> { |
| 96 | Ipcc::receive(channels::cpu2::IPCC_SYSTEM_EVENT_CHANNEL, || unsafe { | 106 | Ipcc::receive(channels::cpu2::IPCC_SYSTEM_EVENT_CHANNEL, || unsafe { |
| 97 | if let Some(node_ptr) = LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr()) { | 107 | if let Some(node_ptr) = LinkedListNode::remove_head(SYSTEM_EVT_QUEUE.as_mut_ptr()) { |
