summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDave Hylands <dhylands@gmail.com>2014-08-25 10:16:52 -0700
committerDave Hylands <dhylands@gmail.com>2014-08-25 10:16:52 -0700
commit994bb4a839657c96d71a73a9fce7beac13086dd1 (patch)
tree668cf6dc1614e62e1f54733a5f8386ce82ea6ad3
parente5cbb70328239e58c820938eccd51f3c735fc312 (diff)
downloadmicropython-994bb4a839657c96d71a73a9fce7beac13086dd1.tar.gz
micropython-994bb4a839657c96d71a73a9fce7beac13086dd1.zip
Fix sdcard_power_on to not do anything if the card is already powered on.
-rw-r--r--stmhal/sdcard.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 2993773fab..22882ddb60 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -90,6 +90,9 @@ bool sdcard_power_on(void) {
if (!sdcard_is_present()) {
return false;
}
+ if (sd_handle.Instance) {
+ return true;
+ }
// SD device interface configuration
sd_handle.Instance = SDIO;
@@ -120,7 +123,10 @@ error:
}
void sdcard_power_off(void) {
- HAL_SD_DeInit(&sd_handle);
+ if (!sd_handle.Instance) {
+ return;
+ }
+ HAL_SD_DeInit(&sd_handle);
sd_handle.Instance = NULL;
}