aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/rcc/l0/mod.rs10
-rw-r--r--embassy-stm32/src/rcc/mod.rs40
2 files changed, 40 insertions, 10 deletions
diff --git a/embassy-stm32/src/rcc/l0/mod.rs b/embassy-stm32/src/rcc/l0/mod.rs
index 978d373a2..fc8a94883 100644
--- a/embassy-stm32/src/rcc/l0/mod.rs
+++ b/embassy-stm32/src/rcc/l0/mod.rs
@@ -1,6 +1,6 @@
1use crate::pac; 1use crate::pac;
2use crate::peripherals::{self, CRS, RCC, SYSCFG}; 2use crate::peripherals::{self, CRS, RCC, SYSCFG};
3use crate::rcc::{get_freqs, set_freqs, Clocks}; 3use crate::rcc::{get_freqs, set_freqs};
4use crate::time::Hertz; 4use crate::time::Hertz;
5use crate::time::U32Ext; 5use crate::time::U32Ext;
6use core::marker::PhantomData; 6use core::marker::PhantomData;
@@ -12,6 +12,14 @@ use pac::rcc::vals::{Hpre, Msirange, Plldiv, Pllmul, Pllsrc, Ppre, Sw};
12/// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC, 12/// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC,
13/// and with the addition of the init function to configure a system clock. 13/// and with the addition of the init function to configure a system clock.
14 14
15#[derive(Clone, Copy)]
16pub struct Clocks {
17 pub sys: Hertz,
18 pub ahb: Hertz,
19 pub apb1: Hertz,
20 pub apb2: Hertz,
21}
22
15/// System clock mux source 23/// System clock mux source
16#[derive(Clone, Copy)] 24#[derive(Clone, Copy)]
17pub enum ClockSrc { 25pub enum ClockSrc {
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 132b50b02..7271030aa 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -1,20 +1,11 @@
1#![macro_use] 1#![macro_use]
2 2
3use crate::peripherals; 3use crate::peripherals;
4use crate::time::Hertz;
5use core::mem::MaybeUninit; 4use core::mem::MaybeUninit;
6 5
7/// Frozen clock frequencies 6/// Frozen clock frequencies
8/// 7///
9/// The existence of this value indicates that the clock configuration can no longer be changed 8/// The existence of this value indicates that the clock configuration can no longer be changed
10#[derive(Clone, Copy)]
11pub struct Clocks {
12 pub sys: Hertz,
13 pub ahb: Hertz,
14 pub apb1: Hertz,
15 pub apb2: Hertz,
16}
17
18static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit(); 9static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit();
19 10
20/// Sets the clock frequencies 11/// Sets the clock frequencies
@@ -36,6 +27,37 @@ cfg_if::cfg_if! {
36 } else if #[cfg(rcc_l0)] { 27 } else if #[cfg(rcc_l0)] {
37 mod l0; 28 mod l0;
38 pub use l0::*; 29 pub use l0::*;
30 } else if #[cfg(rcc_l4)] {
31 // TODO: Implement
32 use crate::time::Hertz;
33
34 #[derive(Clone, Copy)]
35 pub struct Clocks {
36 pub apb1: Hertz,
37 pub apb2: Hertz,
38 pub ahb2: Hertz,
39 }
40
41 #[derive(Default)]
42 pub struct Config {}
43 pub unsafe fn init(_config: Config) {
44 }
45 } else if #[cfg(rcc_f4)] {
46 // TODO: Implement
47 use crate::time::Hertz;
48
49 #[derive(Clone, Copy)]
50 pub struct Clocks {
51 pub apb1: Hertz,
52 pub apb2: Hertz,
53 pub ahb2: Hertz,
54 }
55
56 #[derive(Default)]
57 pub struct Config {}
58 pub unsafe fn init(_config: Config) {
59 }
60
39 } else { 61 } else {
40 #[derive(Default)] 62 #[derive(Default)]
41 pub struct Config {} 63 pub struct Config {}