|
108 | 108 | static SD_HandleTypeDef uSdHandle;
|
109 | 109 | static uint32_t SD_detect_ll_gpio_pin = LL_GPIO_PIN_ALL;
|
110 | 110 | static GPIO_TypeDef *SD_detect_gpio_port = GPIOA;
|
| 111 | +static uint32_t SD_detect_level = SD_DETECT_LEVEL; |
111 | 112 | #if defined(USE_SD_TRANSCEIVER) && (USE_SD_TRANSCEIVER != 0U)
|
112 | 113 | static uint32_t SD_trans_en_ll_gpio_pin = LL_GPIO_PIN_ALL;
|
113 | 114 | static GPIO_TypeDef *SD_trans_en_gpio_port = GPIOA;
|
@@ -379,16 +380,18 @@ uint8_t BSP_SD_TransceiverPin(GPIO_TypeDef *enport, uint32_t enpin, GPIO_TypeDef
|
379 | 380 | #endif
|
380 | 381 |
|
381 | 382 | /**
|
382 |
| - * @brief Set the SD card device detect pin and port. |
| 383 | + * @brief Set the SD card device detect pin, port and level. |
383 | 384 | * @param port one of the gpio port
|
384 | 385 | * @param pin one of the gpio pin
|
| 386 | + * @param level the level of the detect pin (HIGH or LOW) |
385 | 387 | * @retval SD status
|
386 | 388 | */
|
387 |
| -uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin) |
| 389 | +uint8_t BSP_SD_DetectPin(GPIO_TypeDef *port, uint32_t pin, uint32_t level) |
388 | 390 | {
|
389 | 391 | if (port != 0) {
|
390 | 392 | SD_detect_ll_gpio_pin = pin;
|
391 | 393 | SD_detect_gpio_port = port;
|
| 394 | + SD_detect_level = level; |
392 | 395 | return MSD_OK;
|
393 | 396 | }
|
394 | 397 | return MSD_ERROR;
|
@@ -469,12 +472,8 @@ uint8_t BSP_SD_DetectITConfig(void (*callback)(void))
|
469 | 472 | */
|
470 | 473 | uint8_t BSP_SD_IsDetected(void)
|
471 | 474 | {
|
472 |
| - uint8_t status = SD_NOT_PRESENT; |
473 | 475 | /* Check SD card detect pin */
|
474 |
| - if (!LL_GPIO_IsInputPinSet(SD_detect_gpio_port, SD_detect_ll_gpio_pin)) { |
475 |
| - status = SD_PRESENT; |
476 |
| - } |
477 |
| - return status; |
| 476 | + return (LL_GPIO_IsInputPinSet(SD_detect_gpio_port, SD_detect_ll_gpio_pin) == SD_detect_level) ? SD_PRESENT : SD_NOT_PRESENT; |
478 | 477 | }
|
479 | 478 |
|
480 | 479 | /**
|
|
0 commit comments