diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs index b060eb93b..2a92b7f31 100644 --- a/embassy-stm32/src/sdmmc/mod.rs +++ b/embassy-stm32/src/sdmmc/mod.rs @@ -85,6 +85,7 @@ pub struct Card { /// SD Status pub status: SDStatus, } + impl Card { /// Size in bytes pub fn size(&self) -> u64 { @@ -184,7 +185,7 @@ pub struct Sdmmc<'d, T: Instance, P: Pins, Dma = NoDma> { config: Config, dma: Dma, /// Current clock to card - pub clock: Hertz, + clock: Hertz, /// Current signalling scheme to card signalling: Signalling, /// Card @@ -337,6 +338,11 @@ impl<'d, T: Instance, P: Pins, Dma: SdmmcDma> Sdmmc<'d, T, P, Dma> { self.card.as_ref().ok_or(Error::NoCard) } + /// Get the current SDMMC bus clock + pub fn clock(&self) -> Hertz { + self.clock + } + #[inline(always)] fn on_interrupt(_: *mut ()) { let regs = T::inner(); @@ -666,11 +672,6 @@ impl SdmmcInner { } } - /// Get the current SDMMC bus clock - //pub fn clock(&self) -> Hertz { - // self.clock - //} - /// Data transfer is in progress #[inline(always)] fn data_active(&self) -> bool { @@ -806,6 +807,7 @@ impl SdmmcInner { }); } + /// Stops the DMA datapath fn stop_datapath(&self) { let regs = self.0; @@ -1203,11 +1205,10 @@ impl SdmmcInner { w.set_cmdindex(12); w.set_cpsmen(true); - cfg_if::cfg_if! { - if #[cfg(sdmmc_v2)] { - w.set_cmdstop(true); - w.set_cmdtrans(false); - } + #[cfg(sdmmc_v2)] + { + w.set_cmdstop(true); + w.set_cmdtrans(false); } }); diff --git a/examples/stm32f4/src/bin/sdmmc.rs b/examples/stm32f4/src/bin/sdmmc.rs index 301d7dda0..2ef367397 100644 --- a/examples/stm32f4/src/bin/sdmmc.rs +++ b/examples/stm32f4/src/bin/sdmmc.rs @@ -31,7 +31,8 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { p.DMA2_CH3, ); - info!("Configured clock: {}", sdmmc.clock.0); + // Should print 400kHz for initialization + info!("Configured clock: {}", sdmmc.clock().0); unwrap!(sdmmc.init_card(25.mhz()).await); diff --git a/examples/stm32f7/src/bin/sdmmc.rs b/examples/stm32f7/src/bin/sdmmc.rs index f8550d23c..cd6a0d1f1 100644 --- a/examples/stm32f7/src/bin/sdmmc.rs +++ b/examples/stm32f7/src/bin/sdmmc.rs @@ -31,7 +31,8 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { p.DMA2_CH3 ); - info!("Configured clock: {}", sdmmc.clock.0); + // Should print 400kHz for initialization + info!("Configured clock: {}", sdmmc.clock().0); unwrap!(sdmmc.init_card(25.mhz()).await); diff --git a/examples/stm32h7/src/bin/sdmmc.rs b/examples/stm32h7/src/bin/sdmmc.rs index 255c5568f..19c4deed1 100644 --- a/examples/stm32h7/src/bin/sdmmc.rs +++ b/examples/stm32h7/src/bin/sdmmc.rs @@ -30,7 +30,8 @@ async fn main(_spawner: Spawner, p: Peripherals) -> ! { Default::default(), ); - info!("Configured clock: {}", sdmmc.clock.0); + // Should print 400kHz for initialization + info!("Configured clock: {}", sdmmc.clock().0); unwrap!(sdmmc.init_card(25.mhz()).await);