aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxoviat <[email protected]>2025-12-16 13:03:20 +0000
committerGitHub <[email protected]>2025-12-16 13:03:20 +0000
commitc283ba36eb5516cdedc46acf6f9f234859161e2a (patch)
tree62eab463fa44f5f4e88451de6f06e74986a56b43
parent5ae6e060ec1c90561719aabdc29d5b6e7b8b0a82 (diff)
parent03250ec269382f0d9c1a7a832adf32e2bdd7c265 (diff)
Merge pull request #5083 from xoviat/wba
wpan: build mac_ffd
-rw-r--r--embassy-stm32-wpan/src/wba/linklayer_plat.rs35
-rw-r--r--examples/stm32wba/src/bin/mac_ffd.rs8
2 files changed, 25 insertions, 18 deletions
diff --git a/embassy-stm32-wpan/src/wba/linklayer_plat.rs b/embassy-stm32-wpan/src/wba/linklayer_plat.rs
index 108e84efe..e6a342b52 100644
--- a/embassy-stm32-wpan/src/wba/linklayer_plat.rs
+++ b/embassy-stm32-wpan/src/wba/linklayer_plat.rs
@@ -102,7 +102,6 @@ type Callback = unsafe extern "C" fn();
102struct RawInterrupt(u16); 102struct RawInterrupt(u16);
103 103
104impl RawInterrupt { 104impl RawInterrupt {
105 #[inline(always)]
106 fn new(irq: u32) -> Self { 105 fn new(irq: u32) -> Self {
107 debug_assert!(irq <= u16::MAX as u32); 106 debug_assert!(irq <= u16::MAX as u32);
108 Self(irq as u16) 107 Self(irq as u16)
@@ -110,7 +109,6 @@ impl RawInterrupt {
110} 109}
111 110
112impl From<u32> for RawInterrupt { 111impl From<u32> for RawInterrupt {
113 #[inline(always)]
114 fn from(value: u32) -> Self { 112 fn from(value: u32) -> Self {
115 Self::new(value) 113 Self::new(value)
116 } 114 }
@@ -143,22 +141,15 @@ static PRNG_INIT: AtomicBool = AtomicBool::new(false);
143// Only written when the IRQ disable counter transitions 0->1, and consumed when it transitions 1->0. 141// Only written when the IRQ disable counter transitions 0->1, and consumed when it transitions 1->0.
144static mut CS_RESTORE_STATE: Option<critical_section::RestoreState> = None; 142static mut CS_RESTORE_STATE: Option<critical_section::RestoreState> = None;
145 143
146unsafe extern "C" {
147 static SystemCoreClock: u32;
148}
149
150#[inline(always)]
151fn read_system_core_clock() -> u32 { 144fn read_system_core_clock() -> u32 {
152 unsafe { ptr::read_volatile(&SystemCoreClock) } 145 0
153} 146}
154 147
155#[inline(always)]
156fn store_callback(slot: &AtomicPtr<()>, cb: Option<Callback>) { 148fn store_callback(slot: &AtomicPtr<()>, cb: Option<Callback>) {
157 let ptr = cb.map_or(ptr::null_mut(), |f| f as *mut ()); 149 let ptr = cb.map_or(ptr::null_mut(), |f| f as *mut ());
158 slot.store(ptr, Ordering::Release); 150 slot.store(ptr, Ordering::Release);
159} 151}
160 152
161#[inline(always)]
162fn load_callback(slot: &AtomicPtr<()>) -> Option<Callback> { 153fn load_callback(slot: &AtomicPtr<()>) -> Option<Callback> {
163 let ptr = slot.load(Ordering::Acquire); 154 let ptr = slot.load(Ordering::Acquire);
164 if ptr.is_null() { 155 if ptr.is_null() {
@@ -168,7 +159,6 @@ fn load_callback(slot: &AtomicPtr<()>) -> Option<Callback> {
168 } 159 }
169} 160}
170 161
171#[inline(always)]
172fn priority_shift() -> u8 { 162fn priority_shift() -> u8 {
173 8 - NVIC_PRIO_BITS as u8 163 8 - NVIC_PRIO_BITS as u8
174} 164}
@@ -185,12 +175,10 @@ fn pack_priority(raw: u32) -> u8 {
185 (clamped << u32::from(shift)) as u8 175 (clamped << u32::from(shift)) as u8
186} 176}
187 177
188#[inline(always)]
189fn counter_release(counter: &AtomicI32) -> bool { 178fn counter_release(counter: &AtomicI32) -> bool {
190 counter.fetch_sub(1, Ordering::SeqCst) <= 1 179 counter.fetch_sub(1, Ordering::SeqCst) <= 1
191} 180}
192 181
193#[inline(always)]
194fn counter_acquire(counter: &AtomicI32) -> bool { 182fn counter_acquire(counter: &AtomicI32) -> bool {
195 counter.fetch_add(1, Ordering::SeqCst) == 0 183 counter.fetch_add(1, Ordering::SeqCst) == 0
196} 184}
@@ -226,7 +214,6 @@ unsafe fn nvic_set_priority(irq: u32, priority: u8) {
226 isb(); 214 isb();
227} 215}
228 216
229#[inline(always)]
230fn set_basepri_max(value: u8) { 217fn set_basepri_max(value: u8) {
231 unsafe { 218 unsafe {
232 if basepri::read() < value { 219 if basepri::read() < value {
@@ -895,6 +882,7 @@ pub unsafe extern "C" fn LINKLAYER_PLAT_SCHLDR_TIMING_UPDATE_NOT(_timings: *cons
895// */ 882// */
896#[unsafe(no_mangle)] 883#[unsafe(no_mangle)]
897pub unsafe extern "C" fn LINKLAYER_PLAT_GetSTCompanyID() -> u32 { 884pub unsafe extern "C" fn LINKLAYER_PLAT_GetSTCompanyID() -> u32 {
885 trace!("LINKLAYER_PLAT_GetSTCompanyID");
898 // STMicroelectronics Bluetooth SIG Company Identifier 886 // STMicroelectronics Bluetooth SIG Company Identifier
899 // TODO: Pull in update from latest stm32-generated-data 887 // TODO: Pull in update from latest stm32-generated-data
900 0x0030 888 0x0030
@@ -907,7 +895,26 @@ pub unsafe extern "C" fn LINKLAYER_PLAT_GetSTCompanyID() -> u32 {
907// */ 895// */
908#[unsafe(no_mangle)] 896#[unsafe(no_mangle)]
909pub unsafe extern "C" fn LINKLAYER_PLAT_GetUDN() -> u32 { 897pub unsafe extern "C" fn LINKLAYER_PLAT_GetUDN() -> u32 {
898 trace!("LINKLAYER_PLAT_GetUDN");
910 // Read the first 32 bits of the STM32 unique 96-bit ID 899 // Read the first 32 bits of the STM32 unique 96-bit ID
911 let uid = embassy_stm32::uid::uid(); 900 let uid = embassy_stm32::uid::uid();
912 u32::from_le_bytes([uid[0], uid[1], uid[2], uid[3]]) 901 u32::from_le_bytes([uid[0], uid[1], uid[2], uid[3]])
913} 902}
903
904#[unsafe(no_mangle)]
905pub unsafe extern "C" fn LINKLAYER_DEBUG_SIGNAL_SET() {
906 trace!("LINKLAYER_DEBUG_SIGNAL_SET");
907 todo!()
908}
909
910#[unsafe(no_mangle)]
911pub unsafe extern "C" fn LINKLAYER_DEBUG_SIGNAL_RESET() {
912 trace!("LINKLAYER_DEBUG_SIGNAL_RESET");
913 todo!()
914}
915
916#[unsafe(no_mangle)]
917pub unsafe extern "C" fn LINKLAYER_DEBUG_SIGNAL_TOGGLE() {
918 trace!("LINKLAYER_DEBUG_SIGNAL_TOGGLE");
919 todo!()
920}
diff --git a/examples/stm32wba/src/bin/mac_ffd.rs b/examples/stm32wba/src/bin/mac_ffd.rs
index b15fb3452..329a73c6d 100644
--- a/examples/stm32wba/src/bin/mac_ffd.rs
+++ b/examples/stm32wba/src/bin/mac_ffd.rs
@@ -5,7 +5,7 @@ use defmt::*;
5use embassy_executor::Spawner; 5use embassy_executor::Spawner;
6use embassy_stm32::Config; 6use embassy_stm32::Config;
7use embassy_stm32::rcc::{Sysclk, mux}; 7use embassy_stm32::rcc::{Sysclk, mux};
8use embassy_stm32_wpan::bindings::mac::ST_MAC_callbacks_t; 8use embassy_stm32_wpan::bindings::mac::{ST_MAC_callbacks_t, ST_MAC_init};
9use {defmt_rtt as _, panic_probe as _}; 9use {defmt_rtt as _, panic_probe as _};
10 10
11static _MAC_CALLBACKS: ST_MAC_callbacks_t = ST_MAC_callbacks_t { 11static _MAC_CALLBACKS: ST_MAC_callbacks_t = ST_MAC_callbacks_t {
@@ -50,9 +50,9 @@ async fn main(_spawner: Spawner) {
50 let _p = embassy_stm32::init(config); 50 let _p = embassy_stm32::init(config);
51 info!("Hello World!"); 51 info!("Hello World!");
52 52
53 // let status = unsafe { ST_MAC_init(&_MAC_CALLBACKS as *const _ as *mut _) }; 53 let status = unsafe { ST_MAC_init(&_MAC_CALLBACKS as *const _ as *mut _) };
54 // 54
55 // info!("mac init: {}", status); 55 info!("mac init: {}", status);
56 56
57 cortex_m::asm::bkpt(); 57 cortex_m::asm::bkpt();
58} 58}