|
69 | 69 | #define SD_CLK_DIV SDMMC_NSpeed_CLK_DIV
|
70 | 70 | #endif
|
71 | 71 |
|
72 |
| - #ifdef SDMMC_TRANSCEIVER_ENABLE |
73 |
| - #define SD_TRANSCEIVER_ENABLE SDMMC_TRANSCEIVER_ENABLE |
74 |
| - #define SD_TRANSCEIVER_DISABLE SDMMC_TRANSCEIVER_DISABLE |
| 72 | + #if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U) |
| 73 | + #if defined(SDMMC_TRANSCEIVER_ENABLE) |
| 74 | + #define SD_TRANSCEIVER_ENABLE SDMMC_TRANSCEIVER_ENABLE |
| 75 | + #define SD_TRANSCEIVER_DISABLE SDMMC_TRANSCEIVER_DISABLE |
| 76 | + #else |
| 77 | + #define SD_TRANSCEIVER_ENABLE SDMMC_TRANSCEIVER_PRESENT |
| 78 | + #define SD_TRANSCEIVER_DISABLE SDMMC_TRANSCEIVER_NOT_PRESENT |
| 79 | + #endif |
75 | 80 | #endif
|
76 | 81 |
|
77 | 82 | #elif defined(SDIO)
|
|
101 | 106 | #define SD_BUS_WIDE SD_BUS_WIDE_4B
|
102 | 107 | #endif
|
103 | 108 |
|
104 |
| -#if defined(SDMMC_TRANSCEIVER_ENABLE) && !defined(SD_TRANSCEIVER_MODE) |
105 |
| - #define SD_TRANSCEIVER_MODE SD_TRANSCEIVER_DISABLE |
106 |
| -#endif |
107 |
| - |
108 | 109 | /* BSP SD Private Variables */
|
109 | 110 | static SD_HandleTypeDef uSdHandle;
|
110 | 111 | static uint32_t SD_detect_ll_gpio_pin = LL_GPIO_PIN_ALL;
|
111 | 112 | static GPIO_TypeDef *SD_detect_gpio_port = GPIOA;
|
112 |
| -#ifdef SDMMC_TRANSCEIVER_ENABLE |
| 113 | +#if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U) |
113 | 114 | static uint32_t SD_trans_en_ll_gpio_pin = LL_GPIO_PIN_ALL;
|
114 | 115 | static GPIO_TypeDef *SD_trans_en_gpio_port = GPIOA;
|
115 | 116 | static uint32_t SD_trans_sel_ll_gpio_pin = LL_GPIO_PIN_ALL;
|
@@ -143,12 +144,13 @@ uint8_t BSP_SD_Init(void)
|
143 | 144 | uSdHandle.Init.BusWide = SD_BUS_WIDE_1B;
|
144 | 145 | uSdHandle.Init.HardwareFlowControl = SD_HW_FLOW_CTRL;
|
145 | 146 | uSdHandle.Init.ClockDiv = SD_CLK_DIV;
|
146 |
| -#ifdef SDMMC_TRANSCEIVER_ENABLE |
147 |
| - uSdHandle.Init.Transceiver = SD_TRANSCEIVER_MODE; |
148 |
| - if (SD_TRANSCEIVER_MODE == SD_TRANSCEIVER_ENABLE) { |
149 |
| - |
150 |
| - BSP_SD_Transceiver_MspInit(&uSdHandle, NULL); |
151 |
| - } |
| 147 | +#if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U) |
| 148 | +#if defined(SDMMC_TRANSCEIVER_ENABLE) |
| 149 | + uSdHandle.Init.Transceiver = SD_TRANSCEIVER_ENABLE; |
| 150 | +#else |
| 151 | + uSdHandle.Init.TranceiverPresent = SD_TRANSCEIVER_ENABLE; |
| 152 | +#endif |
| 153 | + BSP_SD_Transceiver_MspInit(&uSdHandle, NULL); |
152 | 154 | #endif
|
153 | 155 |
|
154 | 156 | if (SD_detect_ll_gpio_pin != LL_GPIO_PIN_ALL) {
|
@@ -205,11 +207,13 @@ uint8_t BSP_SD_DeInit(void)
|
205 | 207 | return sd_state;
|
206 | 208 | }
|
207 | 209 |
|
208 |
| -#ifdef SDMMC_TRANSCEIVER_ENABLE |
| 210 | +#if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U) |
209 | 211 | /**
|
210 |
| - * @brief Set the SD card device detect pin and port. |
211 |
| - * @param port one of the gpio port |
212 |
| - * @param pin one of the gpio pin |
| 212 | + * @brief Set the transceiver pin and port. |
| 213 | + * @param enport enable gpio port |
| 214 | + * @param enpin enable gpio pin |
| 215 | + * @param selport select gpio port |
| 216 | + * @param selpin select gpio pin |
213 | 217 | * @retval SD status
|
214 | 218 | */
|
215 | 219 | uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef *selport, uint32_t selpin)
|
@@ -483,7 +487,7 @@ __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
|
483 | 487 | #endif
|
484 | 488 | }
|
485 | 489 |
|
486 |
| -#ifdef SDMMC_TRANSCEIVER_ENABLE |
| 490 | +#if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U) |
487 | 491 | /**
|
488 | 492 | * @brief Initializes the SD Transceiver pin MSP.
|
489 | 493 | * @param hsd: SD handle
|
@@ -514,15 +518,19 @@ __weak void BSP_SD_Transceiver_MspInit(SD_HandleTypeDef *hsd, void *Params)
|
514 | 518 | * @param status: Voltage Switch State
|
515 | 519 | * @retval None
|
516 | 520 | */
|
517 |
| -void HAL_SDEx_DriveTransceiver_1_8V_Callback(FlagStatus status) |
| 521 | +#if defined(SDMMC_TRANSCEIVER_ENABLE) |
| 522 | + void HAL_SDEx_DriveTransceiver_1_8V_Callback(FlagStatus status) |
| 523 | +#else |
| 524 | + void HAL_SD_DriveTransceiver_1_8V_Callback(FlagStatus status) |
| 525 | +#endif |
518 | 526 | {
|
519 | 527 | if (status == SET) {
|
520 | 528 | LL_GPIO_SetOutputPin(SD_trans_sel_gpio_port, SD_trans_sel_ll_gpio_pin);
|
521 | 529 | } else {
|
522 | 530 | LL_GPIO_ResetOutputPin(SD_trans_sel_gpio_port, SD_trans_sel_ll_gpio_pin);
|
523 | 531 | }
|
524 | 532 | }
|
525 |
| -#endif /* SDMMC_TRANSCEIVER_ENABLE */ |
| 533 | +#endif /* USE_SD_TRANSCEIVER && (USE_SD_TRANSCEIVER != 0U) */ |
526 | 534 |
|
527 | 535 | #ifndef STM32L1xx
|
528 | 536 | /**
|
|
0 commit comments