stm32/rcc: cleanup merge
This commit is contained in:
parent
2f18770e27
commit
a8a491212b
5 changed files with 14 additions and 8 deletions
|
@ -142,7 +142,7 @@ impl Div<APBPrescaler> for Hertz {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(any(rcc_f1, rcc_g4, rcc_h7, rcc_wb, rcc_wl5, rcc_wle)))]
|
#[cfg(not(any(rcc_f1, rcc_f100, rcc_f1cl, rcc_g4, rcc_h7, rcc_h7ab, rcc_wb, rcc_wl5, rcc_wle)))]
|
||||||
impl From<APBPrescaler> for rcc::vals::Ppre {
|
impl From<APBPrescaler> for rcc::vals::Ppre {
|
||||||
fn from(val: APBPrescaler) -> rcc::vals::Ppre {
|
fn from(val: APBPrescaler) -> rcc::vals::Ppre {
|
||||||
use rcc::vals::Ppre;
|
use rcc::vals::Ppre;
|
||||||
|
|
|
@ -380,7 +380,7 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
APBPrescaler::NotDivided => (ahb_freq.0, ahb_freq.0),
|
APBPrescaler::NotDivided => (ahb_freq.0, ahb_freq.0),
|
||||||
pre => {
|
pre => {
|
||||||
let pre: Ppre = pre.into();
|
let pre: Ppre = pre.into();
|
||||||
let pre: u8 = 1 << (pre.0 - 3);
|
let pre: u8 = 1 << (pre.to_bits() - 3);
|
||||||
let freq = ahb_freq.0 / pre as u32;
|
let freq = ahb_freq.0 / pre as u32;
|
||||||
(freq, freq * 2)
|
(freq, freq * 2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,15 @@ pub enum ClockSrc {
|
||||||
PLL,
|
PLL,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<u8> for APBPrescaler {
|
/// PLL clock input source
|
||||||
fn into(self) -> u8 {
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
pub enum PllSrc {
|
||||||
|
HSI16,
|
||||||
|
HSE(Hertz),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Into<Pllsrc> for PllSrc {
|
||||||
|
fn into(self) -> Pllsrc {
|
||||||
match self {
|
match self {
|
||||||
PllSrc::HSE(..) => Pllsrc::HSE,
|
PllSrc::HSE(..) => Pllsrc::HSE,
|
||||||
PllSrc::HSI16 => Pllsrc::HSI16,
|
PllSrc::HSI16 => Pllsrc::HSI16,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
pub use super::common::{AHBPrescaler, APBPrescaler};
|
pub use super::common::{AHBPrescaler, APBPrescaler};
|
||||||
use crate::pac::RCC;
|
use crate::rcc::Clocks;
|
||||||
use crate::rcc::{set_freqs, Clocks, Clocks};
|
use crate::time::{khz, mhz, Hertz};
|
||||||
use crate::time::{khz, mhz, Hertz, Hertz};
|
|
||||||
|
|
||||||
/// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC,
|
/// Most of clock setup is copied from stm32l0xx-hal, and adopted to the generated PAC,
|
||||||
/// and with the addition of the init function to configure a system clock.
|
/// and with the addition of the init function to configure a system clock.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
pub use super::common::{AHBPrescaler, APBPrescaler, VoltageScale};
|
pub use super::common::{AHBPrescaler, APBPrescaler, VoltageScale};
|
||||||
use crate::pac::pwr::vals::Dbp;
|
use crate::pac::pwr::vals::Dbp;
|
||||||
use crate::pac::{FLASH, FLASH, PWR, RCC, RCC};
|
use crate::pac::{FLASH, PWR, RCC};
|
||||||
use crate::rcc::{set_freqs, Clocks};
|
use crate::rcc::{set_freqs, Clocks};
|
||||||
use crate::time::Hertz;
|
use crate::time::Hertz;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue