This commit is contained in:
Dion Dokter 2024-07-09 09:37:49 +02:00
parent 203297b569
commit f6f312270f
5 changed files with 18 additions and 21 deletions

View File

@ -280,25 +280,24 @@ pub fn init(config: Config) -> Peripherals {
#[cfg(feature = "_dual-core")]
mod dual_core {
use core::mem::MaybeUninit;
use core::sync::atomic::{AtomicUsize, Ordering};
use rcc::Clocks;
use super::*;
use core::{
mem::MaybeUninit,
sync::atomic::{AtomicUsize, Ordering},
};
/// Object containing data that embassy needs to share between cores.
///
///
/// It cannot be initialized by the user. The intended use is:
///
///
/// ```
/// #[link_section = ".ram_d3"]
/// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
///
///
/// init_secondary(&SHARED_DATA);
/// ```
///
///
/// This static must be placed in the same position for both cores. How and where this is done is left to the user.
pub struct SharedData {
init_flag: AtomicUsize,
@ -314,7 +313,7 @@ mod dual_core {
/// This returns the peripheral singletons that can be used for creating drivers.
///
/// This should only be called once at startup, otherwise it panics.
///
///
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
/// for more information on its requirements.
pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
@ -334,7 +333,7 @@ mod dual_core {
/// If the other core is not done yet, this will return `None`.
///
/// This should only be called once at startup, otherwise it may panic.
///
///
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
/// for more information on its requirements.
pub fn try_init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Option<Peripherals> {
@ -357,7 +356,7 @@ mod dual_core {
/// If the other core is not done yet, this will spinloop wait on it.
///
/// This should only be called once at startup, otherwise it may panic.
///
///
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
/// for more information on its requirements.
pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {

View File

@ -78,7 +78,9 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
/// Safety: Sets a mutable global.
pub(crate) unsafe fn set_freqs(freqs: Clocks) {
debug!("rcc: {:?}", freqs);
CLOCK_FREQS_PTR.load(core::sync::atomic::Ordering::SeqCst).write(MaybeUninit::new(freqs));
CLOCK_FREQS_PTR
.load(core::sync::atomic::Ordering::SeqCst)
.write(MaybeUninit::new(freqs));
}
#[cfg(not(feature = "_dual-core"))]

View File

@ -92,7 +92,7 @@ impl Div<Hertz> for Hertz {
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// A variant on [Hertz] that acts as an `Option<Hertz>` that is smaller and repr C.
///
///
/// An `Option<Hertz>` can be `.into()`'d into this type and back.
/// The only restriction is that that [Hertz] cannot have the value 0 since that's
/// seen as the `None` variant.

View File

@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::{
gpio::{Level, Output, Speed},
SharedData,
};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::SharedData;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};

View File

@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
use defmt::*;
use embassy_executor::Spawner;
use embassy_stm32::{
gpio::{Level, Output, Speed},
SharedData,
};
use embassy_stm32::gpio::{Level, Output, Speed};
use embassy_stm32::SharedData;
use embassy_time::Timer;
use {defmt_rtt as _, panic_probe as _};