liblitesdcard/[spi]sdcard: avoid redundant (re-)initialization

This commit is contained in:
Gabriel Somlo 2020-06-17 17:21:33 -04:00
parent aa0cd21378
commit 9ad45a6932
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;
} }