diff options
Diffstat (limited to 'embassy-stm32/src')
| -rw-r--r-- | embassy-stm32/src/dma/dma_bdma.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/dma/gpdma.rs | 9 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 20 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/bd.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/c0.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f013.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/f247.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/g0.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/g4.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/h.rs | 3 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/l.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/u5.rs | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/wba.rs | 1 |
13 files changed, 52 insertions, 2 deletions
diff --git a/embassy-stm32/src/dma/dma_bdma.rs b/embassy-stm32/src/dma/dma_bdma.rs index 8a6aa53a0..8e2964f94 100644 --- a/embassy-stm32/src/dma/dma_bdma.rs +++ b/embassy-stm32/src/dma/dma_bdma.rs | |||
| @@ -15,6 +15,8 @@ use crate::{interrupt, pac}; | |||
| 15 | pub(crate) struct ChannelInfo { | 15 | pub(crate) struct ChannelInfo { |
| 16 | pub(crate) dma: DmaInfo, | 16 | pub(crate) dma: DmaInfo, |
| 17 | pub(crate) num: usize, | 17 | pub(crate) num: usize, |
| 18 | #[cfg(feature = "_dual-core")] | ||
| 19 | pub(crate) irq: pac::Interrupt, | ||
| 18 | #[cfg(dmamux)] | 20 | #[cfg(dmamux)] |
| 19 | pub(crate) dmamux: super::DmamuxInfo, | 21 | pub(crate) dmamux: super::DmamuxInfo, |
| 20 | } | 22 | } |
| @@ -259,10 +261,12 @@ pub(crate) unsafe fn init( | |||
| 259 | foreach_interrupt! { | 261 | foreach_interrupt! { |
| 260 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { | 262 | ($peri:ident, dma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 261 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, dma_priority); | 263 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, dma_priority); |
| 264 | #[cfg(not(feature = "_dual-core"))] | ||
| 262 | crate::interrupt::typelevel::$irq::enable(); | 265 | crate::interrupt::typelevel::$irq::enable(); |
| 263 | }; | 266 | }; |
| 264 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { | 267 | ($peri:ident, bdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 265 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, bdma_priority); | 268 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, bdma_priority); |
| 269 | #[cfg(not(feature = "_dual-core"))] | ||
| 266 | crate::interrupt::typelevel::$irq::enable(); | 270 | crate::interrupt::typelevel::$irq::enable(); |
| 267 | }; | 271 | }; |
| 268 | } | 272 | } |
| @@ -341,6 +345,11 @@ impl AnyChannel { | |||
| 341 | options: TransferOptions, | 345 | options: TransferOptions, |
| 342 | ) { | 346 | ) { |
| 343 | let info = self.info(); | 347 | let info = self.info(); |
| 348 | #[cfg(feature = "_dual-core")] | ||
| 349 | { | ||
| 350 | use embassy_hal_internal::interrupt::InterruptExt as _; | ||
| 351 | info.irq.enable(); | ||
| 352 | } | ||
| 344 | 353 | ||
| 345 | #[cfg(dmamux)] | 354 | #[cfg(dmamux)] |
| 346 | super::dmamux::configure_dmamux(&info.dmamux, _request); | 355 | super::dmamux::configure_dmamux(&info.dmamux, _request); |
diff --git a/embassy-stm32/src/dma/gpdma.rs b/embassy-stm32/src/dma/gpdma.rs index 13d5d15be..f9d66ca86 100644 --- a/embassy-stm32/src/dma/gpdma.rs +++ b/embassy-stm32/src/dma/gpdma.rs | |||
| @@ -18,6 +18,8 @@ use crate::pac::gpdma::vals; | |||
| 18 | pub(crate) struct ChannelInfo { | 18 | pub(crate) struct ChannelInfo { |
| 19 | pub(crate) dma: pac::gpdma::Gpdma, | 19 | pub(crate) dma: pac::gpdma::Gpdma, |
| 20 | pub(crate) num: usize, | 20 | pub(crate) num: usize, |
| 21 | #[cfg(feature = "_dual-core")] | ||
| 22 | pub(crate) irq: pac::Interrupt, | ||
| 21 | } | 23 | } |
| 22 | 24 | ||
| 23 | /// GPDMA transfer options. | 25 | /// GPDMA transfer options. |
| @@ -57,6 +59,7 @@ pub(crate) unsafe fn init(cs: critical_section::CriticalSection, irq_priority: P | |||
| 57 | foreach_interrupt! { | 59 | foreach_interrupt! { |
| 58 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { | 60 | ($peri:ident, gpdma, $block:ident, $signal_name:ident, $irq:ident) => { |
| 59 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, irq_priority); | 61 | crate::interrupt::typelevel::$irq::set_priority_with_cs(cs, irq_priority); |
| 62 | #[cfg(not(feature = "_dual-core"))] | ||
| 60 | crate::interrupt::typelevel::$irq::enable(); | 63 | crate::interrupt::typelevel::$irq::enable(); |
| 61 | }; | 64 | }; |
| 62 | } | 65 | } |
| @@ -67,6 +70,12 @@ impl AnyChannel { | |||
| 67 | /// Safety: Must be called with a matching set of parameters for a valid dma channel | 70 | /// Safety: Must be called with a matching set of parameters for a valid dma channel |
| 68 | pub(crate) unsafe fn on_irq(&self) { | 71 | pub(crate) unsafe fn on_irq(&self) { |
| 69 | let info = self.info(); | 72 | let info = self.info(); |
| 73 | #[cfg(feature = "_dual-core")] | ||
| 74 | { | ||
| 75 | use embassy_hal_internal::interrupt::InterruptExt as _; | ||
| 76 | info.irq.enable(); | ||
| 77 | } | ||
| 78 | |||
| 70 | let state = &STATE[self.id as usize]; | 79 | let state = &STATE[self.id as usize]; |
| 71 | 80 | ||
| 72 | let ch = info.dma.ch(info.num); | 81 | let ch = info.dma.ch(info.num); |
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 12ebbae2d..98695e738 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -197,6 +197,7 @@ pub use crate::pac::NVIC_PRIO_BITS; | |||
| 197 | 197 | ||
| 198 | /// `embassy-stm32` global configuration. | 198 | /// `embassy-stm32` global configuration. |
| 199 | #[non_exhaustive] | 199 | #[non_exhaustive] |
| 200 | #[derive(Clone, Copy)] | ||
| 200 | pub struct Config { | 201 | pub struct Config { |
| 201 | /// RCC config. | 202 | /// RCC config. |
| 202 | pub rcc: rcc::Config, | 203 | pub rcc: rcc::Config, |
| @@ -303,6 +304,7 @@ mod dual_core { | |||
| 303 | pub struct SharedData { | 304 | pub struct SharedData { |
| 304 | init_flag: AtomicUsize, | 305 | init_flag: AtomicUsize, |
| 305 | clocks: UnsafeCell<MaybeUninit<Clocks>>, | 306 | clocks: UnsafeCell<MaybeUninit<Clocks>>, |
| 307 | config: UnsafeCell<MaybeUninit<Config>>, | ||
| 306 | } | 308 | } |
| 307 | 309 | ||
| 308 | unsafe impl Sync for SharedData {} | 310 | unsafe impl Sync for SharedData {} |
| @@ -325,6 +327,8 @@ mod dual_core { | |||
| 325 | rcc::set_freqs_ptr(shared_data.clocks.get()); | 327 | rcc::set_freqs_ptr(shared_data.clocks.get()); |
| 326 | let p = init_hw(config); | 328 | let p = init_hw(config); |
| 327 | 329 | ||
| 330 | unsafe { *shared_data.config.get() }.write(config); | ||
| 331 | |||
| 328 | shared_data.init_flag.store(INIT_DONE_FLAG, Ordering::SeqCst); | 332 | shared_data.init_flag.store(INIT_DONE_FLAG, Ordering::SeqCst); |
| 329 | 333 | ||
| 330 | p | 334 | p |
| @@ -372,9 +376,23 @@ mod dual_core { | |||
| 372 | fn init_secondary_hw(shared_data: &'static SharedData) -> Peripherals { | 376 | fn init_secondary_hw(shared_data: &'static SharedData) -> Peripherals { |
| 373 | rcc::set_freqs_ptr(shared_data.clocks.get()); | 377 | rcc::set_freqs_ptr(shared_data.clocks.get()); |
| 374 | 378 | ||
| 379 | let config = unsafe { (*shared_data.config.get()).assume_init() }; | ||
| 380 | |||
| 375 | // We use different timers on the different cores, so we have to still initialize one here | 381 | // We use different timers on the different cores, so we have to still initialize one here |
| 376 | #[cfg(feature = "_time-driver")] | ||
| 377 | critical_section::with(|cs| { | 382 | critical_section::with(|cs| { |
| 383 | unsafe { | ||
| 384 | dma::init( | ||
| 385 | cs, | ||
| 386 | #[cfg(bdma)] | ||
| 387 | config.bdma_interrupt_priority, | ||
| 388 | #[cfg(dma)] | ||
| 389 | config.dma_interrupt_priority, | ||
| 390 | #[cfg(gpdma)] | ||
| 391 | config.gpdma_interrupt_priority, | ||
| 392 | ) | ||
| 393 | } | ||
| 394 | |||
| 395 | #[cfg(feature = "_time-driver")] | ||
| 378 | // must be after rcc init | 396 | // must be after rcc init |
| 379 | time_driver::init(cs); | 397 | time_driver::init(cs); |
| 380 | }); | 398 | }); |
diff --git a/embassy-stm32/src/rcc/bd.rs b/embassy-stm32/src/rcc/bd.rs index 4e9c18594..9ccca8a2a 100644 --- a/embassy-stm32/src/rcc/bd.rs +++ b/embassy-stm32/src/rcc/bd.rs | |||
| @@ -16,6 +16,7 @@ pub enum LseMode { | |||
| 16 | Bypass, | 16 | Bypass, |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | #[derive(Clone, Copy)] | ||
| 19 | pub struct LseConfig { | 20 | pub struct LseConfig { |
| 20 | pub frequency: Hertz, | 21 | pub frequency: Hertz, |
| 21 | pub mode: LseMode, | 22 | pub mode: LseMode, |
| @@ -80,6 +81,7 @@ fn bdcr() -> Reg<Bdcr, RW> { | |||
| 80 | return crate::pac::RCC.csr1(); | 81 | return crate::pac::RCC.csr1(); |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 84 | #[derive(Clone, Copy)] | ||
| 83 | pub struct LsConfig { | 85 | pub struct LsConfig { |
| 84 | pub rtc: RtcClockSource, | 86 | pub rtc: RtcClockSource, |
| 85 | pub lsi: bool, | 87 | pub lsi: bool, |
diff --git a/embassy-stm32/src/rcc/c0.rs b/embassy-stm32/src/rcc/c0.rs index 5adf37941..6712aedc4 100644 --- a/embassy-stm32/src/rcc/c0.rs +++ b/embassy-stm32/src/rcc/c0.rs | |||
| @@ -37,6 +37,7 @@ pub struct Hsi { | |||
| 37 | 37 | ||
| 38 | /// Clocks configutation | 38 | /// Clocks configutation |
| 39 | #[non_exhaustive] | 39 | #[non_exhaustive] |
| 40 | #[derive(Clone, Copy)] | ||
| 40 | pub struct Config { | 41 | pub struct Config { |
| 41 | /// HSI Configuration | 42 | /// HSI Configuration |
| 42 | pub hsi: Option<Hsi>, | 43 | pub hsi: Option<Hsi>, |
diff --git a/embassy-stm32/src/rcc/f013.rs b/embassy-stm32/src/rcc/f013.rs index 63dc27bdd..60577b213 100644 --- a/embassy-stm32/src/rcc/f013.rs +++ b/embassy-stm32/src/rcc/f013.rs | |||
| @@ -76,6 +76,7 @@ pub enum HrtimClockSource { | |||
| 76 | 76 | ||
| 77 | /// Clocks configutation | 77 | /// Clocks configutation |
| 78 | #[non_exhaustive] | 78 | #[non_exhaustive] |
| 79 | #[derive(Clone, Copy)] | ||
| 79 | pub struct Config { | 80 | pub struct Config { |
| 80 | pub hsi: bool, | 81 | pub hsi: bool, |
| 81 | pub hse: Option<Hse>, | 82 | pub hse: Option<Hse>, |
diff --git a/embassy-stm32/src/rcc/f247.rs b/embassy-stm32/src/rcc/f247.rs index 61f687d30..58056301a 100644 --- a/embassy-stm32/src/rcc/f247.rs +++ b/embassy-stm32/src/rcc/f247.rs | |||
| @@ -63,6 +63,7 @@ pub struct Pll { | |||
| 63 | /// Used to calculate flash waitstates. See | 63 | /// Used to calculate flash waitstates. See |
| 64 | /// RM0033 - Table 3. Number of wait states according to Cortex®-M3 clock frequency | 64 | /// RM0033 - Table 3. Number of wait states according to Cortex®-M3 clock frequency |
| 65 | #[cfg(stm32f2)] | 65 | #[cfg(stm32f2)] |
| 66 | #[derive(Clone, Copy)] | ||
| 66 | pub enum VoltageScale { | 67 | pub enum VoltageScale { |
| 67 | /// 2.7 to 3.6 V | 68 | /// 2.7 to 3.6 V |
| 68 | Range0, | 69 | Range0, |
| @@ -76,6 +77,7 @@ pub enum VoltageScale { | |||
| 76 | 77 | ||
| 77 | /// Configuration of the core clocks | 78 | /// Configuration of the core clocks |
| 78 | #[non_exhaustive] | 79 | #[non_exhaustive] |
| 80 | #[derive(Clone, Copy)] | ||
| 79 | pub struct Config { | 81 | pub struct Config { |
| 80 | pub hsi: bool, | 82 | pub hsi: bool, |
| 81 | pub hse: Option<Hse>, | 83 | pub hse: Option<Hse>, |
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index c2fa0ca39..c53c83b0e 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs | |||
| @@ -33,6 +33,7 @@ pub struct Hse { | |||
| 33 | /// Use this struct to configure the PLL source, input frequency, multiplication factor, and output | 33 | /// Use this struct to configure the PLL source, input frequency, multiplication factor, and output |
| 34 | /// dividers. Be sure to keep check the datasheet for your specific part for the appropriate | 34 | /// dividers. Be sure to keep check the datasheet for your specific part for the appropriate |
| 35 | /// frequency ranges for each of these settings. | 35 | /// frequency ranges for each of these settings. |
| 36 | #[derive(Clone, Copy)] | ||
| 36 | pub struct Pll { | 37 | pub struct Pll { |
| 37 | /// PLL Source clock selection. | 38 | /// PLL Source clock selection. |
| 38 | pub source: PllSource, | 39 | pub source: PllSource, |
| @@ -55,6 +56,7 @@ pub struct Pll { | |||
| 55 | 56 | ||
| 56 | /// Clocks configutation | 57 | /// Clocks configutation |
| 57 | #[non_exhaustive] | 58 | #[non_exhaustive] |
| 59 | #[derive(Clone, Copy)] | ||
| 58 | pub struct Config { | 60 | pub struct Config { |
| 59 | /// HSI Enable | 61 | /// HSI Enable |
| 60 | pub hsi: bool, | 62 | pub hsi: bool, |
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index c261c0fed..16561f908 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs | |||
| @@ -32,6 +32,7 @@ pub struct Hse { | |||
| 32 | /// Use this struct to configure the PLL source, input frequency, multiplication factor, and output | 32 | /// Use this struct to configure the PLL source, input frequency, multiplication factor, and output |
| 33 | /// dividers. Be sure to keep check the datasheet for your specific part for the appropriate | 33 | /// dividers. Be sure to keep check the datasheet for your specific part for the appropriate |
| 34 | /// frequency ranges for each of these settings. | 34 | /// frequency ranges for each of these settings. |
| 35 | #[derive(Clone, Copy)] | ||
| 35 | pub struct Pll { | 36 | pub struct Pll { |
| 36 | /// PLL Source clock selection. | 37 | /// PLL Source clock selection. |
| 37 | pub source: PllSource, | 38 | pub source: PllSource, |
| @@ -54,6 +55,7 @@ pub struct Pll { | |||
| 54 | 55 | ||
| 55 | /// Clocks configutation | 56 | /// Clocks configutation |
| 56 | #[non_exhaustive] | 57 | #[non_exhaustive] |
| 58 | #[derive(Clone, Copy)] | ||
| 57 | pub struct Config { | 59 | pub struct Config { |
| 58 | /// HSI Enable | 60 | /// HSI Enable |
| 59 | pub hsi: bool, | 61 | pub hsi: bool, |
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index e3c7dd158..376a0b454 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs | |||
| @@ -120,7 +120,7 @@ impl From<TimerPrescaler> for Timpre { | |||
| 120 | /// Power supply configuration | 120 | /// Power supply configuration |
| 121 | /// See RM0433 Rev 4 7.4 | 121 | /// See RM0433 Rev 4 7.4 |
| 122 | #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468, pwr_h7rs))] | 122 | #[cfg(any(pwr_h7rm0399, pwr_h7rm0455, pwr_h7rm0468, pwr_h7rs))] |
| 123 | #[derive(PartialEq)] | 123 | #[derive(Clone, Copy, PartialEq)] |
| 124 | pub enum SupplyConfig { | 124 | pub enum SupplyConfig { |
| 125 | /// Default power supply configuration. | 125 | /// Default power supply configuration. |
| 126 | /// V CORE Power Domains are supplied from the LDO according to VOS. | 126 | /// V CORE Power Domains are supplied from the LDO according to VOS. |
| @@ -180,6 +180,7 @@ pub enum SMPSSupplyVoltage { | |||
| 180 | 180 | ||
| 181 | /// Configuration of the core clocks | 181 | /// Configuration of the core clocks |
| 182 | #[non_exhaustive] | 182 | #[non_exhaustive] |
| 183 | #[derive(Clone, Copy)] | ||
| 183 | pub struct Config { | 184 | pub struct Config { |
| 184 | pub hsi: Option<HSIPrescaler>, | 185 | pub hsi: Option<HSIPrescaler>, |
| 185 | pub hse: Option<Hse>, | 186 | pub hse: Option<Hse>, |
diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs index e9266c65b..6120d33be 100644 --- a/embassy-stm32/src/rcc/l.rs +++ b/embassy-stm32/src/rcc/l.rs | |||
| @@ -30,6 +30,7 @@ pub struct Hse { | |||
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | /// Clocks configuration | 32 | /// Clocks configuration |
| 33 | #[derive(Clone, Copy)] | ||
| 33 | pub struct Config { | 34 | pub struct Config { |
| 34 | // base clock sources | 35 | // base clock sources |
| 35 | pub msi: Option<MSIRange>, | 36 | pub msi: Option<MSIRange>, |
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs index d6331f512..28545ca51 100644 --- a/embassy-stm32/src/rcc/u5.rs +++ b/embassy-stm32/src/rcc/u5.rs | |||
| @@ -59,6 +59,7 @@ pub struct Pll { | |||
| 59 | pub divr: Option<PllDiv>, | 59 | pub divr: Option<PllDiv>, |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | #[derive(Clone, Copy)] | ||
| 62 | pub struct Config { | 63 | pub struct Config { |
| 63 | // base clock sources | 64 | // base clock sources |
| 64 | pub msi: Option<MSIRange>, | 65 | pub msi: Option<MSIRange>, |
diff --git a/embassy-stm32/src/rcc/wba.rs b/embassy-stm32/src/rcc/wba.rs index 8e1779d7c..1fee648d4 100644 --- a/embassy-stm32/src/rcc/wba.rs +++ b/embassy-stm32/src/rcc/wba.rs | |||
| @@ -15,6 +15,7 @@ pub struct Hse { | |||
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | /// Clocks configuration | 17 | /// Clocks configuration |
| 18 | #[derive(Clone, Copy)] | ||
| 18 | pub struct Config { | 19 | pub struct Config { |
| 19 | // base clock sources | 20 | // base clock sources |
| 20 | pub hsi: bool, | 21 | pub hsi: bool, |
