Handle stbiterr in 4bit wide mode for sdmmc_v1

This commit is contained in:
Scott Mabin 2023-09-10 14:51:59 +01:00
parent f17f09057d
commit 268da2fcde
2 changed files with 48 additions and 12 deletions

View File

@ -58,7 +58,7 @@ sdio-host = "0.5.0"
embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true }
critical-section = "1.1" critical-section = "1.1"
atomic-polyfill = "1.0.1" atomic-polyfill = "1.0.1"
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-eaa4987e523408dfb31c1b76765dd345d2761373" } stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e667107cf81934383ec5744f49b2cda0599ec749" }
vcell = "0.1.3" vcell = "0.1.3"
bxcan = "0.7.0" bxcan = "0.7.0"
nb = "1.0.0" nb = "1.0.0"
@ -77,7 +77,7 @@ critical-section = { version = "1.1", features = ["std"] }
[build-dependencies] [build-dependencies]
proc-macro2 = "1.0.36" proc-macro2 = "1.0.36"
quote = "1.0.15" quote = "1.0.15"
stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-eaa4987e523408dfb31c1b76765dd345d2761373", default-features = false, features = ["metadata"]} stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e667107cf81934383ec5744f49b2cda0599ec749", default-features = false, features = ["metadata"]}
[features] [features]
default = ["rt"] default = ["rt"]

View File

@ -33,6 +33,8 @@ impl<T: Instance> InterruptHandler<T> {
w.set_dtimeoutie(enable); w.set_dtimeoutie(enable);
w.set_dataendie(enable); w.set_dataendie(enable);
#[cfg(sdmmc_v1)]
w.set_stbiterre(enable);
#[cfg(sdmmc_v2)] #[cfg(sdmmc_v2)]
w.set_dabortie(enable); w.set_dabortie(enable);
}); });
@ -102,6 +104,8 @@ pub enum Error {
BadClock, BadClock,
SignalingSwitchFailed, SignalingSwitchFailed,
PeripheralBusy, PeripheralBusy,
#[cfg(sdmmc_v1)]
StBitErr,
} }
/// A SD command /// A SD command
@ -707,9 +711,15 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
if status.dcrcfail() { if status.dcrcfail() {
return Poll::Ready(Err(Error::Crc)); return Poll::Ready(Err(Error::Crc));
} else if status.dtimeout() { }
if status.dtimeout() {
return Poll::Ready(Err(Error::Timeout)); return Poll::Ready(Err(Error::Timeout));
} else if status.dataend() { }
#[cfg(sdmmc_v1)]
if status.stbiterr() {
return Poll::Ready(Err(Error::StBitErr));
}
if status.dataend() {
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
Poll::Pending Poll::Pending
@ -782,9 +792,15 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
if status.dcrcfail() { if status.dcrcfail() {
return Poll::Ready(Err(Error::Crc)); return Poll::Ready(Err(Error::Crc));
} else if status.dtimeout() { }
if status.dtimeout() {
return Poll::Ready(Err(Error::Timeout)); return Poll::Ready(Err(Error::Timeout));
} else if status.dataend() { }
#[cfg(sdmmc_v1)]
if status.stbiterr() {
return Poll::Ready(Err(Error::StBitErr));
}
if status.dataend() {
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
Poll::Pending Poll::Pending
@ -836,6 +852,8 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
w.set_dataendc(true); w.set_dataendc(true);
w.set_dbckendc(true); w.set_dbckendc(true);
w.set_sdioitc(true); w.set_sdioitc(true);
#[cfg(sdmmc_v1)]
w.set_stbiterrc(true);
#[cfg(sdmmc_v2)] #[cfg(sdmmc_v2)]
{ {
@ -873,9 +891,15 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
if status.dcrcfail() { if status.dcrcfail() {
return Poll::Ready(Err(Error::Crc)); return Poll::Ready(Err(Error::Crc));
} else if status.dtimeout() { }
if status.dtimeout() {
return Poll::Ready(Err(Error::Timeout)); return Poll::Ready(Err(Error::Timeout));
} else if status.dataend() { }
#[cfg(sdmmc_v1)]
if status.stbiterr() {
return Poll::Ready(Err(Error::StBitErr));
}
if status.dataend() {
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
Poll::Pending Poll::Pending
@ -1156,9 +1180,15 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
if status.dcrcfail() { if status.dcrcfail() {
return Poll::Ready(Err(Error::Crc)); return Poll::Ready(Err(Error::Crc));
} else if status.dtimeout() { }
if status.dtimeout() {
return Poll::Ready(Err(Error::Timeout)); return Poll::Ready(Err(Error::Timeout));
} else if status.dataend() { }
#[cfg(sdmmc_v1)]
if status.stbiterr() {
return Poll::Ready(Err(Error::StBitErr));
}
if status.dataend() {
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
Poll::Pending Poll::Pending
@ -1207,9 +1237,15 @@ impl<'d, T: Instance, Dma: SdmmcDma<T> + 'd> Sdmmc<'d, T, Dma> {
if status.dcrcfail() { if status.dcrcfail() {
return Poll::Ready(Err(Error::Crc)); return Poll::Ready(Err(Error::Crc));
} else if status.dtimeout() { }
if status.dtimeout() {
return Poll::Ready(Err(Error::Timeout)); return Poll::Ready(Err(Error::Timeout));
} else if status.dataend() { }
#[cfg(sdmmc_v1)]
if status.stbiterr() {
return Poll::Ready(Err(Error::StBitErr));
}
if status.dataend() {
return Poll::Ready(Ok(())); return Poll::Ready(Ok(()));
} }
Poll::Pending Poll::Pending