fmt
This commit is contained in:
parent
203297b569
commit
f6f312270f
@ -280,25 +280,24 @@ pub fn init(config: Config) -> Peripherals {
|
|||||||
|
|
||||||
#[cfg(feature = "_dual-core")]
|
#[cfg(feature = "_dual-core")]
|
||||||
mod dual_core {
|
mod dual_core {
|
||||||
|
use core::mem::MaybeUninit;
|
||||||
|
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||||
|
|
||||||
use rcc::Clocks;
|
use rcc::Clocks;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use core::{
|
|
||||||
mem::MaybeUninit,
|
|
||||||
sync::atomic::{AtomicUsize, Ordering},
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Object containing data that embassy needs to share between cores.
|
/// Object containing data that embassy needs to share between cores.
|
||||||
///
|
///
|
||||||
/// It cannot be initialized by the user. The intended use is:
|
/// It cannot be initialized by the user. The intended use is:
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// #[link_section = ".ram_d3"]
|
/// #[link_section = ".ram_d3"]
|
||||||
/// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
/// static SHARED_DATA: MaybeUninit<SharedData> = MaybeUninit::uninit();
|
||||||
///
|
///
|
||||||
/// init_secondary(&SHARED_DATA);
|
/// 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.
|
/// 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 {
|
pub struct SharedData {
|
||||||
init_flag: AtomicUsize,
|
init_flag: AtomicUsize,
|
||||||
@ -314,7 +313,7 @@ mod dual_core {
|
|||||||
/// This returns the peripheral singletons that can be used for creating drivers.
|
/// This returns the peripheral singletons that can be used for creating drivers.
|
||||||
///
|
///
|
||||||
/// This should only be called once at startup, otherwise it panics.
|
/// 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
|
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
|
||||||
/// for more information on its requirements.
|
/// for more information on its requirements.
|
||||||
pub fn init_primary(config: Config, shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
|
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`.
|
/// If the other core is not done yet, this will return `None`.
|
||||||
///
|
///
|
||||||
/// This should only be called once at startup, otherwise it may panic.
|
/// 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
|
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
|
||||||
/// for more information on its requirements.
|
/// for more information on its requirements.
|
||||||
pub fn try_init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Option<Peripherals> {
|
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.
|
/// 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.
|
/// 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
|
/// The `shared_data` is used to coordinate the init with the second core. Read the [SharedData] docs
|
||||||
/// for more information on its requirements.
|
/// for more information on its requirements.
|
||||||
pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
|
pub fn init_secondary(shared_data: &'static MaybeUninit<SharedData>) -> Peripherals {
|
||||||
|
|||||||
@ -78,7 +78,9 @@ pub(crate) unsafe fn set_freqs(freqs: Clocks) {
|
|||||||
/// Safety: Sets a mutable global.
|
/// Safety: Sets a mutable global.
|
||||||
pub(crate) unsafe fn set_freqs(freqs: Clocks) {
|
pub(crate) unsafe fn set_freqs(freqs: Clocks) {
|
||||||
debug!("rcc: {:?}", freqs);
|
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"))]
|
#[cfg(not(feature = "_dual-core"))]
|
||||||
|
|||||||
@ -92,7 +92,7 @@ impl Div<Hertz> for Hertz {
|
|||||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)]
|
#[derive(Eq, PartialEq, Ord, PartialOrd, Clone, Copy, Debug, Default)]
|
||||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||||
/// A variant on [Hertz] that acts as an `Option<Hertz>` that is smaller and repr C.
|
/// 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.
|
/// 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
|
/// The only restriction is that that [Hertz] cannot have the value 0 since that's
|
||||||
/// seen as the `None` variant.
|
/// seen as the `None` variant.
|
||||||
|
|||||||
@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
|
|||||||
|
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::{
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
gpio::{Level, Output, Speed},
|
use embassy_stm32::SharedData;
|
||||||
SharedData,
|
|
||||||
};
|
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
|||||||
@ -5,10 +5,8 @@ use core::mem::MaybeUninit;
|
|||||||
|
|
||||||
use defmt::*;
|
use defmt::*;
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_stm32::{
|
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||||
gpio::{Level, Output, Speed},
|
use embassy_stm32::SharedData;
|
||||||
SharedData,
|
|
||||||
};
|
|
||||||
use embassy_time::Timer;
|
use embassy_time::Timer;
|
||||||
use {defmt_rtt as _, panic_probe as _};
|
use {defmt_rtt as _, panic_probe as _};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user