diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-02-26 00:00:17 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-02-26 00:00:17 +0100 |
| commit | 489d0be2a2971cfae7d6413b601bbd044d42e351 (patch) | |
| tree | b930aa13b1f43efedcf8bc19e85e94036dedc7d2 /embassy-stm32/src/rcc/c0.rs | |
| parent | 497515ed57b768332295ef58630231609fb959fc (diff) | |
stm32/rcc: unify naming sysclk field to `sys`, enum to `Sysclk`.
Diffstat (limited to 'embassy-stm32/src/rcc/c0.rs')
| -rw-r--r-- | embassy-stm32/src/rcc/c0.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/embassy-stm32/src/rcc/c0.rs b/embassy-stm32/src/rcc/c0.rs index ca1222185..ec6ec34e8 100644 --- a/embassy-stm32/src/rcc/c0.rs +++ b/embassy-stm32/src/rcc/c0.rs | |||
| @@ -9,7 +9,7 @@ pub const HSI_FREQ: Hertz = Hertz(48_000_000); | |||
| 9 | 9 | ||
| 10 | /// System clock mux source | 10 | /// System clock mux source |
| 11 | #[derive(Clone, Copy)] | 11 | #[derive(Clone, Copy)] |
| 12 | pub enum ClockSrc { | 12 | pub enum Sysclk { |
| 13 | HSE(Hertz), | 13 | HSE(Hertz), |
| 14 | HSI(HSIPrescaler), | 14 | HSI(HSIPrescaler), |
| 15 | LSI, | 15 | LSI, |
| @@ -17,7 +17,7 @@ pub enum ClockSrc { | |||
| 17 | 17 | ||
| 18 | /// Clocks configutation | 18 | /// Clocks configutation |
| 19 | pub struct Config { | 19 | pub struct Config { |
| 20 | pub mux: ClockSrc, | 20 | pub sys: Sysclk, |
| 21 | pub ahb_pre: AHBPrescaler, | 21 | pub ahb_pre: AHBPrescaler, |
| 22 | pub apb_pre: APBPrescaler, | 22 | pub apb_pre: APBPrescaler, |
| 23 | pub ls: super::LsConfig, | 23 | pub ls: super::LsConfig, |
| @@ -27,7 +27,7 @@ impl Default for Config { | |||
| 27 | #[inline] | 27 | #[inline] |
| 28 | fn default() -> Config { | 28 | fn default() -> Config { |
| 29 | Config { | 29 | Config { |
| 30 | mux: ClockSrc::HSI(HSIPrescaler::DIV1), | 30 | sys: Sysclk::HSI(HSIPrescaler::DIV1), |
| 31 | ahb_pre: AHBPrescaler::DIV1, | 31 | ahb_pre: AHBPrescaler::DIV1, |
| 32 | apb_pre: APBPrescaler::DIV1, | 32 | apb_pre: APBPrescaler::DIV1, |
| 33 | ls: Default::default(), | 33 | ls: Default::default(), |
| @@ -36,8 +36,8 @@ impl Default for Config { | |||
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | pub(crate) unsafe fn init(config: Config) { | 38 | pub(crate) unsafe fn init(config: Config) { |
| 39 | let (sys_clk, sw) = match config.mux { | 39 | let (sys_clk, sw) = match config.sys { |
| 40 | ClockSrc::HSI(div) => { | 40 | Sysclk::HSI(div) => { |
| 41 | // Enable HSI | 41 | // Enable HSI |
| 42 | RCC.cr().write(|w| { | 42 | RCC.cr().write(|w| { |
| 43 | w.set_hsidiv(div); | 43 | w.set_hsidiv(div); |
| @@ -47,14 +47,14 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 47 | 47 | ||
| 48 | (HSI_FREQ / div, Sw::HSI) | 48 | (HSI_FREQ / div, Sw::HSI) |
| 49 | } | 49 | } |
| 50 | ClockSrc::HSE(freq) => { | 50 | Sysclk::HSE(freq) => { |
| 51 | // Enable HSE | 51 | // Enable HSE |
| 52 | RCC.cr().write(|w| w.set_hseon(true)); | 52 | RCC.cr().write(|w| w.set_hseon(true)); |
| 53 | while !RCC.cr().read().hserdy() {} | 53 | while !RCC.cr().read().hserdy() {} |
| 54 | 54 | ||
| 55 | (freq, Sw::HSE) | 55 | (freq, Sw::HSE) |
| 56 | } | 56 | } |
| 57 | ClockSrc::LSI => { | 57 | Sysclk::LSI => { |
| 58 | // Enable LSI | 58 | // Enable LSI |
| 59 | RCC.csr2().write(|w| w.set_lsion(true)); | 59 | RCC.csr2().write(|w| w.set_lsion(true)); |
| 60 | while !RCC.csr2().read().lsirdy() {} | 60 | while !RCC.csr2().read().lsirdy() {} |
