Skip to content

Commit 196bf95

Browse files
authored
Merge pull request #76 from LechevSpace/skip-wait-init-sequence
2 parents 01da43c + 60f637e commit 196bf95

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/controller.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,8 @@ where
397397
_ => {
398398
// Safe to unwrap, since we actually have an entry if we got here
399399
let dir_entry = dir_entry.unwrap();
400+
// FIXME: if 2 files are in the same cluster this will cause an error when opening
401+
// a file for a first time in a different than `ReadWriteCreate` mode.
400402
self.open_dir_entry(volume, dir_entry, mode)
401403
}
402404
}

src/sdmmc.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ where
193193
Err(Error::TimeoutCommand(0)) => {
194194
// Try again?
195195
warn!("Timed out, trying again..");
196+
// Try flushing the card as done here: https://github.com/greiman/SdFat/blob/master/src/SdCard/SdSpiCard.cpp#L170,
197+
// https://github.com/rust-embedded-community/embedded-sdmmc-rs/pull/65#issuecomment-1270709448
198+
for _ in 0..0xFF {
199+
s.send(0xFF)?;
200+
}
196201
attempts -= 1;
197202
}
198203
Err(e) => {
@@ -299,7 +304,10 @@ where
299304

300305
/// Perform a command.
301306
fn card_command(&self, command: u8, arg: u32) -> Result<u8, Error> {
302-
self.wait_not_busy()?;
307+
if command != CMD0 && command != CMD12 {
308+
self.wait_not_busy()?;
309+
}
310+
303311
let mut buf = [
304312
0x40 | command,
305313
(arg >> 24) as u8,

0 commit comments

Comments
 (0)