summaryrefslogtreecommitdiff
path: root/software/mpu/board-F405
diff options
context:
space:
mode:
authorChristian Pointner <equinox@mur.at>2014-04-09 04:22:00 +0200
committerChristian Pointner <equinox@mur.at>2014-04-09 04:22:00 +0200
commita324fa64bf9c1070d37b2089973e644cecbd240f (patch)
tree0ff08df4dd6f484645a5f8c476de1a1fd7613214 /software/mpu/board-F405
parentadded gitingore (diff)
added SDIO for F405 and blockstore
Diffstat (limited to 'software/mpu/board-F405')
-rw-r--r--software/mpu/board-F405/board.c28
-rw-r--r--software/mpu/board-F405/board.h128
2 files changed, 92 insertions, 64 deletions
diff --git a/software/mpu/board-F405/board.c b/software/mpu/board-F405/board.c
index e66dd1c..0813bb6 100644
--- a/software/mpu/board-F405/board.c
+++ b/software/mpu/board-F405/board.c
@@ -61,3 +61,31 @@ void __early_init(void) {
*/
void boardInit(void) {
}
+
+#if HAL_USE_SDC
+/**
+ * @brief Insertion monitor function.
+ *
+ * @param[in] sdcp pointer to the @p SDCDriver object
+ *
+ * @notapi
+ */
+bool_t sdc_lld_is_card_inserted(SDCDriver *sdcp) {
+
+ (void)sdcp;
+ return !palReadPad(GPIOA, GPIOA_SDIO_CD);
+}
+
+/**
+ * @brief Protection detection.
+ *
+ * @param[in] sdcp pointer to the @p SDCDriver object
+ *
+ * @notapi
+ */
+bool_t sdc_lld_is_write_protected(SDCDriver *sdcp) {
+
+ (void)sdcp;
+ return !palReadPad(GPIOA, GPIOA_SDIO_WP);
+}
+#endif /* HAL_USE_SDC */
diff --git a/software/mpu/board-F405/board.h b/software/mpu/board-F405/board.h
index 9f2017c..f056102 100644
--- a/software/mpu/board-F405/board.h
+++ b/software/mpu/board-F405/board.h
@@ -67,8 +67,8 @@
#define GPIOA_USB_DM 11
#define GPIOA_USB_DP 12
#define GPIOA_USB_DISC 13
-#define GPIOA_PIN14 14
-#define GPIOA_PIN15 15
+#define GPIOA_SDIO_WP 14
+#define GPIOA_SDIO_CD 15
#define GPIOB_PIN0 0
#define GPIOB_PIN1 1
@@ -95,18 +95,18 @@
#define GPIOC_PIN5 5
#define GPIOC_PIN6 6
#define GPIOC_PIN7 7
-#define GPIOC_PIN8 8
-#define GPIOC_PIN9 9
-#define GPIOC_PIN10 10
-#define GPIOC_PIN11 11
-#define GPIOC_PIN12 12
+#define GPIOC_SDIO_D0 8
+#define GPIOC_SDIO_D1 9
+#define GPIOC_SDIO_D2 10
+#define GPIOC_SDIO_D3 11
+#define GPIOC_SDIO_CK 12
#define GPIOC_PIN13 13
#define GPIOC_PIN14 14
#define GPIOC_PIN15 15
#define GPIOD_PIN0 0
#define GPIOD_PIN1 1
-#define GPIOD_PIN2 2
+#define GPIOD_SDIO_CMD 2
#define GPIOD_PIN3 3
#define GPIOD_PIN4 4
#define GPIOD_PIN5 5
@@ -245,8 +245,8 @@
* PA11 - USB_DM (alternate 10).
* PA12 - USB_DP (alternate 10).
* PA13 - USB_DISC (output pushpull maximum).
- * PA14 - PIN14 (input pullup).
- * PA15 - PIN15 (input pullup).
+ * PA14 - SDIO_WP (input pullup).
+ * PA15 - SDIO_CD (input pullup).
*/
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(GPIOA_PIN0) | \
PIN_MODE_INPUT(GPIOA_PIN1) | \
@@ -262,8 +262,8 @@
PIN_MODE_ALTERNATE(GPIOA_USB_DM) | \
PIN_MODE_ALTERNATE(GPIOA_USB_DP) | \
PIN_MODE_OUTPUT(GPIOA_USB_DISC) | \
- PIN_MODE_INPUT(GPIOA_PIN14) | \
- PIN_MODE_INPUT(GPIOA_PIN15))
+ PIN_MODE_INPUT(GPIOA_SDIO_WP) | \
+ PIN_MODE_INPUT(GPIOA_SDIO_CD))
#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(GPIOA_PIN0) | \
PIN_OTYPE_PUSHPULL(GPIOA_PIN1) | \
PIN_OTYPE_PUSHPULL(GPIOA_PIN2) | \
@@ -278,8 +278,8 @@
PIN_OTYPE_PUSHPULL(GPIOA_USB_DM) | \
PIN_OTYPE_PUSHPULL(GPIOA_USB_DP) | \
PIN_OTYPE_PUSHPULL(GPIOA_USB_DISC) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN14) | \
- PIN_OTYPE_PUSHPULL(GPIOA_PIN15))
+ PIN_OTYPE_PUSHPULL(GPIOA_SDIO_WP) | \
+ PIN_OTYPE_PUSHPULL(GPIOA_SDIO_CD))
#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_100M(GPIOA_PIN0) | \
PIN_OSPEED_100M(GPIOA_PIN1) | \
PIN_OSPEED_100M(GPIOA_PIN2) | \
@@ -294,8 +294,8 @@
PIN_OSPEED_100M(GPIOA_USB_DM) | \
PIN_OSPEED_100M(GPIOA_USB_DP) | \
PIN_OSPEED_100M(GPIOA_USB_DISC) | \
- PIN_OSPEED_100M(GPIOA_PIN14) | \
- PIN_OSPEED_100M(GPIOA_PIN15))
+ PIN_OSPEED_100M(GPIOA_SDIO_WP) | \
+ PIN_OSPEED_100M(GPIOA_SDIO_CD))
#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLUP(GPIOA_PIN0) | \
PIN_PUPDR_PULLUP(GPIOA_PIN1) | \
PIN_PUPDR_PULLUP(GPIOA_PIN2) | \
@@ -309,8 +309,8 @@
PIN_PUPDR_FLOATING(GPIOA_USB_DM) | \
PIN_PUPDR_FLOATING(GPIOA_USB_DP) | \
PIN_PUPDR_FLOATING(GPIOA_USB_DISC) | \
- PIN_PUPDR_PULLDOWN(GPIOA_PIN14) | \
- PIN_PUPDR_FLOATING(GPIOA_PIN15))
+ PIN_PUPDR_PULLUP(GPIOA_SDIO_WP) | \
+ PIN_PUPDR_PULLUP(GPIOA_SDIO_CD))
#define VAL_GPIOA_ODR (PIN_ODR_HIGH(GPIOA_PIN0) | \
PIN_ODR_HIGH(GPIOA_PIN1) | \
PIN_ODR_HIGH(GPIOA_PIN2) | \
@@ -325,8 +325,8 @@
PIN_ODR_HIGH(GPIOA_USB_DM) | \
PIN_ODR_HIGH(GPIOA_USB_DP) | \
PIN_ODR_HIGH(GPIOA_USB_DISC) | \
- PIN_ODR_HIGH(GPIOA_PIN14) | \
- PIN_ODR_HIGH(GPIOA_PIN15))
+ PIN_ODR_HIGH(GPIOA_SDIO_WP) | \
+ PIN_ODR_HIGH(GPIOA_SDIO_CD))
#define VAL_GPIOA_AFRL (PIN_AFIO_AF(GPIOA_PIN0, 0) | \
PIN_AFIO_AF(GPIOA_PIN1, 0) | \
PIN_AFIO_AF(GPIOA_PIN2, 7) | \
@@ -341,8 +341,8 @@
PIN_AFIO_AF(GPIOA_USB_DM, 10) | \
PIN_AFIO_AF(GPIOA_USB_DP, 10) | \
PIN_AFIO_AF(GPIOA_USB_DISC, 0) | \
- PIN_AFIO_AF(GPIOA_PIN14, 0) | \
- PIN_AFIO_AF(GPIOA_PIN15, 0))
+ PIN_AFIO_AF(GPIOA_SDIO_WP, 0) | \
+ PIN_AFIO_AF(GPIOA_SDIO_CD, 0))
/*
* GPIOB setup:
@@ -473,11 +473,11 @@
* PC5 - PIN5 (input pullup).
* PC6 - PIN6 (input pullup).
* PC7 - PIN7 (input pullup).
- * PC8 - PIN8 (input pullup).
- * PC9 - PIN9 (input pullup).
- * PC10 - PIN10 (input pullup).
- * PC11 - PIN11 (input pullup).
- * PC12 - PIN12 (input pullup).
+ * PC8 - SDIO_D0 (alternate function 12).
+ * PC9 - SDIO_D1 (alternate function 12).
+ * PC10 - SDIO_D2 (alternate function 12).
+ * PC11 - SDIO_D3 (alternate function 12).
+ * PC12 - SDIO_CK (alternate function 12).
* PC13 - PIN13 (input pullup).
* PC14 - PIN14 (input pullup).
* PC15 - PIN15 (input pullup).
@@ -490,11 +490,11 @@
PIN_MODE_INPUT(GPIOC_PIN5) | \
PIN_MODE_INPUT(GPIOC_PIN6) | \
PIN_MODE_INPUT(GPIOC_PIN7) | \
- PIN_MODE_INPUT(GPIOC_PIN8) | \
- PIN_MODE_INPUT(GPIOC_PIN9) | \
- PIN_MODE_INPUT(GPIOC_PIN10) | \
- PIN_MODE_INPUT(GPIOC_PIN11) | \
- PIN_MODE_INPUT(GPIOC_PIN12) | \
+ PIN_MODE_ALTERNATE(GPIOC_SDIO_D0) | \
+ PIN_MODE_ALTERNATE(GPIOC_SDIO_D1) | \
+ PIN_MODE_ALTERNATE(GPIOC_SDIO_D2) | \
+ PIN_MODE_ALTERNATE(GPIOC_SDIO_D3) | \
+ PIN_MODE_ALTERNATE(GPIOC_SDIO_CK) | \
PIN_MODE_INPUT(GPIOC_PIN13) | \
PIN_MODE_INPUT(GPIOC_PIN14) | \
PIN_MODE_INPUT(GPIOC_PIN15))
@@ -506,11 +506,11 @@
PIN_OTYPE_PUSHPULL(GPIOC_PIN5) | \
PIN_OTYPE_PUSHPULL(GPIOC_PIN6) | \
PIN_OTYPE_PUSHPULL(GPIOC_PIN7) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN8) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN9) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN10) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN11) | \
- PIN_OTYPE_PUSHPULL(GPIOC_PIN12) | \
+ PIN_OTYPE_PUSHPULL(GPIOC_SDIO_D0) | \
+ PIN_OTYPE_PUSHPULL(GPIOC_SDIO_D1) | \
+ PIN_OTYPE_PUSHPULL(GPIOC_SDIO_D2) | \
+ PIN_OTYPE_PUSHPULL(GPIOC_SDIO_D3) | \
+ PIN_OTYPE_PUSHPULL(GPIOC_SDIO_CK) | \
PIN_OTYPE_PUSHPULL(GPIOC_PIN13) | \
PIN_OTYPE_PUSHPULL(GPIOC_PIN14) | \
PIN_OTYPE_PUSHPULL(GPIOC_PIN15))
@@ -522,11 +522,11 @@
PIN_OSPEED_100M(GPIOC_PIN5) | \
PIN_OSPEED_100M(GPIOC_PIN6) | \
PIN_OSPEED_100M(GPIOC_PIN7) | \
- PIN_OSPEED_100M(GPIOC_PIN8) | \
- PIN_OSPEED_100M(GPIOC_PIN9) | \
- PIN_OSPEED_100M(GPIOC_PIN10) | \
- PIN_OSPEED_100M(GPIOC_PIN11) | \
- PIN_OSPEED_100M(GPIOC_PIN12) | \
+ PIN_OSPEED_100M(GPIOC_SDIO_D0) | \
+ PIN_OSPEED_100M(GPIOC_SDIO_D1) | \
+ PIN_OSPEED_100M(GPIOC_SDIO_D2) | \
+ PIN_OSPEED_100M(GPIOC_SDIO_D3) | \
+ PIN_OSPEED_100M(GPIOC_SDIO_CK) | \
PIN_OSPEED_100M(GPIOC_PIN13) | \
PIN_OSPEED_100M(GPIOC_PIN14) | \
PIN_OSPEED_100M(GPIOC_PIN15))
@@ -538,11 +538,11 @@
PIN_PUPDR_PULLUP(GPIOC_PIN5) | \
PIN_PUPDR_PULLUP(GPIOC_PIN6) | \
PIN_PUPDR_PULLUP(GPIOC_PIN7) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN8) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN9) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN10) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN11) | \
- PIN_PUPDR_PULLUP(GPIOC_PIN12) | \
+ PIN_PUPDR_PULLUP(GPIOC_SDIO_D0) | \
+ PIN_PUPDR_PULLUP(GPIOC_SDIO_D1) | \
+ PIN_PUPDR_PULLUP(GPIOC_SDIO_D2) | \
+ PIN_PUPDR_PULLUP(GPIOC_SDIO_D3) | \
+ PIN_PUPDR_PULLUP(GPIOC_SDIO_CK) | \
PIN_PUPDR_PULLUP(GPIOC_PIN13) | \
PIN_PUPDR_PULLUP(GPIOC_PIN14) | \
PIN_PUPDR_PULLUP(GPIOC_PIN15))
@@ -554,11 +554,11 @@
PIN_ODR_HIGH(GPIOC_PIN5) | \
PIN_ODR_HIGH(GPIOC_PIN6) | \
PIN_ODR_HIGH(GPIOC_PIN7) | \
- PIN_ODR_HIGH(GPIOC_PIN8) | \
- PIN_ODR_HIGH(GPIOC_PIN9) | \
- PIN_ODR_HIGH(GPIOC_PIN10) | \
- PIN_ODR_HIGH(GPIOC_PIN11) | \
- PIN_ODR_HIGH(GPIOC_PIN12) | \
+ PIN_ODR_HIGH(GPIOC_SDIO_D0) | \
+ PIN_ODR_HIGH(GPIOC_SDIO_D1) | \
+ PIN_ODR_HIGH(GPIOC_SDIO_D2) | \
+ PIN_ODR_HIGH(GPIOC_SDIO_D3) | \
+ PIN_ODR_HIGH(GPIOC_SDIO_CK) | \
PIN_ODR_HIGH(GPIOC_PIN13) | \
PIN_ODR_HIGH(GPIOC_PIN14) | \
PIN_ODR_HIGH(GPIOC_PIN15))
@@ -570,11 +570,11 @@
PIN_AFIO_AF(GPIOC_PIN5, 0) | \
PIN_AFIO_AF(GPIOC_PIN6, 0) | \
PIN_AFIO_AF(GPIOC_PIN7, 0))
-#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_PIN8, 0) | \
- PIN_AFIO_AF(GPIOC_PIN9, 0) | \
- PIN_AFIO_AF(GPIOC_PIN10, 0) | \
- PIN_AFIO_AF(GPIOC_PIN11, 0) | \
- PIN_AFIO_AF(GPIOC_PIN12, 0) | \
+#define VAL_GPIOC_AFRH (PIN_AFIO_AF(GPIOC_SDIO_D0, 12) | \
+ PIN_AFIO_AF(GPIOC_SDIO_D1, 12) | \
+ PIN_AFIO_AF(GPIOC_SDIO_D2, 12) | \
+ PIN_AFIO_AF(GPIOC_SDIO_D3, 12) | \
+ PIN_AFIO_AF(GPIOC_SDIO_CK, 12) | \
PIN_AFIO_AF(GPIOC_PIN13, 0) | \
PIN_AFIO_AF(GPIOC_PIN14, 0) | \
PIN_AFIO_AF(GPIOC_PIN15, 0))
@@ -585,7 +585,7 @@
*
* PD0 - PIN0 (input pullup).
* PD1 - PIN1 (input pullup).
- * PD2 - PIN2 (input pullup).
+ * PD2 - SDIO_CMD (alternate function 12).
* PD3 - PIN3 (input pullup).
* PD4 - PIN4 (input pullup).
* PD5 - PIN5 (input pullup).
@@ -602,7 +602,7 @@
*/
#define VAL_GPIOD_MODER (PIN_MODE_INPUT(GPIOD_PIN0) | \
PIN_MODE_INPUT(GPIOD_PIN1) | \
- PIN_MODE_INPUT(GPIOD_PIN2) | \
+ PIN_MODE_ALTERNATE(GPIOD_SDIO_CMD) | \
PIN_MODE_INPUT(GPIOD_PIN3) | \
PIN_MODE_INPUT(GPIOD_PIN4) | \
PIN_MODE_INPUT(GPIOD_PIN5) | \
@@ -618,7 +618,7 @@
PIN_MODE_INPUT(GPIOD_PIN15))
#define VAL_GPIOD_OTYPER (PIN_OTYPE_PUSHPULL(GPIOD_PIN0) | \
PIN_OTYPE_PUSHPULL(GPIOD_PIN1) | \
- PIN_OTYPE_PUSHPULL(GPIOD_PIN2) | \
+ PIN_OTYPE_PUSHPULL(GPIOD_SDIO_CMD) | \
PIN_OTYPE_PUSHPULL(GPIOD_PIN3) | \
PIN_OTYPE_PUSHPULL(GPIOD_PIN4) | \
PIN_OTYPE_PUSHPULL(GPIOD_PIN5) | \
@@ -634,7 +634,7 @@
PIN_OTYPE_PUSHPULL(GPIOD_PIN15))
#define VAL_GPIOD_OSPEEDR (PIN_OSPEED_100M(GPIOD_PIN0) | \
PIN_OSPEED_100M(GPIOD_PIN1) | \
- PIN_OSPEED_100M(GPIOD_PIN2) | \
+ PIN_OSPEED_100M(GPIOD_SDIO_CMD) | \
PIN_OSPEED_100M(GPIOD_PIN3) | \
PIN_OSPEED_100M(GPIOD_PIN4) | \
PIN_OSPEED_100M(GPIOD_PIN5) | \
@@ -650,7 +650,7 @@
PIN_OSPEED_100M(GPIOD_PIN15))
#define VAL_GPIOD_PUPDR (PIN_PUPDR_PULLUP(GPIOD_PIN0) | \
PIN_PUPDR_PULLUP(GPIOD_PIN1) | \
- PIN_PUPDR_PULLUP(GPIOD_PIN2) | \
+ PIN_PUPDR_PULLUP(GPIOD_SDIO_CMD) | \
PIN_PUPDR_PULLUP(GPIOD_PIN3) | \
PIN_PUPDR_PULLUP(GPIOD_PIN4) | \
PIN_PUPDR_PULLUP(GPIOD_PIN5) | \
@@ -666,7 +666,7 @@
PIN_PUPDR_PULLUP(GPIOD_PIN15))
#define VAL_GPIOD_ODR (PIN_ODR_HIGH(GPIOD_PIN0) | \
PIN_ODR_HIGH(GPIOD_PIN1) | \
- PIN_ODR_HIGH(GPIOD_PIN2) | \
+ PIN_ODR_HIGH(GPIOD_SDIO_CMD) | \
PIN_ODR_HIGH(GPIOD_PIN3) | \
PIN_ODR_HIGH(GPIOD_PIN4) | \
PIN_ODR_HIGH(GPIOD_PIN5) | \
@@ -682,7 +682,7 @@
PIN_ODR_HIGH(GPIOD_PIN15))
#define VAL_GPIOD_AFRL (PIN_AFIO_AF(GPIOD_PIN0, 0) | \
PIN_AFIO_AF(GPIOD_PIN1, 0) | \
- PIN_AFIO_AF(GPIOD_PIN2, 0) | \
+ PIN_AFIO_AF(GPIOD_SDIO_CMD, 12) | \
PIN_AFIO_AF(GPIOD_PIN3, 0) | \
PIN_AFIO_AF(GPIOD_PIN4, 0) | \
PIN_AFIO_AF(GPIOD_PIN5, 0) | \