diff options
| author | xoviat <[email protected]> | 2023-06-23 17:54:06 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-06-23 17:54:06 -0500 |
| commit | 29f32ce00ec0f50ef5e3b29c7e50f7f5479b4967 (patch) | |
| tree | ab2d04d6cce0de6471a24aae4a68bf36011170e4 | |
| parent | 4dd48099bee305fc31e47a586f34d09c3ec02673 (diff) | |
stm32/wpan: reorg subsystems
| -rw-r--r-- | embassy-stm32-wpan/src/evt.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lhci.rs | 8 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/lib.rs | 26 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/ble.rs (renamed from embassy-stm32-wpan/src/ble.rs) | 0 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mac.rs (renamed from embassy-stm32-wpan/src/mac.rs) | 0 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mm.rs (renamed from embassy-stm32-wpan/src/mm.rs) | 0 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/mod.rs | 6 | ||||
| -rw-r--r-- | embassy-stm32-wpan/src/sub/sys.rs (renamed from embassy-stm32-wpan/src/sys.rs) | 0 | ||||
| -rw-r--r-- | examples/stm32wb/src/bin/eddystone_beacon.rs | 14 | ||||
| -rw-r--r-- | tests/stm32/src/bin/tl_mbox.rs | 17 |
10 files changed, 41 insertions, 34 deletions
diff --git a/embassy-stm32-wpan/src/evt.rs b/embassy-stm32-wpan/src/evt.rs index 25249a13a..22f089037 100644 --- a/embassy-stm32-wpan/src/evt.rs +++ b/embassy-stm32-wpan/src/evt.rs | |||
| @@ -145,14 +145,14 @@ impl Drop for EvtBox { | |||
| 145 | fn drop(&mut self) { | 145 | fn drop(&mut self) { |
| 146 | #[cfg(feature = "ble")] | 146 | #[cfg(feature = "ble")] |
| 147 | unsafe { | 147 | unsafe { |
| 148 | use crate::mm; | 148 | use crate::sub::mm; |
| 149 | 149 | ||
| 150 | mm::MemoryManager::drop_event_packet(self.ptr) | 150 | mm::MemoryManager::drop_event_packet(self.ptr) |
| 151 | }; | 151 | }; |
| 152 | 152 | ||
| 153 | #[cfg(feature = "mac")] | 153 | #[cfg(feature = "mac")] |
| 154 | unsafe { | 154 | unsafe { |
| 155 | use crate::mac; | 155 | use crate::sub::mac; |
| 156 | 156 | ||
| 157 | mac::Mac::drop_event_packet(self.ptr) | 157 | mac::Mac::drop_event_packet(self.ptr) |
| 158 | } | 158 | } |
diff --git a/embassy-stm32-wpan/src/lhci.rs b/embassy-stm32-wpan/src/lhci.rs index 62116a695..284103705 100644 --- a/embassy-stm32-wpan/src/lhci.rs +++ b/embassy-stm32-wpan/src/lhci.rs | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | use core::ptr; | ||
| 2 | |||
| 1 | use crate::cmd::CmdPacket; | 3 | use crate::cmd::CmdPacket; |
| 2 | use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; | 4 | use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; |
| 3 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; | 5 | use crate::evt::{CcEvt, EvtPacket, EvtSerial}; |
| 4 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable}; | 6 | use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable, TL_DEVICE_INFO_TABLE}; |
| 5 | use crate::TL_REF_TABLE; | 7 | use crate::TL_REF_TABLE; |
| 6 | 8 | ||
| 7 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; | 9 | const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; |
| @@ -38,7 +40,7 @@ impl Default for LhciC1DeviceInformationCcrp { | |||
| 38 | safe_boot_info_table, | 40 | safe_boot_info_table, |
| 39 | rss_info_table, | 41 | rss_info_table, |
| 40 | wireless_fw_info_table, | 42 | wireless_fw_info_table, |
| 41 | } = unsafe { &*(*TL_REF_TABLE.as_ptr()).device_info_table }.clone(); | 43 | } = unsafe { ptr::read_volatile(TL_DEVICE_INFO_TABLE.as_ptr()) }; |
| 42 | 44 | ||
| 43 | let device_id = stm32_device_signature::device_id(); | 45 | let device_id = stm32_device_signature::device_id(); |
| 44 | let uid96_0 = (device_id[3] as u32) << 24 | 46 | let uid96_0 = (device_id[3] as u32) << 24 |
| @@ -105,7 +107,7 @@ impl LhciC1DeviceInformationCcrp { | |||
| 105 | let self_ptr: *const LhciC1DeviceInformationCcrp = self; | 107 | let self_ptr: *const LhciC1DeviceInformationCcrp = self; |
| 106 | let self_buf = self_ptr.cast(); | 108 | let self_buf = self_ptr.cast(); |
| 107 | 109 | ||
| 108 | core::ptr::copy(self_buf, evt_cc_payload_buf, self_size); | 110 | ptr::copy(self_buf, evt_cc_payload_buf, self_size); |
| 109 | } | 111 | } |
| 110 | } | 112 | } |
| 111 | } | 113 | } |
diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index bf0f0466e..99c610583 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs | |||
| @@ -11,26 +11,24 @@ use embassy_hal_common::{into_ref, Peripheral, PeripheralRef}; | |||
| 11 | use embassy_stm32::interrupt; | 11 | use embassy_stm32::interrupt; |
| 12 | use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler}; | 12 | use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 13 | use embassy_stm32::peripherals::IPCC; | 13 | use embassy_stm32::peripherals::IPCC; |
| 14 | use mm::MemoryManager; | 14 | use sub::mm::MemoryManager; |
| 15 | use sys::Sys; | 15 | use sub::sys::Sys; |
| 16 | use tables::*; | 16 | use tables::*; |
| 17 | use unsafe_linked_list::LinkedListNode; | 17 | use unsafe_linked_list::LinkedListNode; |
| 18 | 18 | ||
| 19 | #[cfg(feature = "ble")] | ||
| 20 | pub mod ble; | ||
| 21 | pub mod channels; | 19 | pub mod channels; |
| 22 | pub mod cmd; | 20 | pub mod cmd; |
| 23 | pub mod consts; | 21 | pub mod consts; |
| 24 | pub mod evt; | 22 | pub mod evt; |
| 25 | pub mod lhci; | 23 | pub mod lhci; |
| 26 | #[cfg(feature = "mac")] | ||
| 27 | pub mod mac; | ||
| 28 | pub mod mm; | ||
| 29 | pub mod shci; | 24 | pub mod shci; |
| 30 | pub mod sys; | 25 | pub mod sub; |
| 31 | pub mod tables; | 26 | pub mod tables; |
| 32 | pub mod unsafe_linked_list; | 27 | pub mod unsafe_linked_list; |
| 33 | 28 | ||
| 29 | #[cfg(feature = "ble")] | ||
| 30 | pub use crate::sub::ble::hci; | ||
| 31 | |||
| 34 | type PacketHeader = LinkedListNode; | 32 | type PacketHeader = LinkedListNode; |
| 35 | 33 | ||
| 36 | pub struct TlMbox<'d> { | 34 | pub struct TlMbox<'d> { |
| @@ -39,9 +37,9 @@ pub struct TlMbox<'d> { | |||
| 39 | pub sys_subsystem: Sys, | 37 | pub sys_subsystem: Sys, |
| 40 | pub mm_subsystem: MemoryManager, | 38 | pub mm_subsystem: MemoryManager, |
| 41 | #[cfg(feature = "ble")] | 39 | #[cfg(feature = "ble")] |
| 42 | pub ble_subsystem: ble::Ble, | 40 | pub ble_subsystem: sub::ble::Ble, |
| 43 | #[cfg(feature = "mac")] | 41 | #[cfg(feature = "mac")] |
| 44 | pub mac_subsystem: mac::Mac, | 42 | pub mac_subsystem: sub::mac::Mac, |
| 45 | } | 43 | } |
| 46 | 44 | ||
| 47 | impl<'d> TlMbox<'d> { | 45 | impl<'d> TlMbox<'d> { |
| @@ -128,12 +126,12 @@ impl<'d> TlMbox<'d> { | |||
| 128 | 126 | ||
| 129 | Self { | 127 | Self { |
| 130 | _ipcc: ipcc, | 128 | _ipcc: ipcc, |
| 131 | sys_subsystem: sys::Sys::new(), | 129 | sys_subsystem: sub::sys::Sys::new(), |
| 132 | #[cfg(feature = "ble")] | 130 | #[cfg(feature = "ble")] |
| 133 | ble_subsystem: ble::Ble::new(), | 131 | ble_subsystem: sub::ble::Ble::new(), |
| 134 | #[cfg(feature = "mac")] | 132 | #[cfg(feature = "mac")] |
| 135 | mac_subsystem: mac::Mac::new(), | 133 | mac_subsystem: sub::mac::Mac::new(), |
| 136 | mm_subsystem: mm::MemoryManager::new(), | 134 | mm_subsystem: sub::mm::MemoryManager::new(), |
| 137 | } | 135 | } |
| 138 | } | 136 | } |
| 139 | } | 137 | } |
diff --git a/embassy-stm32-wpan/src/ble.rs b/embassy-stm32-wpan/src/sub/ble.rs index 619cd66a0..619cd66a0 100644 --- a/embassy-stm32-wpan/src/ble.rs +++ b/embassy-stm32-wpan/src/sub/ble.rs | |||
diff --git a/embassy-stm32-wpan/src/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs index d2be1b85c..d2be1b85c 100644 --- a/embassy-stm32-wpan/src/mac.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs | |||
diff --git a/embassy-stm32-wpan/src/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs index 047fddcd4..047fddcd4 100644 --- a/embassy-stm32-wpan/src/mm.rs +++ b/embassy-stm32-wpan/src/sub/mm.rs | |||
diff --git a/embassy-stm32-wpan/src/sub/mod.rs b/embassy-stm32-wpan/src/sub/mod.rs new file mode 100644 index 000000000..bee3dbdf1 --- /dev/null +++ b/embassy-stm32-wpan/src/sub/mod.rs | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #[cfg(feature = "ble")] | ||
| 2 | pub mod ble; | ||
| 3 | #[cfg(feature = "mac")] | ||
| 4 | pub mod mac; | ||
| 5 | pub mod mm; | ||
| 6 | pub mod sys; | ||
diff --git a/embassy-stm32-wpan/src/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs index 2b699b725..2b699b725 100644 --- a/embassy-stm32-wpan/src/sys.rs +++ b/embassy-stm32-wpan/src/sub/sys.rs | |||
diff --git a/examples/stm32wb/src/bin/eddystone_beacon.rs b/examples/stm32wb/src/bin/eddystone_beacon.rs index fdd5be4a2..b99f8cb2e 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs | |||
| @@ -8,15 +8,15 @@ use defmt::*; | |||
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::bind_interrupts; | 9 | use embassy_stm32::bind_interrupts; |
| 10 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 10 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 11 | use embassy_stm32_wpan::ble::hci::host::uart::UartHci; | 11 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 12 | use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 12 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 13 | use embassy_stm32_wpan::ble::hci::types::AdvertisingType; | 13 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 14 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ | 14 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ |
| 15 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 15 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, |
| 16 | }; | 16 | }; |
| 17 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; | 17 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; |
| 18 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 19 | use embassy_stm32_wpan::ble::hci::BdAddr; | 19 | use embassy_stm32_wpan::hci::BdAddr; |
| 20 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 20 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 21 | use embassy_stm32_wpan::TlMbox; | 21 | use embassy_stm32_wpan::TlMbox; |
| 22 | use {defmt_rtt as _, panic_probe as _}; | 22 | use {defmt_rtt as _, panic_probe as _}; |
diff --git a/tests/stm32/src/bin/tl_mbox.rs b/tests/stm32/src/bin/tl_mbox.rs index 76c736a5b..8880554de 100644 --- a/tests/stm32/src/bin/tl_mbox.rs +++ b/tests/stm32/src/bin/tl_mbox.rs | |||
| @@ -12,17 +12,18 @@ use common::*; | |||
| 12 | use embassy_executor::Spawner; | 12 | use embassy_executor::Spawner; |
| 13 | use embassy_stm32::bind_interrupts; | 13 | use embassy_stm32::bind_interrupts; |
| 14 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; | 14 | use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; |
| 15 | use embassy_stm32_wpan::ble::hci::host::uart::UartHci; | 15 | use embassy_stm32_wpan::hci::host::uart::UartHci; |
| 16 | use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; | 16 | use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; |
| 17 | use embassy_stm32_wpan::ble::hci::types::AdvertisingType; | 17 | use embassy_stm32_wpan::hci::types::AdvertisingType; |
| 18 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ | 18 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ |
| 19 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, | 19 | AdvertisingDataType, DiscoverableParameters, GapCommands, Role, |
| 20 | }; | 20 | }; |
| 21 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; | 21 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; |
| 22 | use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; | 22 | use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; |
| 23 | use embassy_stm32_wpan::ble::hci::BdAddr; | 23 | use embassy_stm32_wpan::hci::BdAddr; |
| 24 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; | 24 | use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; |
| 25 | use embassy_stm32_wpan::{mm, TlMbox}; | 25 | use embassy_stm32_wpan::sub::mm; |
| 26 | use embassy_stm32_wpan::TlMbox; | ||
| 26 | use {defmt_rtt as _, panic_probe as _}; | 27 | use {defmt_rtt as _, panic_probe as _}; |
| 27 | 28 | ||
| 28 | bind_interrupts!(struct Irqs{ | 29 | bind_interrupts!(struct Irqs{ |
