Rename to follow ref manual and CubeIDE

This commit is contained in:
Carl St-Laurent 2023-06-08 20:46:48 -04:00
parent 0915fb73b2
commit 8ddeaddc67
No known key found for this signature in database
GPG key ID: 88D67D5DC9A6996D
2 changed files with 12 additions and 12 deletions

View file

@ -17,7 +17,7 @@ pub const LSI_FREQ: Hertz = Hertz(32_000);
pub enum ClockSrc { pub enum ClockSrc {
HSE(Hertz), HSE(Hertz),
HSI16, HSI16,
PLL(PllSrc, PllM, PllN, PllClkDiv), PLLCLK(PllSrc, PllM, PllN, PllR),
} }
/// AHB prescaler /// AHB prescaler
@ -61,27 +61,27 @@ impl Into<Pllsrc> for PllSrc {
} }
#[derive(Clone, Copy)] #[derive(Clone, Copy)]
pub enum PllClkDiv { pub enum PllR {
Div2, Div2,
Div4, Div4,
Div6, Div6,
Div8, Div8,
} }
impl PllClkDiv { impl PllR {
pub fn to_div(self) -> u32 { pub fn to_div(self) -> u32 {
let val: u8 = self.into(); let val: u8 = self.into();
(val as u32 + 1) * 2 (val as u32 + 1) * 2
} }
} }
impl From<PllClkDiv> for u8 { impl From<PllR> for u8 {
fn from(val: PllClkDiv) -> u8 { fn from(val: PllR) -> u8 {
match val { match val {
PllClkDiv::Div2 => 0b00, PllR::Div2 => 0b00,
PllClkDiv::Div4 => 0b01, PllR::Div4 => 0b01,
PllClkDiv::Div6 => 0b10, PllR::Div6 => 0b10,
PllClkDiv::Div8 => 0b11, PllR::Div8 => 0b11,
} }
} }
} }
@ -260,7 +260,7 @@ pub(crate) unsafe fn init(config: Config) {
(freq.0, Sw::HSE) (freq.0, Sw::HSE)
} }
ClockSrc::PLL(src, prediv, mul, div) => { ClockSrc::PLLCLK(src, prediv, mul, div) => {
let src_freq = match src { let src_freq = match src {
PllSrc::HSI16 => { PllSrc::HSI16 => {
// Enable HSI16 as clock source for PLL // Enable HSI16 as clock source for PLL

View file

@ -4,7 +4,7 @@
use defmt::*; use defmt::*;
use embassy_executor::Spawner; use embassy_executor::Spawner;
use embassy_stm32::rcc::{ClockSrc, PllClkDiv, PllM, PllN, PllSrc}; use embassy_stm32::rcc::{ClockSrc, PllM, PllN, PllR, PllSrc};
use embassy_stm32::Config; use embassy_stm32::Config;
use embassy_time::{Duration, Timer}; use embassy_time::{Duration, Timer};
use {defmt_rtt as _, panic_probe as _}; use {defmt_rtt as _, panic_probe as _};
@ -14,7 +14,7 @@ async fn main(_spawner: Spawner) {
let mut config = Config::default(); let mut config = Config::default();
// Configure PLL to max frequency of 170 MHz // Configure PLL to max frequency of 170 MHz
config.rcc.mux = ClockSrc::PLL(PllSrc::HSI16, PllM::Div4, PllN::Mul85, PllClkDiv::Div2); config.rcc.mux = ClockSrc::PLLCLK(PllSrc::HSI16, PllM::Div4, PllN::Mul85, PllR::Div2);
let _p = embassy_stm32::init(config); let _p = embassy_stm32::init(config);
info!("Hello World!"); info!("Hello World!");