rust-embedded-community / embedded-sdmmc-rs

A SD/MMC library with FAT16/FAT32 support, suitable for Embedded Rust systems
Apache License 2.0
306 stars 72 forks source link

Delay and busy-waiting #81

Closed elpiel closed 1 year ago

elpiel commented 1 year ago

I was looking to improve the Delay struct used for busy-waiting when waiting for the card to do some work.

I wanted to discuss:

  1. How we can improve the current Delay which acts more like a Retry counter than a delay.
  2. Rely on embedded-hal crates for the delay waiting instead of reading from volatile:
    • support the embedded-hal (0.2) timer::CountDown
    • support the embedded-hal (1.0.0-alpha.10) delay::DelayUs
    • support the embedded-hal-async delay::DelayUs

This issue is also part of my efforts to improve speed, reliability and introduce async interface in this upstream repo.

Also related to #80

thejpster commented 1 year ago

I added a change which uses the blocking DelayUs trait.

Really we just need something that slows down the retries so the card isn't battered while calculating its response, and ideally something independent if transfer clock speed.