From 4db4200c37c191f4ec018dd318e805aa805d9cc3 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sat, 15 Jul 2023 14:47:34 -0500 Subject: [PATCH] wpan: factor mac logic into other mod --- embassy-stm32-wpan/src/lib.rs | 3 +++ embassy-stm32-wpan/src/{sub => }/mac/commands.rs | 0 embassy-stm32-wpan/src/{sub => }/mac/consts.rs | 0 embassy-stm32-wpan/src/{sub => }/mac/event.rs | 2 +- embassy-stm32-wpan/src/{sub => }/mac/helpers.rs | 0 .../src/{sub => }/mac/indications.rs | 0 embassy-stm32-wpan/src/{sub => }/mac/macros.rs | 0 embassy-stm32-wpan/src/mac/mod.rs | 9 +++++++++ embassy-stm32-wpan/src/{sub => }/mac/opcodes.rs | 0 .../src/{sub => }/mac/responses.rs | 0 embassy-stm32-wpan/src/{sub => }/mac/typedefs.rs | 0 .../src/sub/{mac/mod.rs => mac.rs} | 16 +++------------- examples/stm32wb/src/bin/mac_ffd.rs | 6 +++--- examples/stm32wb/src/bin/mac_rfd.rs | 6 +++--- tests/stm32/src/bin/wpan_mac.rs | 6 +++--- 15 files changed, 25 insertions(+), 23 deletions(-) rename embassy-stm32-wpan/src/{sub => }/mac/commands.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/consts.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/event.rs (99%) rename embassy-stm32-wpan/src/{sub => }/mac/helpers.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/indications.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/macros.rs (100%) create mode 100644 embassy-stm32-wpan/src/mac/mod.rs rename embassy-stm32-wpan/src/{sub => }/mac/opcodes.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/responses.rs (100%) rename embassy-stm32-wpan/src/{sub => }/mac/typedefs.rs (100%) rename embassy-stm32-wpan/src/sub/{mac/mod.rs => mac.rs} (94%) diff --git a/embassy-stm32-wpan/src/lib.rs b/embassy-stm32-wpan/src/lib.rs index 3a45c597..57f0dc4f 100644 --- a/embassy-stm32-wpan/src/lib.rs +++ b/embassy-stm32-wpan/src/lib.rs @@ -26,6 +26,9 @@ pub mod sub; pub mod tables; pub mod unsafe_linked_list; +#[cfg(feature = "mac")] +pub mod mac; + #[cfg(feature = "ble")] pub use crate::sub::ble::hci; diff --git a/embassy-stm32-wpan/src/sub/mac/commands.rs b/embassy-stm32-wpan/src/mac/commands.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/commands.rs rename to embassy-stm32-wpan/src/mac/commands.rs diff --git a/embassy-stm32-wpan/src/sub/mac/consts.rs b/embassy-stm32-wpan/src/mac/consts.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/consts.rs rename to embassy-stm32-wpan/src/mac/consts.rs diff --git a/embassy-stm32-wpan/src/sub/mac/event.rs b/embassy-stm32-wpan/src/mac/event.rs similarity index 99% rename from embassy-stm32-wpan/src/sub/mac/event.rs rename to embassy-stm32-wpan/src/mac/event.rs index aaf96556..dfce21fe 100644 --- a/embassy-stm32-wpan/src/sub/mac/event.rs +++ b/embassy-stm32-wpan/src/mac/event.rs @@ -7,7 +7,7 @@ use super::responses::{ AssociateConfirm, CalibrateConfirm, DataConfirm, DisassociateConfirm, DpsConfirm, GetConfirm, GtsConfirm, PollConfirm, PurgeConfirm, ResetConfirm, RxEnableConfirm, ScanConfirm, SetConfirm, SoundingConfirm, StartConfirm, }; -use crate::sub::mac::opcodes::OpcodeM0ToM4; +use crate::mac::opcodes::OpcodeM0ToM4; pub trait ParseableMacEvent { const SIZE: usize; diff --git a/embassy-stm32-wpan/src/sub/mac/helpers.rs b/embassy-stm32-wpan/src/mac/helpers.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/helpers.rs rename to embassy-stm32-wpan/src/mac/helpers.rs diff --git a/embassy-stm32-wpan/src/sub/mac/indications.rs b/embassy-stm32-wpan/src/mac/indications.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/indications.rs rename to embassy-stm32-wpan/src/mac/indications.rs diff --git a/embassy-stm32-wpan/src/sub/mac/macros.rs b/embassy-stm32-wpan/src/mac/macros.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/macros.rs rename to embassy-stm32-wpan/src/mac/macros.rs diff --git a/embassy-stm32-wpan/src/mac/mod.rs b/embassy-stm32-wpan/src/mac/mod.rs new file mode 100644 index 00000000..1af8fe6b --- /dev/null +++ b/embassy-stm32-wpan/src/mac/mod.rs @@ -0,0 +1,9 @@ +pub mod commands; +mod consts; +pub mod event; +mod helpers; +pub mod indications; +mod macros; +mod opcodes; +pub mod responses; +pub mod typedefs; diff --git a/embassy-stm32-wpan/src/sub/mac/opcodes.rs b/embassy-stm32-wpan/src/mac/opcodes.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/opcodes.rs rename to embassy-stm32-wpan/src/mac/opcodes.rs diff --git a/embassy-stm32-wpan/src/sub/mac/responses.rs b/embassy-stm32-wpan/src/mac/responses.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/responses.rs rename to embassy-stm32-wpan/src/mac/responses.rs diff --git a/embassy-stm32-wpan/src/sub/mac/typedefs.rs b/embassy-stm32-wpan/src/mac/typedefs.rs similarity index 100% rename from embassy-stm32-wpan/src/sub/mac/typedefs.rs rename to embassy-stm32-wpan/src/mac/typedefs.rs diff --git a/embassy-stm32-wpan/src/sub/mac/mod.rs b/embassy-stm32-wpan/src/sub/mac.rs similarity index 94% rename from embassy-stm32-wpan/src/sub/mac/mod.rs rename to embassy-stm32-wpan/src/sub/mac.rs index ab39f89c..4893cb47 100644 --- a/embassy-stm32-wpan/src/sub/mac/mod.rs +++ b/embassy-stm32-wpan/src/sub/mac.rs @@ -8,25 +8,15 @@ use embassy_futures::poll_once; use embassy_stm32::ipcc::Ipcc; use embassy_sync::waitqueue::AtomicWaker; -use self::commands::MacCommand; -use self::event::MacEvent; -use self::typedefs::MacError; use crate::cmd::CmdPacket; use crate::consts::TlPacketType; use crate::evt::{EvtBox, EvtPacket}; +use crate::mac::commands::MacCommand; +use crate::mac::event::MacEvent; +use crate::mac::typedefs::MacError; use crate::tables::{MAC_802_15_4_CMD_BUFFER, MAC_802_15_4_NOTIF_RSP_EVT_BUFFER}; use crate::{channels, evt}; -pub mod commands; -mod consts; -pub mod event; -mod helpers; -pub mod indications; -mod macros; -mod opcodes; -pub mod responses; -pub mod typedefs; - static MAC_WAKER: AtomicWaker = AtomicWaker::new(); static MAC_EVT_OUT: AtomicBool = AtomicBool::new(false); diff --git a/examples/stm32wb/src/bin/mac_ffd.rs b/examples/stm32wb/src/bin/mac_ffd.rs index 689a2835..e4d81997 100644 --- a/examples/stm32wb/src/bin/mac_ffd.rs +++ b/examples/stm32wb/src/bin/mac_ffd.rs @@ -6,9 +6,9 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::bind_interrupts; use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; -use embassy_stm32_wpan::sub::mac::commands::{AssociateResponse, ResetRequest, SetRequest, StartRequest}; -use embassy_stm32_wpan::sub::mac::event::MacEvent; -use embassy_stm32_wpan::sub::mac::typedefs::{MacChannel, MacStatus, PanId, PibId, SecurityLevel}; +use embassy_stm32_wpan::mac::commands::{AssociateResponse, ResetRequest, SetRequest, StartRequest}; +use embassy_stm32_wpan::mac::event::MacEvent; +use embassy_stm32_wpan::mac::typedefs::{MacChannel, MacStatus, PanId, PibId, SecurityLevel}; use embassy_stm32_wpan::sub::mm; use embassy_stm32_wpan::TlMbox; use {defmt_rtt as _, panic_probe as _}; diff --git a/examples/stm32wb/src/bin/mac_rfd.rs b/examples/stm32wb/src/bin/mac_rfd.rs index ea349f9a..b2dac72c 100644 --- a/examples/stm32wb/src/bin/mac_rfd.rs +++ b/examples/stm32wb/src/bin/mac_rfd.rs @@ -6,9 +6,9 @@ use defmt::*; use embassy_executor::Spawner; use embassy_stm32::bind_interrupts; use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; -use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, DataRequest, GetRequest, ResetRequest, SetRequest}; -use embassy_stm32_wpan::sub::mac::event::MacEvent; -use embassy_stm32_wpan::sub::mac::typedefs::{ +use embassy_stm32_wpan::mac::commands::{AssociateRequest, DataRequest, GetRequest, ResetRequest, SetRequest}; +use embassy_stm32_wpan::mac::event::MacEvent; +use embassy_stm32_wpan::mac::typedefs::{ AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, }; use embassy_stm32_wpan::sub::mm; diff --git a/tests/stm32/src/bin/wpan_mac.rs b/tests/stm32/src/bin/wpan_mac.rs index d97a4d40..cfa0aca3 100644 --- a/tests/stm32/src/bin/wpan_mac.rs +++ b/tests/stm32/src/bin/wpan_mac.rs @@ -10,9 +10,9 @@ use common::*; use embassy_executor::Spawner; use embassy_stm32::bind_interrupts; use embassy_stm32::ipcc::{Config, ReceiveInterruptHandler, TransmitInterruptHandler}; -use embassy_stm32_wpan::sub::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest}; -use embassy_stm32_wpan::sub::mac::event::MacEvent; -use embassy_stm32_wpan::sub::mac::typedefs::{ +use embassy_stm32_wpan::mac::commands::{AssociateRequest, GetRequest, ResetRequest, SetRequest}; +use embassy_stm32_wpan::mac::event::MacEvent; +use embassy_stm32_wpan::mac::typedefs::{ AddressMode, Capabilities, KeyIdMode, MacAddress, MacChannel, PanId, PibId, SecurityLevel, }; use embassy_stm32_wpan::sub::mm;