aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Lazarev <[email protected]>2025-03-31 11:43:35 -0700
committerAnton Lazarev <[email protected]>2025-03-31 12:47:41 -0700
commit14bb4ee9e414137f318f64e82d808d4012e30680 (patch)
tree3fa4178644684b10c5cd9245dcbc415ebc7ccd90
parent5d01712d840af0b48c4d85a1f9347a157991f88e (diff)
use ready_for_data status to determine when write has finished
`read_sd_status` works, but it's somewhat of a hack, but also won't work on eMMC devices. The official spec for both SD and eMMC recommends using this method.
-rw-r--r--embassy-stm32/src/sdmmc/mod.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/embassy-stm32/src/sdmmc/mod.rs b/embassy-stm32/src/sdmmc/mod.rs
index 2229347f4..a28fd51e8 100644
--- a/embassy-stm32/src/sdmmc/mod.rs
+++ b/embassy-stm32/src/sdmmc/mod.rs
@@ -1292,12 +1292,12 @@ impl<'d, T: Instance> Sdmmc<'d, T> {
1292 // TODO: Make this configurable 1292 // TODO: Make this configurable
1293 let mut timeout: u32 = 0x00FF_FFFF; 1293 let mut timeout: u32 = 0x00FF_FFFF;
1294 1294
1295 // Try to read card status (ACMD13) 1295 let card = self.card.as_ref().unwrap();
1296 while timeout > 0 { 1296 while timeout > 0 {
1297 match self.read_sd_status().await { 1297 let status = self.read_status(card)?;
1298 Ok(_) => return Ok(()), 1298
1299 Err(Error::Timeout) => (), // Try again 1299 if status.ready_for_data() {
1300 Err(e) => return Err(e), 1300 return Ok(());
1301 } 1301 }
1302 timeout -= 1; 1302 timeout -= 1;
1303 } 1303 }