Skip to content

Commit 778ed6c

Browse files
authored
Merge pull request #89 from jbeaurivage/select-num-acq-retries
2 parents 33642eb + d80f39d commit 778ed6c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/sdcard/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ where
401401
// Assert CS
402402
s.cs_low()?;
403403
// Enter SPI mode.
404-
let mut delay = Delay::new_command();
404+
let mut delay = Delay::new(s.options.acquire_retries);
405405
for attempts in 1.. {
406406
trace!("Enter SPI mode, attempt: {}..", attempts);
407407
match s.card_command(CMD0, 0) {
@@ -586,11 +586,18 @@ pub struct AcquireOpts {
586586
/// On by default because without it you might get silent data corruption on
587587
/// your card.
588588
pub use_crc: bool,
589+
590+
/// Sets the number of times we will retry to acquire the card before giving up and returning
591+
/// `Err(Error::CardNotFound)`. By default, card acquisition will be retried 50 times.
592+
pub acquire_retries: u32,
589593
}
590594

591595
impl Default for AcquireOpts {
592596
fn default() -> Self {
593-
AcquireOpts { use_crc: true }
597+
AcquireOpts {
598+
use_crc: true,
599+
acquire_retries: 50,
600+
}
594601
}
595602
}
596603

0 commit comments

Comments
 (0)