aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Belykh2019-10-04 23:27:14 -0400
committerDamien George2019-10-10 17:29:44 +1100
commit305f537bf940fbbe3474cd1e0938586426d25b48 (patch)
treeebbeeae4aee9ae34cf7fd96b80f7110e4a5f9d3e
parent3117fde407064cd6e51c4f4bdd35ac9ca3cca20f (diff)
stm32/sdcard: Support boards with no SD card detect pin.
If MICROPY_HW_SDCARD_DETECT_PIN is not defined then the SD card will always be detected as present.
-rw-r--r--ports/stm32/sdcard.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/ports/stm32/sdcard.c b/ports/stm32/sdcard.c
index f54d67ea4..44b1c807d 100644
--- a/ports/stm32/sdcard.c
+++ b/ports/stm32/sdcard.c
@@ -175,7 +175,9 @@ void sdcard_init(void) {
// configure the SD card detect pin
// we do this here so we can detect if the SD card is inserted before powering it on
+ #if defined(MICROPY_HW_SDCARD_DETECT_PIN)
mp_hal_pin_config(MICROPY_HW_SDCARD_DETECT_PIN, MP_HAL_PIN_MODE_INPUT, MICROPY_HW_SDCARD_DETECT_PULL, 0);
+ #endif
}
STATIC void sdmmc_msp_init(void) {
@@ -231,7 +233,11 @@ bool sdcard_is_present(void) {
return false;
}
#endif
+ #if defined(MICROPY_HW_SDCARD_DETECT_PIN)
return HAL_GPIO_ReadPin(MICROPY_HW_SDCARD_DETECT_PIN->gpio, MICROPY_HW_SDCARD_DETECT_PIN->pin_mask) == MICROPY_HW_SDCARD_DETECT_PRESENT;
+ #else
+ return true;
+ #endif
}
#if MICROPY_HW_ENABLE_SDCARD