summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBenjamin Weps <benjamin.weps@posteo.de>2017-06-15 12:48:21 +0200
committerDamien George <damien.p.george@gmail.com>2017-06-27 12:42:46 +1000
commit3e82bedf46c29ce33baa34cfeb535bf1a04e12f6 (patch)
treecf74aec2e30c6b4c38536ed8b1f512534def8b9b
parentfbd252b77cb7eb5b525e757ac7dd20051fd6b673 (diff)
downloadmicropython-3e82bedf46c29ce33baa34cfeb535bf1a04e12f6.tar.gz
micropython-3e82bedf46c29ce33baa34cfeb535bf1a04e12f6.zip
stmhal/sdcard: Allow a board to customise the SDIO pins.
-rw-r--r--stmhal/sdcard.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/stmhal/sdcard.c b/stmhal/sdcard.c
index 5a4b3b0e47..c7ddbbde3a 100644
--- a/stmhal/sdcard.c
+++ b/stmhal/sdcard.c
@@ -96,6 +96,18 @@
#endif
+// If no custom SDIO pins defined, use the default ones
+#ifndef MICROPY_HW_SDMMC_CK
+
+#define MICROPY_HW_SDMMC_D0 (pin_C8)
+#define MICROPY_HW_SDMMC_D1 (pin_C9)
+#define MICROPY_HW_SDMMC_D2 (pin_C10)
+#define MICROPY_HW_SDMMC_D3 (pin_C11)
+#define MICROPY_HW_SDMMC_CK (pin_C12)
+#define MICROPY_HW_SDMMC_CMD (pin_D2)
+
+#endif
+
// TODO: Since SDIO is fundamentally half-duplex, we really only need to
// tie up one DMA channel. However, the HAL DMA API doesn't
// seem to provide a convenient way to change the direction. I believe that
@@ -128,12 +140,12 @@ void sdcard_init(void) {
mp_hal_pin_config_alt(&MICROPY_HW_SDMMC2_D3, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, AF_FN_SDMMC, 2);
#else
// Default SDIO/SDMMC1 config
- mp_hal_pin_config(&pin_C8, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
- mp_hal_pin_config(&pin_C9, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
- mp_hal_pin_config(&pin_C10, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
- mp_hal_pin_config(&pin_C11, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
- mp_hal_pin_config(&pin_C12, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
- mp_hal_pin_config(&pin_D2, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_D0, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_D1, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_D2, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_D3, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_CK, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
+ mp_hal_pin_config(&MICROPY_HW_SDMMC_CMD, MP_HAL_PIN_MODE_ALT, MP_HAL_PIN_PULL_UP, GPIO_AF12_SDIO);
#endif
// configure the SD card detect pin