Merge pull request #570 from gsomlo/gls-sdcard-lazy-init

liblitesdcard/[spi]sdcard: avoid redundant (re-)initialization
This commit is contained in:
enjoy-digital 2020-06-18 08:42:44 +02:00 committed by GitHub
commit 4cab38fa5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -728,6 +728,7 @@ DSTATUS disk_status(uint8_t drv) {
DSTATUS disk_initialize(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) {
if (drv) return STA_NOINIT; if (drv) return STA_NOINIT;
if (sdcardstatus)
sdcardstatus = sdcard_init() ? 0 : STA_NOINIT; sdcardstatus = sdcard_init() ? 0 : STA_NOINIT;
return sdcardstatus; return sdcardstatus;
} }

View File

@ -277,8 +277,10 @@ DSTATUS disk_status(uint8_t drv) {
DSTATUS disk_initialize(uint8_t drv) { DSTATUS disk_initialize(uint8_t drv) {
if (drv) return STA_NOINIT; if (drv) return STA_NOINIT;
if (spisdcardstatus) {
spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT; spisdcardstatus = spisdcard_init() ? 0 : STA_NOINIT;
spisdcard_deselect(); spisdcard_deselect();
}
return spisdcardstatus; return spisdcardstatus;
} }