SDMMC: Implement Default for Config and add docs

This commit is contained in:
Thales Fragoso 2021-05-15 21:21:06 -03:00
parent 86063ac2a2
commit 0f5ba6d4a9
4 changed files with 19 additions and 44 deletions

View File

@ -1 +0,0 @@
pub mod rcc;

View File

@ -1,36 +0,0 @@
use crate::time::Hertz;
/// Frozen core clock frequencies
#[derive(Clone, Copy)]
pub struct CoreClocks {
pub hclk: Hertz,
pub pclk1: Hertz,
pub pclk2: Hertz,
pub pclk3: Hertz,
pub pclk4: Hertz,
pub ppre1: u8,
pub ppre2: u8,
pub ppre3: u8,
pub ppre4: u8,
pub csi_ck: Option<Hertz>,
pub hsi_ck: Option<Hertz>,
pub hsi48_ck: Option<Hertz>,
pub lsi_ck: Option<Hertz>,
pub per_ck: Option<Hertz>,
pub hse_ck: Option<Hertz>,
pub mco1_ck: Option<Hertz>,
pub mco2_ck: Option<Hertz>,
pub pll1_p_ck: Option<Hertz>,
pub pll1_q_ck: Option<Hertz>,
pub pll1_r_ck: Option<Hertz>,
pub pll2_p_ck: Option<Hertz>,
pub pll2_q_ck: Option<Hertz>,
pub pll2_r_ck: Option<Hertz>,
pub pll3_p_ck: Option<Hertz>,
pub pll3_q_ck: Option<Hertz>,
pub pll3_r_ck: Option<Hertz>,
pub timx_ker_ck: Hertz,
pub timy_ker_ck: Hertz,
pub sys_ck: Hertz,
pub c_ck: Hertz,
}

View File

@ -28,13 +28,6 @@ pub mod sdmmc_v2;
#[cfg(feature = "_sdmmc_v2")] #[cfg(feature = "_sdmmc_v2")]
pub use sdmmc_v2 as sdmmc; pub use sdmmc_v2 as sdmmc;
pub mod time;
#[cfg(feature = "stm32h750vb")]
mod h7;
#[cfg(feature = "stm32h750vb")]
pub use h7::rcc;
// This must go LAST so that it sees the `impl_foo!` macros // This must go LAST so that it sees the `impl_foo!` macros
mod pac; mod pac;
pub mod time; pub mod time;

View File

@ -1,3 +1,4 @@
use core::default::Default;
use core::future::Future; use core::future::Future;
use core::marker::PhantomData; use core::marker::PhantomData;
use core::task::Poll; use core::task::Poll;
@ -135,6 +136,14 @@ fn clk_div(ker_ck: Hertz, sdmmc_ck: u32) -> Result<(u16, Hertz), Error> {
} }
} }
/// SDMMC configuration
///
/// You should probably change the default clock values to match your configuration
///
/// Default values:
/// hclk = 400_000_000 Hz
/// kernel_clk: 100_000_000 Hz
/// data_transfer_timeout: 5_000_000
#[non_exhaustive] #[non_exhaustive]
pub struct Config { pub struct Config {
/// AHB clock /// AHB clock
@ -145,6 +154,16 @@ pub struct Config {
pub data_transfer_timeout: u32, pub data_transfer_timeout: u32,
} }
impl Default for Config {
fn default() -> Self {
Self {
hclk: Hertz(400_000_000),
kernel_clk: Hertz(100_000_000),
data_transfer_timeout: 5_000_000,
}
}
}
/// Sdmmc device /// Sdmmc device
pub struct Sdmmc<'d, T: Instance, P: Pins<T>> { pub struct Sdmmc<'d, T: Instance, P: Pins<T>> {
sdmmc: PhantomData<&'d mut T>, sdmmc: PhantomData<&'d mut T>,