This commit is contained in:
chemicstry 2022-03-16 23:55:07 +02:00
parent 224071f08e
commit 9d71acc49e
4 changed files with 18 additions and 14 deletions

View File

@ -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<T>, 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<T>, Dma: SdmmcDma<T>> 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,12 +1205,11 @@ impl SdmmcInner {
w.set_cmdindex(12);
w.set_cpsmen(true);
cfg_if::cfg_if! {
if #[cfg(sdmmc_v2)] {
#[cfg(sdmmc_v2)]
{
w.set_cmdstop(true);
w.set_cmdtrans(false);
}
}
});
// Wait for the abort

View File

@ -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);

View File

@ -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);

View File

@ -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);