aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDion Dokter <[email protected]>2024-07-09 09:37:49 +0200
committerDion Dokter <[email protected]>2024-07-09 09:37:49 +0200
commitf6f312270f9b2c42b0112545ac356cd6f595505b (patch)
tree1b4f966d97b87decf60b71f37fde4bd1a90b06d9
parent203297b56912c05d2dd6a009ffeb433fb2ffbea6 (diff)
fmt
-rw-r--r--embassy-stm32/src/lib.rs21
-rw-r--r--embassy-stm32/src/rcc/mod.rs4
-rw-r--r--embassy-stm32/src/time.rs2
-rw-r--r--examples/stm32h755cm4/src/bin/blinky.rs6
-rw-r--r--examples/stm32h755cm7/src/bin/blinky.rs6
5 files changed, 18 insertions, 21 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 8f001f03b..88683bfe4 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -280,25 +280,24 @@ pub fn init(config: Config) -> Peripherals {
280 280
281#[cfg(feature = "_dual-core")] 281#[cfg(feature = "_dual-core")]
282mod dual_core { 282mod dual_core {
283 use core::mem::MaybeUninit;
284 use core::sync::atomic::{AtomicUsize, Ordering};
285
283 use rcc::Clocks; 286 use rcc::Clocks;
284 287
285 use super::*; 288 use super::*;
286 use core::{
287 mem::MaybeUninit,
288 sync::atomic::{AtomicUsize, Ordering},
289 };
290 289
291 /// Object containing data that embassy needs to share between cores. 290 /// Object containing data that embassy needs to share between cores.
292 /// 291 ///
293 /// It cannot be initialized by the user. The intended use is: 292 /// It cannot be initialized by the user. The intended use is:
294 /// 293 ///
295 /// ``` 294 /// ```
296 /// #[link_section = ".ram_d3"] 295 /// #[link_section = ".ram_d3"]
297 /// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit(); 296 /// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
298 /// 297 ///
299 /// init_secondary(&SHARED_DATA); 298 /// init_secondary(&SHARED_DATA);
300 /// ``` 299 /// ```
301 /// 300 ///
302 /// This static must be placed in the same position for both cores. How and where this is done is left to the user. 301 /// This static must be placed in the same position for both cores. How and where this is done is left to the user.
303 pub struct SharedData { 302 pub struct SharedData {
304 init_flag: AtomicUsize, 303 init_flag: AtomicUsize,
@@ -314,7 +313,7 @@ mod dual_core {
314 /// This returns the peripheral singletons that can be used for creating drivers. 313 /// This returns the peripheral singletons that can be used for creating drivers.
315 /// 314 ///
316 /// This should only be called once at startup, otherwise it panics. 315 /// This should only be called once at startup, otherwise it panics.
317 /// 316 ///
318 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs 317 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
319 /// for more information on its requirements. 318 /// for more information on its requirements.
320 pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals { 319 pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
@@ -334,7 +333,7 @@ mod dual_core {
334 /// If the other core is not done yet, this will return `None`. 333 /// If the other core is not done yet, this will return `None`.
335 /// 334 ///
336 /// This should only be called once at startup, otherwise it may panic. 335 /// This should only be called once at startup, otherwise it may panic.
337 /// 336 ///
338 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs 337 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
339 /// for more information on its requirements. 338 /// for more information on its requirements.
340 pub fn try_init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Option<Peripherals> { 339 pub fn try_init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Option<Peripherals> {
@@ -357,7 +356,7 @@ mod dual_core {
357 /// If the other core is not done yet, this will spinloop wait on it. 356 /// If the other core is not done yet, this will spinloop wait on it.
358 /// 357 ///
359 /// This should only be called once at startup, otherwise it may panic. 358 /// This should only be called once at startup, otherwise it may panic.
360 /// 359 ///
361 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs 360 /// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
362 /// for more information on its requirements. 361 /// for more information on its requirements.
363 pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals { 362 pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 587231b0c..0656619b1 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -78,7 +78,9 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
78/// Safety: Sets a mutable global. 78/// Safety: Sets a mutable global.
79pub(crate) unsafe fn set_freqs(freqs: Clocks) { 79pub(crate) unsafe fn set_freqs(freqs: Clocks) {
80 debug!("rcc: {:?}", freqs); 80 debug!("rcc: {:?}", freqs);
81 CLOCK_FREQS_PTR.load(core::sync::atomic::Ordering::SeqCst).write(MaybeUninit::new(freqs)); 81 CLOCK_FREQS_PTR
82 .load(core::sync::atomic::Ordering::SeqCst)
83 .write(MaybeUninit::new(freqs));
82} 84}
83 85
84#[cfg(not(feature = "_dual-core"))] 86#[cfg(not(feature = "_dual-core"))]
diff --git a/embassy-stm32/src/time.rs b/embassy-stm32/src/time.rs
index d7337191d..802ff41ce 100644
--- a/embassy-stm32/src/time.rs
+++ b/embassy-stm32/src/time.rs
@@ -92,7 +92,7 @@ impl Div<Hertz> for Hertz {
92#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)] 92#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)]
93#[cfg_attr(feature = "defmt", derive(defmt::Format))] 93#[cfg_attr(feature = "defmt", derive(defmt::Format))]
94/// A variant on [Hertz] that acts as an `Option<Hertz>` that is smaller and repr C. 94/// A variant on [Hertz] that acts as an `Option<Hertz>` that is smaller and repr C.
95/// 95///
96/// An `Option<Hertz>` can be `.into()`'d into this type and back. 96/// An `Option<Hertz>` can be `.into()`'d into this type and back.
97/// The only restriction is that that [Hertz] cannot have the value 0 since that's 97/// The only restriction is that that [Hertz] cannot have the value 0 since that's
98/// seen as the `None` variant. 98/// seen as the `None` variant.
diff --git a/examples/stm32h755cm4/src/bin/blinky.rs b/examples/stm32h755cm4/src/bin/blinky.rs
index 52db326b0..f750c5db6 100644
--- a/examples/stm32h755cm4/src/bin/blinky.rs
+++ b/examples/stm32h755cm4/src/bin/blinky.rs
@@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
5 5
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::{ 8use embassy_stm32::gpio::{Level, Output, Speed};
9 gpio::{Level, Output, Speed}, 9use embassy_stm32::SharedData;
10 SharedData,
11};
12use embassy_time::Timer; 10use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
14 12
diff --git a/examples/stm32h755cm7/src/bin/blinky.rs b/examples/stm32h755cm7/src/bin/blinky.rs
index f76395326..f76a136aa 100644
--- a/examples/stm32h755cm7/src/bin/blinky.rs
+++ b/examples/stm32h755cm7/src/bin/blinky.rs
@@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
5 5
6use defmt::*; 6use defmt::*;
7use embassy_executor::Spawner; 7use embassy_executor::Spawner;
8use embassy_stm32::{ 8use embassy_stm32::gpio::{Level, Output, Speed};
9 gpio::{Level, Output, Speed}, 9use embassy_stm32::SharedData;
10 SharedData,
11};
12use embassy_time::Timer; 10use embassy_time::Timer;
13use {defmt_rtt as _, panic_probe as _}; 11use {defmt_rtt as _, panic_probe as _};
14 12