rp clock configuration

This commit is contained in:
Caleb Jamison
2023-05-07 13:49:48 -04:00
parent 79c60f4a7d
commit 1a96eae22c
2 changed files with 438 additions and 97 deletions

View File

@ -136,23 +136,35 @@ embassy_hal_common::peripherals! {
static BOOT2: [u8; 256] = *include_bytes!("boot2.bin");
pub mod config {
use crate::clocks::ClockConfig;
#[non_exhaustive]
pub struct Config {}
pub struct Config {
pub clocks: ClockConfig,
}
impl Default for Config {
fn default() -> Self {
Self {}
Self {
clocks: ClockConfig::crystal(12_000_000),
}
}
}
impl Config {
pub fn new(clocks: ClockConfig) -> Self {
Self { clocks }
}
}
}
pub fn init(_config: config::Config) -> Peripherals {
pub fn init(config: config::Config) -> Peripherals {
// Do this first, so that it panics if user is calling `init` a second time
// before doing anything important.
let peripherals = Peripherals::take();
unsafe {
clocks::init();
clocks::init(config.clocks);
#[cfg(feature = "time-driver")]
timer::init();
dma::init();