Add Clock type per RCC family
This commit is contained in:
parent
952f525af5
commit
2c63393c9e
@ -1,6 +1,6 @@
|
||||
use crate::pac;
|
||||
use crate::peripherals::{self, CRS, RCC, SYSCFG};
|
||||
use crate::rcc::{get_freqs, set_freqs, Clocks};
|
||||
use crate::rcc::{get_freqs, set_freqs};
|
||||
use crate::time::Hertz;
|
||||
use crate::time::U32Ext;
|
||||
use core::marker::PhantomData;
|
||||
@ -12,6 +12,14 @@ use pac::rcc::vals::{Hpre, Msirange, Plldiv, Pllmul, Pllsrc, Ppre, Sw};
|
||||
/// 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.
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Clocks {
|
||||
pub sys: Hertz,
|
||||
pub ahb: Hertz,
|
||||
pub apb1: Hertz,
|
||||
pub apb2: Hertz,
|
||||
}
|
||||
|
||||
/// System clock mux source
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum ClockSrc {
|
||||
|
@ -1,20 +1,11 @@
|
||||
#![macro_use]
|
||||
|
||||
use crate::peripherals;
|
||||
use crate::time::Hertz;
|
||||
use core::mem::MaybeUninit;
|
||||
|
||||
/// Frozen clock frequencies
|
||||
///
|
||||
/// The existence of this value indicates that the clock configuration can no longer be changed
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Clocks {
|
||||
pub sys: Hertz,
|
||||
pub ahb: Hertz,
|
||||
pub apb1: Hertz,
|
||||
pub apb2: Hertz,
|
||||
}
|
||||
|
||||
static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit();
|
||||
|
||||
/// Sets the clock frequencies
|
||||
@ -36,6 +27,37 @@ cfg_if::cfg_if! {
|
||||
} else if #[cfg(rcc_l0)] {
|
||||
mod l0;
|
||||
pub use l0::*;
|
||||
} else if #[cfg(rcc_l4)] {
|
||||
// TODO: Implement
|
||||
use crate::time::Hertz;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Clocks {
|
||||
pub apb1: Hertz,
|
||||
pub apb2: Hertz,
|
||||
pub ahb2: Hertz,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Config {}
|
||||
pub unsafe fn init(_config: Config) {
|
||||
}
|
||||
} else if #[cfg(rcc_f4)] {
|
||||
// TODO: Implement
|
||||
use crate::time::Hertz;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Clocks {
|
||||
pub apb1: Hertz,
|
||||
pub apb2: Hertz,
|
||||
pub ahb2: Hertz,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Config {}
|
||||
pub unsafe fn init(_config: Config) {
|
||||
}
|
||||
|
||||
} else {
|
||||
#[derive(Default)]
|
||||
pub struct Config {}
|
||||
|
Loading…
Reference in New Issue
Block a user