diff --git a/embassy-stm32-wpan/src/evt.rs b/embassy-stm32-wpan/src/evt.rs index 25249a13..22f08903 100644 --- a/embassy-stm32-wpan/src/evt.rs +++ b/embassy-stm32-wpan/src/evt.rs @@ -145,14 +145,14 @@ impl Drop for EvtBox { fn drop(&mut self) { #[cfg(feature = "ble")] unsafe { - use crate::mm; + use crate::sub::mm; mm::MemoryManager::drop_event_packet(self.ptr) }; #[cfg(feature = "mac")] unsafe { - use crate::mac; + use crate::sub::mac; mac::Mac::drop_event_packet(self.ptr) } diff --git a/embassy-stm32-wpan/src/lhci.rs b/embassy-stm32-wpan/src/lhci.rs index 62116a69..28410370 100644 --- a/embassy-stm32-wpan/src/lhci.rs +++ b/embassy-stm32-wpan/src/lhci.rs @@ -1,7 +1,9 @@ +use core::ptr; + use crate::cmd::CmdPacket; use crate::consts::{TlPacketType, TL_EVT_HEADER_SIZE}; use crate::evt::{CcEvt, EvtPacket, EvtSerial}; -use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable}; +use crate::tables::{DeviceInfoTable, RssInfoTable, SafeBootInfoTable, WirelessFwInfoTable, TL_DEVICE_INFO_TABLE}; use crate::TL_REF_TABLE; const TL_BLEEVT_CC_OPCODE: u8 = 0x0e; @@ -38,7 +40,7 @@ impl Default for LhciC1DeviceInformationCcrp { safe_boot_info_table, rss_info_table, wireless_fw_info_table, - } = unsafe { &*(*TL_REF_TABLE.as_ptr()).device_info_table }.clone(); + } = unsafe { ptr::read_volatile(TL_DEVICE_INFO_TABLE.as_ptr()) }; let device_id = stm32_device_signature::device_id(); let uid96_0 = (device_id[3] as u32) << 24 @@ -105,7 +107,7 @@ impl LhciC1DeviceInformationCcrp { let self_ptr: *const LhciC1DeviceInformationCcrp = self; let self_buf = self_ptr.cast(); - core::ptr::copy(self_buf, evt_cc_payload_buf, self_size); + ptr::copy(self_buf, evt_cc_payload_buf, self_size); } } } diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index bf0f0466..99c61058 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}; use embassy_stm32::interrupt; use embassy_stm32::ipcc::{Config, Ipcc, ReceiveInterruptHandler, TransmitInterruptHandler}; use embassy_stm32::peripherals::IPCC; -use mm::MemoryManager; -use sys::Sys; +use sub::mm::MemoryManager; +use sub::sys::Sys; use tables::*; use unsafe_linked_list::LinkedListNode; -#[cfg(feature = "ble")] -pub mod ble; pub mod channels; pub mod cmd; pub mod consts; pub mod evt; pub mod lhci; -#[cfg(feature = "mac")] -pub mod mac; -pub mod mm; pub mod shci; -pub mod sys; +pub mod sub; pub mod tables; pub mod unsafe_linked_list; +#[cfg(feature = "ble")] +pub use crate::sub::ble::hci; + type PacketHeader = LinkedListNode; pub struct TlMbox<'d> { @@ -39,9 +37,9 @@ pub struct TlMbox<'d> { pub sys_subsystem: Sys, pub mm_subsystem: MemoryManager, #[cfg(feature = "ble")] - pub ble_subsystem: ble::Ble, + pub ble_subsystem: sub::ble::Ble, #[cfg(feature = "mac")] - pub mac_subsystem: mac::Mac, + pub mac_subsystem: sub::mac::Mac, } impl<'d> TlMbox<'d> { @@ -128,12 +126,12 @@ impl<'d> TlMbox<'d> { Self { _ipcc: ipcc, - sys_subsystem: sys::Sys::new(), + sys_subsystem: sub::sys::Sys::new(), #[cfg(feature = "ble")] - ble_subsystem: ble::Ble::new(), + ble_subsystem: sub::ble::Ble::new(), #[cfg(feature = "mac")] - mac_subsystem: mac::Mac::new(), - mm_subsystem: mm::MemoryManager::new(), + mac_subsystem: sub::mac::Mac::new(), + mm_subsystem: sub::mm::MemoryManager::new(), } } } diff --git a/embassy-stm32-wpan/src/ble.rs b/embassy-stm32-wpan/src/sub/ble.rs similarity index 100% rename from embassy-stm32-wpan/src/ble.rs rename to embassy-stm32-wpan/src/sub/ble.rs diff --git a/embassy-stm32-wpan/src/mac.rs b/embassy-stm32-wpan/src/sub/mac.rs similarity index 100% rename from embassy-stm32-wpan/src/mac.rs rename to embassy-stm32-wpan/src/sub/mac.rs diff --git a/embassy-stm32-wpan/src/mm.rs b/embassy-stm32-wpan/src/sub/mm.rs similarity index 100% rename from embassy-stm32-wpan/src/mm.rs rename to 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 00000000..bee3dbdf --- /dev/null +++ b/embassy-stm32-wpan/src/sub/mod.rs @@ -0,0 +1,6 @@ +#[cfg(feature = "ble")] +pub mod ble; +#[cfg(feature = "mac")] +pub mod mac; +pub mod mm; +pub mod sys; diff --git a/embassy-stm32-wpan/src/sys.rs b/embassy-stm32-wpan/src/sub/sys.rs similarity index 100% rename from embassy-stm32-wpan/src/sys.rs rename to 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 fdd5be4a..b99f8cb2 100644 --- a/examples/stm32wb/src/bin/eddystone_beacon.rs +++ b/examples/stm32wb/src/bin/eddystone_beacon.rs @@ -8,15 +8,15 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::bind_interrupts; use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; -use embassy_stm32_wpan::ble::hci::host::uart::UartHci; -use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; -use embassy_stm32_wpan::ble::hci::types::AdvertisingType; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ +use embassy_stm32_wpan::hci::host::uart::UartHci; +use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; +use embassy_stm32_wpan::hci::types::AdvertisingType; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ AdvertisingDataType, DiscoverableParameters, GapCommands, Role, }; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; -use embassy_stm32_wpan::ble::hci::BdAddr; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; +use embassy_stm32_wpan::hci::BdAddr; use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; use embassy_stm32_wpan::TlMbox; 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 76c736a5..8880554d 100644 --- a/tests/stm32/src/bin/tl_mbox.rs +++ b/tests/stm32/src/bin/tl_mbox.rs @@ -12,17 +12,18 @@ use common::*; use embassy_executor::Spawner; use embassy_stm32::bind_interrupts; use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; -use embassy_stm32_wpan::ble::hci::host::uart::UartHci; -use embassy_stm32_wpan::ble::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; -use embassy_stm32_wpan::ble::hci::types::AdvertisingType; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gap::{ +use embassy_stm32_wpan::hci::host::uart::UartHci; +use embassy_stm32_wpan::hci::host::{AdvertisingFilterPolicy, EncryptionKey, HostHci, OwnAddressType}; +use embassy_stm32_wpan::hci::types::AdvertisingType; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::gap::{ AdvertisingDataType, DiscoverableParameters, GapCommands, Role, }; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::gatt::GattCommands; -use embassy_stm32_wpan::ble::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; -use embassy_stm32_wpan::ble::hci::BdAddr; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::gatt::GattCommands; +use embassy_stm32_wpan::hci::vendor::stm32wb::command::hal::{ConfigData, HalCommands, PowerLevel}; +use embassy_stm32_wpan::hci::BdAddr; use embassy_stm32_wpan::lhci::LhciC1DeviceInformationCcrp; -use embassy_stm32_wpan::{mm, TlMbox}; +use embassy_stm32_wpan::sub::mm; +use embassy_stm32_wpan::TlMbox; use {defmt_rtt as _, panic_probe as _}; bind_interrupts!(struct Irqs{