diff options
26 files changed, 111 insertions, 111 deletions
diff --git a/embassy-stm32/src/rcc/f2.rs b/embassy-stm32/src/rcc/f2.rs index 9a66e75a4..00480222a 100644 --- a/embassy-stm32/src/rcc/f2.rs +++ b/embassy-stm32/src/rcc/f2.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use crate::pac::flash::vals::Latency; | 1 | use crate::pac::flash::vals::Latency; |
| 2 | use crate::pac::rcc::vals::Sw; | 2 | use crate::pac::rcc::vals::Sw; |
| 3 | pub use crate::pac::rcc::vals::{ | 3 | pub use crate::pac::rcc::vals::{ |
| 4 | Hpre as AHBPrescaler, Pllm as PLLPreDiv, Plln as PLLMul, Pllp as PLLPDiv, Pllq as PLLQDiv, Pllsrc as PLLSrc, | 4 | Hpre as AHBPrescaler, Pllm as PllPreDiv, Plln as PllMul, Pllp as PllPDiv, Pllq as PllQDiv, Pllsrc as PllSource, |
| 5 | Ppre as APBPrescaler, | 5 | Ppre as APBPrescaler, |
| 6 | }; | 6 | }; |
| 7 | use crate::pac::{FLASH, RCC}; | 7 | use crate::pac::{FLASH, RCC}; |
| @@ -35,30 +35,30 @@ pub enum HSESrc { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | #[derive(Clone, Copy)] | 37 | #[derive(Clone, Copy)] |
| 38 | pub struct PLLConfig { | 38 | pub struct Pll { |
| 39 | pub pre_div: PLLPreDiv, | 39 | pub pre_div: PllPreDiv, |
| 40 | pub mul: PLLMul, | 40 | pub mul: PllMul, |
| 41 | pub p_div: PLLPDiv, | 41 | pub divp: PllPDiv, |
| 42 | pub q_div: PLLQDiv, | 42 | pub divq: PllQDiv, |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | impl Default for PLLConfig { | 45 | impl Default for Pll { |
| 46 | fn default() -> Self { | 46 | fn default() -> Self { |
| 47 | PLLConfig { | 47 | Pll { |
| 48 | pre_div: PLLPreDiv::DIV16, | 48 | pre_div: PllPreDiv::DIV16, |
| 49 | mul: PLLMul::MUL192, | 49 | mul: PllMul::MUL192, |
| 50 | p_div: PLLPDiv::DIV2, | 50 | divp: PllPDiv::DIV2, |
| 51 | q_div: PLLQDiv::DIV4, | 51 | divq: PllQDiv::DIV4, |
| 52 | } | 52 | } |
| 53 | } | 53 | } |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | impl PLLConfig { | 56 | impl Pll { |
| 57 | pub fn clocks(&self, src_freq: Hertz) -> PLLClocks { | 57 | pub fn clocks(&self, src_freq: Hertz) -> PLLClocks { |
| 58 | let in_freq = src_freq / self.pre_div; | 58 | let in_freq = src_freq / self.pre_div; |
| 59 | let vco_freq = src_freq / self.pre_div * self.mul; | 59 | let vco_freq = src_freq / self.pre_div * self.mul; |
| 60 | let main_freq = vco_freq / self.p_div; | 60 | let main_freq = vco_freq / self.divp; |
| 61 | let pll48_freq = vco_freq / self.q_div; | 61 | let pll48_freq = vco_freq / self.divq; |
| 62 | PLLClocks { | 62 | PLLClocks { |
| 63 | in_freq, | 63 | in_freq, |
| 64 | vco_freq, | 64 | vco_freq, |
| @@ -172,8 +172,8 @@ impl VoltageScale { | |||
| 172 | pub struct Config { | 172 | pub struct Config { |
| 173 | pub hse: Option<HSEConfig>, | 173 | pub hse: Option<HSEConfig>, |
| 174 | pub hsi: bool, | 174 | pub hsi: bool, |
| 175 | pub pll_mux: PLLSrc, | 175 | pub pll_mux: PllSource, |
| 176 | pub pll: PLLConfig, | 176 | pub pll: Pll, |
| 177 | pub mux: ClockSrc, | 177 | pub mux: ClockSrc, |
| 178 | pub voltage: VoltageScale, | 178 | pub voltage: VoltageScale, |
| 179 | pub ahb_pre: AHBPrescaler, | 179 | pub ahb_pre: AHBPrescaler, |
| @@ -188,8 +188,8 @@ impl Default for Config { | |||
| 188 | Config { | 188 | Config { |
| 189 | hse: None, | 189 | hse: None, |
| 190 | hsi: true, | 190 | hsi: true, |
| 191 | pll_mux: PLLSrc::HSI, | 191 | pll_mux: PllSource::HSI, |
| 192 | pll: PLLConfig::default(), | 192 | pll: Pll::default(), |
| 193 | voltage: VoltageScale::Range3, | 193 | voltage: VoltageScale::Range3, |
| 194 | mux: ClockSrc::HSI, | 194 | mux: ClockSrc::HSI, |
| 195 | ahb_pre: AHBPrescaler::DIV1, | 195 | ahb_pre: AHBPrescaler::DIV1, |
| @@ -217,13 +217,13 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | let pll_src_freq = match config.pll_mux { | 219 | let pll_src_freq = match config.pll_mux { |
| 220 | PLLSrc::HSE => { | 220 | PllSource::HSE => { |
| 221 | let hse_config = config | 221 | let hse_config = config |
| 222 | .hse | 222 | .hse |
| 223 | .unwrap_or_else(|| panic!("HSE must be configured to be used as PLL input")); | 223 | .unwrap_or_else(|| panic!("HSE must be configured to be used as PLL input")); |
| 224 | hse_config.frequency | 224 | hse_config.frequency |
| 225 | } | 225 | } |
| 226 | PLLSrc::HSI => HSI_FREQ, | 226 | PllSource::HSI => HSI_FREQ, |
| 227 | }; | 227 | }; |
| 228 | 228 | ||
| 229 | // Reference: STM32F215xx/217xx datasheet Table 33. Main PLL characteristics | 229 | // Reference: STM32F215xx/217xx datasheet Table 33. Main PLL characteristics |
| @@ -238,8 +238,8 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 238 | w.set_pllsrc(config.pll_mux); | 238 | w.set_pllsrc(config.pll_mux); |
| 239 | w.set_pllm(config.pll.pre_div); | 239 | w.set_pllm(config.pll.pre_div); |
| 240 | w.set_plln(config.pll.mul); | 240 | w.set_plln(config.pll.mul); |
| 241 | w.set_pllp(config.pll.p_div); | 241 | w.set_pllp(config.pll.divp); |
| 242 | w.set_pllq(config.pll.q_div); | 242 | w.set_pllq(config.pll.divq); |
| 243 | }); | 243 | }); |
| 244 | 244 | ||
| 245 | let (sys_clk, sw) = match config.mux { | 245 | let (sys_clk, sw) = match config.mux { |
diff --git a/embassy-stm32/src/rcc/g0.rs b/embassy-stm32/src/rcc/g0.rs index 45d41a4e0..75613dd2b 100644 --- a/embassy-stm32/src/rcc/g0.rs +++ b/embassy-stm32/src/rcc/g0.rs | |||
| @@ -28,7 +28,7 @@ pub enum ClockSrc { | |||
| 28 | #[derive(Clone, Copy)] | 28 | #[derive(Clone, Copy)] |
| 29 | pub struct PllConfig { | 29 | pub struct PllConfig { |
| 30 | /// The source from which the PLL receives a clock signal | 30 | /// The source from which the PLL receives a clock signal |
| 31 | pub source: PllSrc, | 31 | pub source: PllSource, |
| 32 | /// The initial divisor of that clock signal | 32 | /// The initial divisor of that clock signal |
| 33 | pub m: Pllm, | 33 | pub m: Pllm, |
| 34 | /// The PLL VCO multiplier, which must be in the range `8..=86`. | 34 | /// The PLL VCO multiplier, which must be in the range `8..=86`. |
| @@ -48,7 +48,7 @@ impl Default for PllConfig { | |||
| 48 | fn default() -> PllConfig { | 48 | fn default() -> PllConfig { |
| 49 | // HSI / 1 * 8 / 2 = 64 MHz | 49 | // HSI / 1 * 8 / 2 = 64 MHz |
| 50 | PllConfig { | 50 | PllConfig { |
| 51 | source: PllSrc::HSI, | 51 | source: PllSource::HSI, |
| 52 | m: Pllm::DIV1, | 52 | m: Pllm::DIV1, |
| 53 | n: Plln::MUL8, | 53 | n: Plln::MUL8, |
| 54 | r: Pllr::DIV2, | 54 | r: Pllr::DIV2, |
| @@ -59,7 +59,7 @@ impl Default for PllConfig { | |||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | #[derive(Clone, Copy, Eq, PartialEq)] | 61 | #[derive(Clone, Copy, Eq, PartialEq)] |
| 62 | pub enum PllSrc { | 62 | pub enum PllSource { |
| 63 | HSI, | 63 | HSI, |
| 64 | HSE(Hertz), | 64 | HSE(Hertz), |
| 65 | } | 65 | } |
| @@ -89,8 +89,8 @@ impl Default for Config { | |||
| 89 | impl PllConfig { | 89 | impl PllConfig { |
| 90 | pub(crate) fn init(self) -> Hertz { | 90 | pub(crate) fn init(self) -> Hertz { |
| 91 | let (src, input_freq) = match self.source { | 91 | let (src, input_freq) = match self.source { |
| 92 | PllSrc::HSI => (vals::Pllsrc::HSI, HSI_FREQ), | 92 | PllSource::HSI => (vals::Pllsrc::HSI, HSI_FREQ), |
| 93 | PllSrc::HSE(freq) => (vals::Pllsrc::HSE, freq), | 93 | PllSource::HSE(freq) => (vals::Pllsrc::HSE, freq), |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | let m_freq = input_freq / self.m; | 96 | let m_freq = input_freq / self.m; |
| @@ -121,11 +121,11 @@ impl PllConfig { | |||
| 121 | // > 3. Change the desired parameter. | 121 | // > 3. Change the desired parameter. |
| 122 | // Enable whichever clock source we're using, and wait for it to become ready | 122 | // Enable whichever clock source we're using, and wait for it to become ready |
| 123 | match self.source { | 123 | match self.source { |
| 124 | PllSrc::HSI => { | 124 | PllSource::HSI => { |
| 125 | RCC.cr().write(|w| w.set_hsion(true)); | 125 | RCC.cr().write(|w| w.set_hsion(true)); |
| 126 | while !RCC.cr().read().hsirdy() {} | 126 | while !RCC.cr().read().hsirdy() {} |
| 127 | } | 127 | } |
| 128 | PllSrc::HSE(_) => { | 128 | PllSource::HSE(_) => { |
| 129 | RCC.cr().write(|w| w.set_hseon(true)); | 129 | RCC.cr().write(|w| w.set_hseon(true)); |
| 130 | while !RCC.cr().read().hserdy() {} | 130 | while !RCC.cr().read().hserdy() {} |
| 131 | } | 131 | } |
diff --git a/embassy-stm32/src/rcc/g4.rs b/embassy-stm32/src/rcc/g4.rs index 13eb0c48d..48b27255d 100644 --- a/embassy-stm32/src/rcc/g4.rs +++ b/embassy-stm32/src/rcc/g4.rs | |||
| @@ -23,16 +23,16 @@ pub enum ClockSrc { | |||
| 23 | 23 | ||
| 24 | /// PLL clock input source | 24 | /// PLL clock input source |
| 25 | #[derive(Clone, Copy, Debug)] | 25 | #[derive(Clone, Copy, Debug)] |
| 26 | pub enum PllSrc { | 26 | pub enum PllSource { |
| 27 | HSI, | 27 | HSI, |
| 28 | HSE(Hertz), | 28 | HSE(Hertz), |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | impl Into<Pllsrc> for PllSrc { | 31 | impl Into<Pllsrc> for PllSource { |
| 32 | fn into(self) -> Pllsrc { | 32 | fn into(self) -> Pllsrc { |
| 33 | match self { | 33 | match self { |
| 34 | PllSrc::HSE(..) => Pllsrc::HSE, | 34 | PllSource::HSE(..) => Pllsrc::HSE, |
| 35 | PllSrc::HSI => Pllsrc::HSI, | 35 | PllSource::HSI => Pllsrc::HSI, |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| @@ -44,7 +44,7 @@ impl Into<Pllsrc> for PllSrc { | |||
| 44 | /// frequency ranges for each of these settings. | 44 | /// frequency ranges for each of these settings. |
| 45 | pub struct Pll { | 45 | pub struct Pll { |
| 46 | /// PLL Source clock selection. | 46 | /// PLL Source clock selection. |
| 47 | pub source: PllSrc, | 47 | pub source: PllSource, |
| 48 | 48 | ||
| 49 | /// PLL pre-divider | 49 | /// PLL pre-divider |
| 50 | pub prediv_m: PllM, | 50 | pub prediv_m: PllM, |
| @@ -118,13 +118,13 @@ pub struct PllFreq { | |||
| 118 | pub(crate) unsafe fn init(config: Config) { | 118 | pub(crate) unsafe fn init(config: Config) { |
| 119 | let pll_freq = config.pll.map(|pll_config| { | 119 | let pll_freq = config.pll.map(|pll_config| { |
| 120 | let src_freq = match pll_config.source { | 120 | let src_freq = match pll_config.source { |
| 121 | PllSrc::HSI => { | 121 | PllSource::HSI => { |
| 122 | RCC.cr().write(|w| w.set_hsion(true)); | 122 | RCC.cr().write(|w| w.set_hsion(true)); |
| 123 | while !RCC.cr().read().hsirdy() {} | 123 | while !RCC.cr().read().hsirdy() {} |
| 124 | 124 | ||
| 125 | HSI_FREQ | 125 | HSI_FREQ |
| 126 | } | 126 | } |
| 127 | PllSrc::HSE(freq) => { | 127 | PllSource::HSE(freq) => { |
| 128 | RCC.cr().write(|w| w.set_hseon(true)); | 128 | RCC.cr().write(|w| w.set_hseon(true)); |
| 129 | while !RCC.cr().read().hserdy() {} | 129 | while !RCC.cr().read().hserdy() {} |
| 130 | freq | 130 | freq |
diff --git a/embassy-stm32/src/rcc/l0l1.rs b/embassy-stm32/src/rcc/l0l1.rs index 25a7762a3..c3d58e8ec 100644 --- a/embassy-stm32/src/rcc/l0l1.rs +++ b/embassy-stm32/src/rcc/l0l1.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | pub use crate::pac::pwr::vals::Vos as VoltageScale; | 1 | pub use crate::pac::pwr::vals::Vos as VoltageScale; |
| 2 | pub use crate::pac::rcc::vals::{ | 2 | pub use crate::pac::rcc::vals::{ |
| 3 | Hpre as AHBPrescaler, Msirange as MSIRange, Plldiv as PLLDiv, Plldiv as PllDiv, Pllmul as PLLMul, Pllmul as PllMul, | 3 | Hpre as AHBPrescaler, Msirange as MSIRange, Plldiv as PllDiv, Pllmul as PllMul, Pllsrc as PllSource, |
| 4 | Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc, | 4 | Ppre as APBPrescaler, Sw as ClockSrc, |
| 5 | }; | 5 | }; |
| 6 | use crate::pac::{FLASH, PWR, RCC}; | 6 | use crate::pac::{FLASH, PWR, RCC}; |
| 7 | use crate::rcc::{set_freqs, Clocks}; | 7 | use crate::rcc::{set_freqs, Clocks}; |
| @@ -29,7 +29,7 @@ pub struct Hse { | |||
| 29 | #[derive(Clone, Copy)] | 29 | #[derive(Clone, Copy)] |
| 30 | pub struct Pll { | 30 | pub struct Pll { |
| 31 | /// PLL source | 31 | /// PLL source |
| 32 | pub source: PLLSource, | 32 | pub source: PllSource, |
| 33 | 33 | ||
| 34 | /// PLL multiplication factor. | 34 | /// PLL multiplication factor. |
| 35 | pub mul: PllMul, | 35 | pub mul: PllMul, |
| @@ -116,8 +116,8 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 116 | 116 | ||
| 117 | let pll = config.pll.map(|pll| { | 117 | let pll = config.pll.map(|pll| { |
| 118 | let freq = match pll.source { | 118 | let freq = match pll.source { |
| 119 | PLLSource::HSE => hse.unwrap(), | 119 | PllSource::HSE => hse.unwrap(), |
| 120 | PLLSource::HSI => hsi.unwrap(), | 120 | PllSource::HSI => hsi.unwrap(), |
| 121 | }; | 121 | }; |
| 122 | 122 | ||
| 123 | // Disable PLL | 123 | // Disable PLL |
diff --git a/embassy-stm32/src/rcc/l4l5.rs b/embassy-stm32/src/rcc/l4l5.rs index c44839104..97f231f61 100644 --- a/embassy-stm32/src/rcc/l4l5.rs +++ b/embassy-stm32/src/rcc/l4l5.rs | |||
| @@ -5,7 +5,7 @@ pub use crate::pac::rcc::vals::Clk48sel as Clk48Src; | |||
| 5 | pub use crate::pac::rcc::vals::Hsepre as HsePrescaler; | 5 | pub use crate::pac::rcc::vals::Hsepre as HsePrescaler; |
| 6 | pub use crate::pac::rcc::vals::{ | 6 | pub use crate::pac::rcc::vals::{ |
| 7 | Adcsel as AdcClockSource, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, | 7 | Adcsel as AdcClockSource, Hpre as AHBPrescaler, Msirange as MSIRange, Pllm as PllPreDiv, Plln as PllMul, |
| 8 | Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PLLSource, Ppre as APBPrescaler, Sw as ClockSrc, | 8 | Pllp as PllPDiv, Pllq as PllQDiv, Pllr as PllRDiv, Pllsrc as PllSource, Ppre as APBPrescaler, Sw as ClockSrc, |
| 9 | }; | 9 | }; |
| 10 | use crate::pac::{FLASH, RCC}; | 10 | use crate::pac::{FLASH, RCC}; |
| 11 | use crate::rcc::{set_freqs, Clocks}; | 11 | use crate::rcc::{set_freqs, Clocks}; |
| @@ -36,7 +36,7 @@ pub struct Hse { | |||
| 36 | #[derive(Clone, Copy)] | 36 | #[derive(Clone, Copy)] |
| 37 | pub struct Pll { | 37 | pub struct Pll { |
| 38 | /// PLL source | 38 | /// PLL source |
| 39 | pub source: PLLSource, | 39 | pub source: PllSource, |
| 40 | 40 | ||
| 41 | /// PLL pre-divider (DIVM). | 41 | /// PLL pre-divider (DIVM). |
| 42 | pub prediv: PllPreDiv, | 42 | pub prediv: PllPreDiv, |
| @@ -135,7 +135,7 @@ pub const WPAN_DEFAULT: Config = Config { | |||
| 135 | ls: super::LsConfig::default_lse(), | 135 | ls: super::LsConfig::default_lse(), |
| 136 | 136 | ||
| 137 | pll: Some(Pll { | 137 | pll: Some(Pll { |
| 138 | source: PLLSource::HSE, | 138 | source: PllSource::HSE, |
| 139 | prediv: PllPreDiv::DIV2, | 139 | prediv: PllPreDiv::DIV2, |
| 140 | mul: PllMul::MUL12, | 140 | mul: PllMul::MUL12, |
| 141 | divp: Some(PllPDiv::DIV3), // 32 / 2 * 12 / 3 = 64Mhz | 141 | divp: Some(PllPDiv::DIV3), // 32 / 2 * 12 / 3 = 64Mhz |
| @@ -456,10 +456,10 @@ fn init_pll(instance: PllInstance, config: Option<Pll>, input: &PllInput) -> Pll | |||
| 456 | let Some(pll) = config else { return PllOutput::default() }; | 456 | let Some(pll) = config else { return PllOutput::default() }; |
| 457 | 457 | ||
| 458 | let pll_src = match pll.source { | 458 | let pll_src = match pll.source { |
| 459 | PLLSource::DISABLE => panic!("must not select PLL source as DISABLE"), | 459 | PllSource::DISABLE => panic!("must not select PLL source as DISABLE"), |
| 460 | PLLSource::HSE => input.hse, | 460 | PllSource::HSE => input.hse, |
| 461 | PLLSource::HSI => input.hsi, | 461 | PllSource::HSI => input.hsi, |
| 462 | PLLSource::MSI => input.msi, | 462 | PllSource::MSI => input.msi, |
| 463 | }; | 463 | }; |
| 464 | 464 | ||
| 465 | let pll_src = pll_src.unwrap(); | 465 | let pll_src = pll_src.unwrap(); |
diff --git a/embassy-stm32/src/rcc/u5.rs b/embassy-stm32/src/rcc/u5.rs index c111362bf..81bdec881 100644 --- a/embassy-stm32/src/rcc/u5.rs +++ b/embassy-stm32/src/rcc/u5.rs | |||
| @@ -35,7 +35,7 @@ impl Default for ClockSrc { | |||
| 35 | #[derive(Clone, Copy)] | 35 | #[derive(Clone, Copy)] |
| 36 | pub struct PllConfig { | 36 | pub struct PllConfig { |
| 37 | /// The clock source for the PLL. | 37 | /// The clock source for the PLL. |
| 38 | pub source: PllSrc, | 38 | pub source: PllSource, |
| 39 | /// The PLL prescaler. | 39 | /// The PLL prescaler. |
| 40 | /// | 40 | /// |
| 41 | /// The clock speed of the `source` divided by `m` must be between 4 and 16 MHz. | 41 | /// The clock speed of the `source` divided by `m` must be between 4 and 16 MHz. |
| @@ -57,7 +57,7 @@ impl PllConfig { | |||
| 57 | /// A configuration for HSI / 1 * 10 / 1 = 160 MHz | 57 | /// A configuration for HSI / 1 * 10 / 1 = 160 MHz |
| 58 | pub const fn hsi_160mhz() -> Self { | 58 | pub const fn hsi_160mhz() -> Self { |
| 59 | PllConfig { | 59 | PllConfig { |
| 60 | source: PllSrc::HSI, | 60 | source: PllSource::HSI, |
| 61 | m: Pllm::DIV1, | 61 | m: Pllm::DIV1, |
| 62 | n: Plln::MUL10, | 62 | n: Plln::MUL10, |
| 63 | r: Plldiv::DIV1, | 63 | r: Plldiv::DIV1, |
| @@ -67,7 +67,7 @@ impl PllConfig { | |||
| 67 | /// A configuration for MSIS @ 48 MHz / 3 * 10 / 1 = 160 MHz | 67 | /// A configuration for MSIS @ 48 MHz / 3 * 10 / 1 = 160 MHz |
| 68 | pub const fn msis_160mhz() -> Self { | 68 | pub const fn msis_160mhz() -> Self { |
| 69 | PllConfig { | 69 | PllConfig { |
| 70 | source: PllSrc::MSIS(Msirange::RANGE_48MHZ), | 70 | source: PllSource::MSIS(Msirange::RANGE_48MHZ), |
| 71 | m: Pllm::DIV3, | 71 | m: Pllm::DIV3, |
| 72 | n: Plln::MUL10, | 72 | n: Plln::MUL10, |
| 73 | r: Plldiv::DIV1, | 73 | r: Plldiv::DIV1, |
| @@ -76,7 +76,7 @@ impl PllConfig { | |||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | #[derive(Clone, Copy)] | 78 | #[derive(Clone, Copy)] |
| 79 | pub enum PllSrc { | 79 | pub enum PllSource { |
| 80 | /// Use an internal medium speed oscillator as the PLL source. | 80 | /// Use an internal medium speed oscillator as the PLL source. |
| 81 | MSIS(Msirange), | 81 | MSIS(Msirange), |
| 82 | /// Use the external high speed clock as the system PLL source. | 82 | /// Use the external high speed clock as the system PLL source. |
| @@ -88,12 +88,12 @@ pub enum PllSrc { | |||
| 88 | HSI, | 88 | HSI, |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | impl Into<Pllsrc> for PllSrc { | 91 | impl Into<Pllsrc> for PllSource { |
| 92 | fn into(self) -> Pllsrc { | 92 | fn into(self) -> Pllsrc { |
| 93 | match self { | 93 | match self { |
| 94 | PllSrc::MSIS(..) => Pllsrc::MSIS, | 94 | PllSource::MSIS(..) => Pllsrc::MSIS, |
| 95 | PllSrc::HSE(..) => Pllsrc::HSE, | 95 | PllSource::HSE(..) => Pllsrc::HSE, |
| 96 | PllSrc::HSI => Pllsrc::HSI, | 96 | PllSource::HSI => Pllsrc::HSI, |
| 97 | } | 97 | } |
| 98 | } | 98 | } |
| 99 | } | 99 | } |
| @@ -216,9 +216,9 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 216 | ClockSrc::PLL1_R(pll) => { | 216 | ClockSrc::PLL1_R(pll) => { |
| 217 | // Configure the PLL source | 217 | // Configure the PLL source |
| 218 | let source_clk = match pll.source { | 218 | let source_clk = match pll.source { |
| 219 | PllSrc::MSIS(range) => config.init_msis(range), | 219 | PllSource::MSIS(range) => config.init_msis(range), |
| 220 | PllSrc::HSE(hertz) => config.init_hse(hertz), | 220 | PllSource::HSE(hertz) => config.init_hse(hertz), |
| 221 | PllSrc::HSI => config.init_hsi(), | 221 | PllSource::HSI => config.init_hsi(), |
| 222 | }; | 222 | }; |
| 223 | 223 | ||
| 224 | // Calculate the reference clock, which is the source divided by m | 224 | // Calculate the reference clock, which is the source divided by m |
diff --git a/embassy-stm32/src/rcc/wba.rs b/embassy-stm32/src/rcc/wba.rs index 8925d9606..c0cd91507 100644 --- a/embassy-stm32/src/rcc/wba.rs +++ b/embassy-stm32/src/rcc/wba.rs | |||
| @@ -17,16 +17,16 @@ pub enum ClockSrc { | |||
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | #[derive(Clone, Copy, Debug)] | 19 | #[derive(Clone, Copy, Debug)] |
| 20 | pub enum PllSrc { | 20 | pub enum PllSource { |
| 21 | HSE(Hertz), | 21 | HSE(Hertz), |
| 22 | HSI, | 22 | HSI, |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | impl Into<Pllsrc> for PllSrc { | 25 | impl Into<Pllsrc> for PllSource { |
| 26 | fn into(self) -> Pllsrc { | 26 | fn into(self) -> Pllsrc { |
| 27 | match self { | 27 | match self { |
| 28 | PllSrc::HSE(..) => Pllsrc::HSE, | 28 | PllSource::HSE(..) => Pllsrc::HSE, |
| 29 | PllSrc::HSI => Pllsrc::HSI, | 29 | PllSource::HSI => Pllsrc::HSI, |
| 30 | } | 30 | } |
| 31 | } | 31 | } |
| 32 | } | 32 | } |
diff --git a/examples/stm32f2/src/bin/pll.rs b/examples/stm32f2/src/bin/pll.rs index 56591b527..feec90016 100644 --- a/examples/stm32f2/src/bin/pll.rs +++ b/examples/stm32f2/src/bin/pll.rs | |||
| @@ -7,7 +7,7 @@ use core::convert::TryFrom; | |||
| 7 | use defmt::*; | 7 | use defmt::*; |
| 8 | use embassy_executor::Spawner; | 8 | use embassy_executor::Spawner; |
| 9 | use embassy_stm32::rcc::{ | 9 | use embassy_stm32::rcc::{ |
| 10 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, PLLConfig, PLLMul, PLLPDiv, PLLPreDiv, PLLQDiv, PLLSrc, | 10 | APBPrescaler, ClockSrc, HSEConfig, HSESrc, Pll, PllMul, PllPDiv, PllPreDiv, PllQDiv, PllSource, |
| 11 | }; | 11 | }; |
| 12 | use embassy_stm32::time::Hertz; | 12 | use embassy_stm32::time::Hertz; |
| 13 | use embassy_stm32::Config; | 13 | use embassy_stm32::Config; |
| @@ -25,16 +25,16 @@ async fn main(_spawner: Spawner) { | |||
| 25 | source: HSESrc::Bypass, | 25 | source: HSESrc::Bypass, |
| 26 | }); | 26 | }); |
| 27 | // PLL uses HSE as the clock source | 27 | // PLL uses HSE as the clock source |
| 28 | config.rcc.pll_mux = PLLSrc::HSE; | 28 | config.rcc.pll_mux = PllSource::HSE; |
| 29 | config.rcc.pll = PLLConfig { | 29 | config.rcc.pll = Pll { |
| 30 | // 8 MHz clock source / 8 = 1 MHz PLL input | 30 | // 8 MHz clock source / 8 = 1 MHz PLL input |
| 31 | pre_div: unwrap!(PLLPreDiv::try_from(8)), | 31 | pre_div: unwrap!(PllPreDiv::try_from(8)), |
| 32 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO | 32 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO |
| 33 | mul: unwrap!(PLLMul::try_from(240)), | 33 | mul: unwrap!(PllMul::try_from(240)), |
| 34 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output | 34 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output |
| 35 | p_div: PLLPDiv::DIV2, | 35 | divp: PllPDiv::DIV2, |
| 36 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output | 36 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output |
| 37 | q_div: PLLQDiv::DIV5, | 37 | divq: PllQDiv::DIV5, |
| 38 | }; | 38 | }; |
| 39 | // System clock comes from PLL (= the 120 MHz main PLL output) | 39 | // System clock comes from PLL (= the 120 MHz main PLL output) |
| 40 | config.rcc.mux = ClockSrc::PLL; | 40 | config.rcc.mux = ClockSrc::PLL; |
diff --git a/examples/stm32g4/src/bin/adc.rs b/examples/stm32g4/src/bin/adc.rs index f05733847..63b20c0d4 100644 --- a/examples/stm32g4/src/bin/adc.rs +++ b/examples/stm32g4/src/bin/adc.rs | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::adc::{Adc, SampleTime}; | 7 | use embassy_stm32::adc::{Adc, SampleTime}; |
| 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 8 | use embassy_stm32::rcc::{AdcClockSource, ClockSrc, Pll, PllM, PllN, PllR, PllSource}; |
| 9 | use embassy_stm32::Config; | 9 | use embassy_stm32::Config; |
| 10 | use embassy_time::{Delay, Timer}; | 10 | use embassy_time::{Delay, Timer}; |
| 11 | use {defmt_rtt as _, panic_probe as _}; | 11 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) { | |||
| 15 | let mut config = Config::default(); | 15 | let mut config = Config::default(); |
| 16 | 16 | ||
| 17 | config.rcc.pll = Some(Pll { | 17 | config.rcc.pll = Some(Pll { |
| 18 | source: PllSrc::HSI, | 18 | source: PllSource::HSI, |
| 19 | prediv_m: PllM::DIV4, | 19 | prediv_m: PllM::DIV4, |
| 20 | mul_n: PllN::MUL85, | 20 | mul_n: PllN::MUL85, |
| 21 | div_p: None, | 21 | div_p: None, |
diff --git a/examples/stm32g4/src/bin/pll.rs b/examples/stm32g4/src/bin/pll.rs index 90c3f8dce..09ef59d44 100644 --- a/examples/stm32g4/src/bin/pll.rs +++ b/examples/stm32g4/src/bin/pll.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSrc}; | 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllM, PllN, PllR, PllSource}; |
| 8 | use embassy_stm32::Config; | 8 | use embassy_stm32::Config; |
| 9 | use embassy_time::Timer; | 9 | use embassy_time::Timer; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) { | |||
| 14 | let mut config = Config::default(); | 14 | let mut config = Config::default(); |
| 15 | 15 | ||
| 16 | config.rcc.pll = Some(Pll { | 16 | config.rcc.pll = Some(Pll { |
| 17 | source: PllSrc::HSI, | 17 | source: PllSource::HSI, |
| 18 | prediv_m: PllM::DIV4, | 18 | prediv_m: PllM::DIV4, |
| 19 | mul_n: PllN::MUL85, | 19 | mul_n: PllN::MUL85, |
| 20 | div_p: None, | 20 | div_p: None, |
diff --git a/examples/stm32g4/src/bin/usb_serial.rs b/examples/stm32g4/src/bin/usb_serial.rs index 378e7b988..565b25d60 100644 --- a/examples/stm32g4/src/bin/usb_serial.rs +++ b/examples/stm32g4/src/bin/usb_serial.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::{panic, *}; | 5 | use defmt::{panic, *}; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{Clock48MhzSrc, ClockSrc, Hsi48Config, Pll, PllM, PllN, PllQ, PllR, PllSrc}; | 7 | use embassy_stm32::rcc::{Clock48MhzSrc, ClockSrc, Hsi48Config, Pll, PllM, PllN, PllQ, PllR, PllSource}; |
| 8 | use embassy_stm32::time::Hertz; | 8 | use embassy_stm32::time::Hertz; |
| 9 | use embassy_stm32::usb::{self, Driver, Instance}; | 9 | use embassy_stm32::usb::{self, Driver, Instance}; |
| 10 | use embassy_stm32::{bind_interrupts, peripherals, Config}; | 10 | use embassy_stm32::{bind_interrupts, peripherals, Config}; |
| @@ -25,14 +25,14 @@ async fn main(_spawner: Spawner) { | |||
| 25 | // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE. | 25 | // Change this to `false` to use the HSE clock source for the USB. This example assumes an 8MHz HSE. |
| 26 | const USE_HSI48: bool = true; | 26 | const USE_HSI48: bool = true; |
| 27 | 27 | ||
| 28 | let pllq_div = if USE_HSI48 { None } else { Some(PllQ::DIV6) }; | 28 | let plldivq = if USE_HSI48 { None } else { Some(PllQ::DIV6) }; |
| 29 | 29 | ||
| 30 | config.rcc.pll = Some(Pll { | 30 | config.rcc.pll = Some(Pll { |
| 31 | source: PllSrc::HSE(Hertz(8_000_000)), | 31 | source: PllSource::HSE(Hertz(8_000_000)), |
| 32 | prediv_m: PllM::DIV2, | 32 | prediv_m: PllM::DIV2, |
| 33 | mul_n: PllN::MUL72, | 33 | mul_n: PllN::MUL72, |
| 34 | div_p: None, | 34 | div_p: None, |
| 35 | div_q: pllq_div, | 35 | div_q: plldivq, |
| 36 | // Main system clock at 144 MHz | 36 | // Main system clock at 144 MHz |
| 37 | div_r: Some(PllR::DIV2), | 37 | div_r: Some(PllR::DIV2), |
| 38 | }); | 38 | }); |
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs index 553d11c03..e5ad56fb9 100644 --- a/examples/stm32l4/src/bin/rng.rs +++ b/examples/stm32l4/src/bin/rng.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, PLLSource, Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv}; | 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllMul, PllPreDiv, PllQDiv, PllRDiv, PllSource}; |
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 9 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) { | |||
| 19 | config.rcc.mux = ClockSrc::PLL1_R; | 19 | config.rcc.mux = ClockSrc::PLL1_R; |
| 20 | config.rcc.hsi = true; | 20 | config.rcc.hsi = true; |
| 21 | config.rcc.pll = Some(Pll { | 21 | config.rcc.pll = Some(Pll { |
| 22 | source: PLLSource::HSI, | 22 | source: PllSource::HSI, |
| 23 | prediv: PllPreDiv::DIV1, | 23 | prediv: PllPreDiv::DIV1, |
| 24 | mul: PllMul::MUL18, | 24 | mul: PllMul::MUL18, |
| 25 | divp: None, | 25 | divp: None, |
diff --git a/examples/stm32l4/src/bin/rtc.rs b/examples/stm32l4/src/bin/rtc.rs index 69527c9ad..d2a2aa1f2 100644 --- a/examples/stm32l4/src/bin/rtc.rs +++ b/examples/stm32l4/src/bin/rtc.rs | |||
| @@ -22,7 +22,7 @@ async fn main(_spawner: Spawner) { | |||
| 22 | mode: HseMode::Oscillator, | 22 | mode: HseMode::Oscillator, |
| 23 | }); | 23 | }); |
| 24 | config.rcc.pll = Some(Pll { | 24 | config.rcc.pll = Some(Pll { |
| 25 | source: PLLSource::HSE, | 25 | source: PllSource::HSE, |
| 26 | prediv: PllPreDiv::DIV1, | 26 | prediv: PllPreDiv::DIV1, |
| 27 | mul: PllMul::MUL20, | 27 | mul: PllMul::MUL20, |
| 28 | divp: None, | 28 | divp: None, |
diff --git a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs index 62caeea55..3a7e5370c 100644 --- a/examples/stm32l4/src/bin/spe_adin1110_http_server.rs +++ b/examples/stm32l4/src/bin/spe_adin1110_http_server.rs | |||
| @@ -75,7 +75,7 @@ async fn main(spawner: Spawner) { | |||
| 75 | let mut config = embassy_stm32::Config::default(); | 75 | let mut config = embassy_stm32::Config::default(); |
| 76 | { | 76 | { |
| 77 | use embassy_stm32::rcc::*; | 77 | use embassy_stm32::rcc::*; |
| 78 | // 80Mhz clock (Source: 8 / SrcDiv: 1 * PLLMul 20 / ClkDiv 2) | 78 | // 80Mhz clock (Source: 8 / SrcDiv: 1 * PllMul 20 / ClkDiv 2) |
| 79 | // 80MHz highest frequency for flash 0 wait. | 79 | // 80MHz highest frequency for flash 0 wait. |
| 80 | config.rcc.mux = ClockSrc::PLL1_R; | 80 | config.rcc.mux = ClockSrc::PLL1_R; |
| 81 | config.rcc.hse = Some(Hse { | 81 | config.rcc.hse = Some(Hse { |
| @@ -83,7 +83,7 @@ async fn main(spawner: Spawner) { | |||
| 83 | mode: HseMode::Oscillator, | 83 | mode: HseMode::Oscillator, |
| 84 | }); | 84 | }); |
| 85 | config.rcc.pll = Some(Pll { | 85 | config.rcc.pll = Some(Pll { |
| 86 | source: PLLSource::HSE, | 86 | source: PllSource::HSE, |
| 87 | prediv: PllPreDiv::DIV1, | 87 | prediv: PllPreDiv::DIV1, |
| 88 | mul: PllMul::MUL20, | 88 | mul: PllMul::MUL20, |
| 89 | divp: None, | 89 | divp: None, |
diff --git a/examples/stm32l4/src/bin/usb_serial.rs b/examples/stm32l4/src/bin/usb_serial.rs index d977398f5..4baf5f05d 100644 --- a/examples/stm32l4/src/bin/usb_serial.rs +++ b/examples/stm32l4/src/bin/usb_serial.rs | |||
| @@ -27,7 +27,7 @@ async fn main(_spawner: Spawner) { | |||
| 27 | config.rcc.mux = ClockSrc::PLL1_R; | 27 | config.rcc.mux = ClockSrc::PLL1_R; |
| 28 | config.rcc.hsi = true; | 28 | config.rcc.hsi = true; |
| 29 | config.rcc.pll = Some(Pll { | 29 | config.rcc.pll = Some(Pll { |
| 30 | source: PLLSource::HSI, | 30 | source: PllSource::HSI, |
| 31 | prediv: PllPreDiv::DIV1, | 31 | prediv: PllPreDiv::DIV1, |
| 32 | mul: PllMul::MUL10, | 32 | mul: PllMul::MUL10, |
| 33 | divp: None, | 33 | divp: None, |
diff --git a/examples/stm32l5/src/bin/rng.rs b/examples/stm32l5/src/bin/rng.rs index b9d4cd255..279f4f65d 100644 --- a/examples/stm32l5/src/bin/rng.rs +++ b/examples/stm32l5/src/bin/rng.rs | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | use defmt::*; | 5 | use defmt::*; |
| 6 | use embassy_executor::Spawner; | 6 | use embassy_executor::Spawner; |
| 7 | use embassy_stm32::rcc::{ClockSrc, PLLSource, Pll, PllMul, PllPreDiv, PllRDiv}; | 7 | use embassy_stm32::rcc::{ClockSrc, Pll, PllMul, PllPreDiv, PllRDiv, PllSource}; |
| 8 | use embassy_stm32::rng::Rng; | 8 | use embassy_stm32::rng::Rng; |
| 9 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; | 9 | use embassy_stm32::{bind_interrupts, peripherals, rng, Config}; |
| 10 | use {defmt_rtt as _, panic_probe as _}; | 10 | use {defmt_rtt as _, panic_probe as _}; |
| @@ -20,7 +20,7 @@ async fn main(_spawner: Spawner) { | |||
| 20 | config.rcc.mux = ClockSrc::PLL1_R; | 20 | config.rcc.mux = ClockSrc::PLL1_R; |
| 21 | config.rcc.pll = Some(Pll { | 21 | config.rcc.pll = Some(Pll { |
| 22 | // 64Mhz clock (16 / 1 * 8 / 2) | 22 | // 64Mhz clock (16 / 1 * 8 / 2) |
| 23 | source: PLLSource::HSI, | 23 | source: PllSource::HSI, |
| 24 | prediv: PllPreDiv::DIV1, | 24 | prediv: PllPreDiv::DIV1, |
| 25 | mul: PllMul::MUL8, | 25 | mul: PllMul::MUL8, |
| 26 | divp: None, | 26 | divp: None, |
diff --git a/examples/stm32l5/src/bin/usb_ethernet.rs b/examples/stm32l5/src/bin/usb_ethernet.rs index 923193abf..0b0a0e2db 100644 --- a/examples/stm32l5/src/bin/usb_ethernet.rs +++ b/examples/stm32l5/src/bin/usb_ethernet.rs | |||
| @@ -49,7 +49,7 @@ async fn main(spawner: Spawner) { | |||
| 49 | config.rcc.mux = ClockSrc::PLL1_R; | 49 | config.rcc.mux = ClockSrc::PLL1_R; |
| 50 | config.rcc.pll = Some(Pll { | 50 | config.rcc.pll = Some(Pll { |
| 51 | // 80Mhz clock (16 / 1 * 10 / 2) | 51 | // 80Mhz clock (16 / 1 * 10 / 2) |
| 52 | source: PLLSource::HSI, | 52 | source: PllSource::HSI, |
| 53 | prediv: PllPreDiv::DIV1, | 53 | prediv: PllPreDiv::DIV1, |
| 54 | mul: PllMul::MUL10, | 54 | mul: PllMul::MUL10, |
| 55 | divp: None, | 55 | divp: None, |
diff --git a/examples/stm32l5/src/bin/usb_hid_mouse.rs b/examples/stm32l5/src/bin/usb_hid_mouse.rs index f64d0f34e..3614a8e0a 100644 --- a/examples/stm32l5/src/bin/usb_hid_mouse.rs +++ b/examples/stm32l5/src/bin/usb_hid_mouse.rs | |||
| @@ -26,7 +26,7 @@ async fn main(_spawner: Spawner) { | |||
| 26 | config.rcc.mux = ClockSrc::PLL1_R; | 26 | config.rcc.mux = ClockSrc::PLL1_R; |
| 27 | config.rcc.pll = Some(Pll { | 27 | config.rcc.pll = Some(Pll { |
| 28 | // 80Mhz clock (16 / 1 * 10 / 2) | 28 | // 80Mhz clock (16 / 1 * 10 / 2) |
| 29 | source: PLLSource::HSI, | 29 | source: PllSource::HSI, |
| 30 | prediv: PllPreDiv::DIV1, | 30 | prediv: PllPreDiv::DIV1, |
| 31 | mul: PllMul::MUL10, | 31 | mul: PllMul::MUL10, |
| 32 | divp: None, | 32 | divp: None, |
diff --git a/examples/stm32l5/src/bin/usb_serial.rs b/examples/stm32l5/src/bin/usb_serial.rs index 58a8898a6..f2b894b68 100644 --- a/examples/stm32l5/src/bin/usb_serial.rs +++ b/examples/stm32l5/src/bin/usb_serial.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | config.rcc.mux = ClockSrc::PLL1_R; | 24 | config.rcc.mux = ClockSrc::PLL1_R; |
| 25 | config.rcc.pll = Some(Pll { | 25 | config.rcc.pll = Some(Pll { |
| 26 | // 80Mhz clock (16 / 1 * 10 / 2) | 26 | // 80Mhz clock (16 / 1 * 10 / 2) |
| 27 | source: PLLSource::HSI, | 27 | source: PllSource::HSI, |
| 28 | prediv: PllPreDiv::DIV1, | 28 | prediv: PllPreDiv::DIV1, |
| 29 | mul: PllMul::MUL10, | 29 | mul: PllMul::MUL10, |
| 30 | divp: None, | 30 | divp: None, |
diff --git a/examples/stm32u5/src/bin/usb_serial.rs b/examples/stm32u5/src/bin/usb_serial.rs index a218d5dfd..839d6472f 100644 --- a/examples/stm32u5/src/bin/usb_serial.rs +++ b/examples/stm32u5/src/bin/usb_serial.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | 24 | ||
| 25 | let mut config = Config::default(); | 25 | let mut config = Config::default(); |
| 26 | config.rcc.mux = ClockSrc::PLL1_R(PllConfig { | 26 | config.rcc.mux = ClockSrc::PLL1_R(PllConfig { |
| 27 | source: PllSrc::HSI, | 27 | source: PllSource::HSI, |
| 28 | m: Pllm::DIV2, | 28 | m: Pllm::DIV2, |
| 29 | n: Plln::MUL10, | 29 | n: Plln::MUL10, |
| 30 | r: Plldiv::DIV1, | 30 | r: Plldiv::DIV1, |
diff --git a/examples/stm32wl/src/bin/lora_lorawan.rs b/examples/stm32wl/src/bin/lora_lorawan.rs index 226e6786f..348e3cdce 100644 --- a/examples/stm32wl/src/bin/lora_lorawan.rs +++ b/examples/stm32wl/src/bin/lora_lorawan.rs | |||
| @@ -44,7 +44,7 @@ async fn main(_spawner: Spawner) { | |||
| 44 | }); | 44 | }); |
| 45 | config.rcc.mux = ClockSrc::PLL1_R; | 45 | config.rcc.mux = ClockSrc::PLL1_R; |
| 46 | config.rcc.pll = Some(Pll { | 46 | config.rcc.pll = Some(Pll { |
| 47 | source: PLLSource::HSE, | 47 | source: PllSource::HSE, |
| 48 | prediv: PllPreDiv::DIV2, | 48 | prediv: PllPreDiv::DIV2, |
| 49 | mul: PllMul::MUL6, | 49 | mul: PllMul::MUL6, |
| 50 | divp: None, | 50 | divp: None, |
diff --git a/examples/stm32wl/src/bin/lora_p2p_receive.rs b/examples/stm32wl/src/bin/lora_p2p_receive.rs index a3bb0c0f9..c643ddb15 100644 --- a/examples/stm32wl/src/bin/lora_p2p_receive.rs +++ b/examples/stm32wl/src/bin/lora_p2p_receive.rs | |||
| @@ -37,7 +37,7 @@ async fn main(_spawner: Spawner) { | |||
| 37 | }); | 37 | }); |
| 38 | config.rcc.mux = ClockSrc::PLL1_R; | 38 | config.rcc.mux = ClockSrc::PLL1_R; |
| 39 | config.rcc.pll = Some(Pll { | 39 | config.rcc.pll = Some(Pll { |
| 40 | source: PLLSource::HSE, | 40 | source: PllSource::HSE, |
| 41 | prediv: PllPreDiv::DIV2, | 41 | prediv: PllPreDiv::DIV2, |
| 42 | mul: PllMul::MUL6, | 42 | mul: PllMul::MUL6, |
| 43 | divp: None, | 43 | divp: None, |
diff --git a/examples/stm32wl/src/bin/lora_p2p_send.rs b/examples/stm32wl/src/bin/lora_p2p_send.rs index 08dd0845e..7fe8cea3e 100644 --- a/examples/stm32wl/src/bin/lora_p2p_send.rs +++ b/examples/stm32wl/src/bin/lora_p2p_send.rs | |||
| @@ -37,7 +37,7 @@ async fn main(_spawner: Spawner) { | |||
| 37 | }); | 37 | }); |
| 38 | config.rcc.mux = ClockSrc::PLL1_R; | 38 | config.rcc.mux = ClockSrc::PLL1_R; |
| 39 | config.rcc.pll = Some(Pll { | 39 | config.rcc.pll = Some(Pll { |
| 40 | source: PLLSource::HSE, | 40 | source: PllSource::HSE, |
| 41 | prediv: PllPreDiv::DIV2, | 41 | prediv: PllPreDiv::DIV2, |
| 42 | mul: PllMul::MUL6, | 42 | mul: PllMul::MUL6, |
| 43 | divp: None, | 43 | divp: None, |
diff --git a/examples/stm32wl/src/bin/random.rs b/examples/stm32wl/src/bin/random.rs index 1a8822b42..2fd234966 100644 --- a/examples/stm32wl/src/bin/random.rs +++ b/examples/stm32wl/src/bin/random.rs | |||
| @@ -25,7 +25,7 @@ async fn main(_spawner: Spawner) { | |||
| 25 | }); | 25 | }); |
| 26 | config.rcc.mux = ClockSrc::PLL1_R; | 26 | config.rcc.mux = ClockSrc::PLL1_R; |
| 27 | config.rcc.pll = Some(Pll { | 27 | config.rcc.pll = Some(Pll { |
| 28 | source: PLLSource::HSE, | 28 | source: PllSource::HSE, |
| 29 | prediv: PllPreDiv::DIV2, | 29 | prediv: PllPreDiv::DIV2, |
| 30 | mul: PllMul::MUL6, | 30 | mul: PllMul::MUL6, |
| 31 | divp: None, | 31 | divp: None, |
diff --git a/examples/stm32wl/src/bin/rtc.rs b/examples/stm32wl/src/bin/rtc.rs index b3b7f9c5c..4ffb0bb58 100644 --- a/examples/stm32wl/src/bin/rtc.rs +++ b/examples/stm32wl/src/bin/rtc.rs | |||
| @@ -24,7 +24,7 @@ async fn main(_spawner: Spawner) { | |||
| 24 | }); | 24 | }); |
| 25 | config.rcc.mux = ClockSrc::PLL1_R; | 25 | config.rcc.mux = ClockSrc::PLL1_R; |
| 26 | config.rcc.pll = Some(Pll { | 26 | config.rcc.pll = Some(Pll { |
| 27 | source: PLLSource::HSE, | 27 | source: PllSource::HSE, |
| 28 | prediv: PllPreDiv::DIV2, | 28 | prediv: PllPreDiv::DIV2, |
| 29 | mul: PllMul::MUL6, | 29 | mul: PllMul::MUL6, |
| 30 | divp: None, | 30 | divp: None, |
diff --git a/tests/stm32/src/common.rs b/tests/stm32/src/common.rs index 3668e18ce..35f42d28a 100644 --- a/tests/stm32/src/common.rs +++ b/tests/stm32/src/common.rs | |||
| @@ -241,16 +241,16 @@ pub fn config() -> Config { | |||
| 241 | source: HSESrc::Bypass, | 241 | source: HSESrc::Bypass, |
| 242 | }); | 242 | }); |
| 243 | // PLL uses HSE as the clock source | 243 | // PLL uses HSE as the clock source |
| 244 | config.rcc.pll_mux = PLLSrc::HSE; | 244 | config.rcc.pll_mux = PllSource::HSE; |
| 245 | config.rcc.pll = PLLConfig { | 245 | config.rcc.pll = Pll { |
| 246 | // 8 MHz clock source / 8 = 1 MHz PLL input | 246 | // 8 MHz clock source / 8 = 1 MHz PLL input |
| 247 | pre_div: unwrap!(PLLPreDiv::try_from(8)), | 247 | pre_div: unwrap!(PllPreDiv::try_from(8)), |
| 248 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO | 248 | // 1 MHz PLL input * 240 = 240 MHz PLL VCO |
| 249 | mul: unwrap!(PLLMul::try_from(240)), | 249 | mul: unwrap!(PllMul::try_from(240)), |
| 250 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output | 250 | // 240 MHz PLL VCO / 2 = 120 MHz main PLL output |
| 251 | p_div: PLLPDiv::DIV2, | 251 | divp: PllPDiv::DIV2, |
| 252 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output | 252 | // 240 MHz PLL VCO / 5 = 48 MHz PLL48 output |
| 253 | q_div: PLLQDiv::DIV5, | 253 | divq: PllQDiv::DIV5, |
| 254 | }; | 254 | }; |
| 255 | // System clock comes from PLL (= the 120 MHz main PLL output) | 255 | // System clock comes from PLL (= the 120 MHz main PLL output) |
| 256 | config.rcc.mux = ClockSrc::PLL; | 256 | config.rcc.mux = ClockSrc::PLL; |
| @@ -397,7 +397,7 @@ pub fn config() -> Config { | |||
| 397 | config.rcc.mux = ClockSrc::PLL1_R; | 397 | config.rcc.mux = ClockSrc::PLL1_R; |
| 398 | config.rcc.hsi = true; | 398 | config.rcc.hsi = true; |
| 399 | config.rcc.pll = Some(Pll { | 399 | config.rcc.pll = Some(Pll { |
| 400 | source: PLLSource::HSI, | 400 | source: PllSource::HSI, |
| 401 | prediv: PllPreDiv::DIV1, | 401 | prediv: PllPreDiv::DIV1, |
| 402 | mul: PllMul::MUL18, | 402 | mul: PllMul::MUL18, |
| 403 | divp: None, | 403 | divp: None, |
| @@ -416,7 +416,7 @@ pub fn config() -> Config { | |||
| 416 | }); | 416 | }); |
| 417 | config.rcc.mux = ClockSrc::PLL1_R; | 417 | config.rcc.mux = ClockSrc::PLL1_R; |
| 418 | config.rcc.pll = Some(Pll { | 418 | config.rcc.pll = Some(Pll { |
| 419 | source: PLLSource::HSE, | 419 | source: PllSource::HSE, |
| 420 | prediv: PllPreDiv::DIV2, | 420 | prediv: PllPreDiv::DIV2, |
| 421 | mul: PllMul::MUL6, | 421 | mul: PllMul::MUL6, |
| 422 | divp: None, | 422 | divp: None, |
| @@ -432,7 +432,7 @@ pub fn config() -> Config { | |||
| 432 | config.rcc.mux = ClockSrc::PLL1_R; | 432 | config.rcc.mux = ClockSrc::PLL1_R; |
| 433 | config.rcc.pll = Some(Pll { | 433 | config.rcc.pll = Some(Pll { |
| 434 | // 110Mhz clock (16 / 4 * 55 / 2) | 434 | // 110Mhz clock (16 / 4 * 55 / 2) |
| 435 | source: PLLSource::HSI, | 435 | source: PllSource::HSI, |
| 436 | prediv: PllPreDiv::DIV4, | 436 | prediv: PllPreDiv::DIV4, |
| 437 | mul: PllMul::MUL55, | 437 | mul: PllMul::MUL55, |
| 438 | divp: None, | 438 | divp: None, |
| @@ -462,9 +462,9 @@ pub fn config() -> Config { | |||
| 462 | use embassy_stm32::rcc::*; | 462 | use embassy_stm32::rcc::*; |
| 463 | config.rcc.hsi = true; | 463 | config.rcc.hsi = true; |
| 464 | config.rcc.pll = Some(Pll { | 464 | config.rcc.pll = Some(Pll { |
| 465 | source: PLLSource::HSI, | 465 | source: PllSource::HSI, |
| 466 | mul: PLLMul::MUL4, | 466 | mul: PllMul::MUL4, |
| 467 | div: PLLDiv::DIV2, // 32Mhz clock (16 * 4 / 2) | 467 | div: PllDiv::DIV2, // 32Mhz clock (16 * 4 / 2) |
| 468 | }); | 468 | }); |
| 469 | config.rcc.mux = ClockSrc::PLL1_P; | 469 | config.rcc.mux = ClockSrc::PLL1_P; |
| 470 | } | 470 | } |
| @@ -474,9 +474,9 @@ pub fn config() -> Config { | |||
| 474 | use embassy_stm32::rcc::*; | 474 | use embassy_stm32::rcc::*; |
| 475 | config.rcc.hsi = true; | 475 | config.rcc.hsi = true; |
| 476 | config.rcc.pll = Some(Pll { | 476 | config.rcc.pll = Some(Pll { |
| 477 | source: PLLSource::HSI, | 477 | source: PllSource::HSI, |
| 478 | mul: PLLMul::MUL4, | 478 | mul: PllMul::MUL4, |
| 479 | div: PLLDiv::DIV2, // 32Mhz clock (16 * 4 / 2) | 479 | div: PllDiv::DIV2, // 32Mhz clock (16 * 4 / 2) |
| 480 | }); | 480 | }); |
| 481 | config.rcc.mux = ClockSrc::PLL1_P; | 481 | config.rcc.mux = ClockSrc::PLL1_P; |
| 482 | } | 482 | } |
