@@ -354,6 +354,15 @@ uint8_t BSP_SD_DeInit(void)
354354 /* Msp SD deinitialization */
355355 BSP_SD_MspDeInit (& uSdHandle , NULL );
356356
357+
358+ if (SD_detect_ll_gpio_pin != LL_GPIO_PIN_ALL ) {
359+ BSP_SD_Detect_MspDeInit (& uSdHandle , NULL );
360+ }
361+ #if defined(USE_SD_TRANSCEIVER ) && (USE_SD_TRANSCEIVER != 0U )
362+ BSP_SD_Transceiver_MspDeInit (& uSdHandle , NULL );
363+ #endif
364+
365+
357366 return sd_state ;
358367}
359368
@@ -523,26 +532,6 @@ __weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params)
523532#endif
524533}
525534
526- /**
527- * @brief Initializes the SD Detect pin MSP.
528- * @param hsd: SD handle
529- * @param Params : pointer on additional configuration parameters, can be NULL.
530- */
531- __weak void BSP_SD_Detect_MspInit (SD_HandleTypeDef * hsd , void * Params )
532- {
533- UNUSED (hsd );
534- UNUSED (Params );
535-
536- /* GPIO configuration in input for uSD_Detect signal */
537- #ifdef LL_GPIO_SPEED_FREQ_VERY_HIGH
538- LL_GPIO_SetPinSpeed (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_SPEED_FREQ_VERY_HIGH );
539- #else
540- LL_GPIO_SetPinSpeed (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_SPEED_FREQ_HIGH );
541- #endif
542- LL_GPIO_SetPinMode (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_INPUT );
543- LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_PULL_UP );
544- }
545-
546535/**
547536 * @brief DeInitializes the SD MSP.
548537 * @param hsd: SD handle
@@ -608,6 +597,47 @@ __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
608597#endif
609598}
610599
600+ /**
601+ * @brief Initializes the SD Detect pin MSP.
602+ * @param hsd: SD handle
603+ * @param Params : pointer on additional configuration parameters, can be NULL.
604+ */
605+ __weak void BSP_SD_Detect_MspInit (SD_HandleTypeDef * hsd , void * Params )
606+ {
607+ UNUSED (hsd );
608+ UNUSED (Params );
609+
610+ /* GPIO configuration in input for uSD_Detect signal */
611+ #ifdef LL_GPIO_SPEED_FREQ_VERY_HIGH
612+ LL_GPIO_SetPinSpeed (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_SPEED_FREQ_VERY_HIGH );
613+ #else
614+ LL_GPIO_SetPinSpeed (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_SPEED_FREQ_HIGH );
615+ #endif
616+ LL_GPIO_SetPinMode (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_INPUT );
617+ LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_PULL_UP );
618+ }
619+
620+ /**
621+ * @brief DeInitializes the SD Detect pin MSP.
622+ * @param hsd: SD handle
623+ * @param Params : pointer on additional configuration parameters, can be NULL.
624+ */
625+ __weak void BSP_SD_Detect_MspDeInit (SD_HandleTypeDef * hsd , void * Params )
626+ {
627+ UNUSED (hsd );
628+ UNUSED (Params );
629+
630+ /* GPIO configuration in analog to saves the consumption */
631+ LL_GPIO_SetPinSpeed (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_SPEED_FREQ_LOW );
632+ #ifndef LL_GPIO_PULL_NO
633+ /* For STM32F1xx */
634+ LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_FLOATING );
635+ #else
636+ LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_PULL_NO );
637+ #endif
638+ LL_GPIO_SetPinMode (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_ANALOG );
639+ }
640+
611641#if defined(USE_SD_TRANSCEIVER ) && (USE_SD_TRANSCEIVER != 0U )
612642/**
613643 * @brief Initializes the SD Transceiver pin MSP.
@@ -621,19 +651,46 @@ __weak void BSP_SD_Transceiver_MspInit(SD_HandleTypeDef *hsd, void *Params)
621651
622652 LL_GPIO_SetPinSpeed (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_SPEED_FREQ_HIGH );
623653 LL_GPIO_SetPinMode (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_MODE_OUTPUT );
654+ #ifndef LL_GPIO_PULL_NO
655+ /* For STM32F1xx */
656+ LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_FLOATING );
657+ #else
624658 LL_GPIO_SetPinPull (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_PULL_NO );
625-
659+ #endif
626660 LL_GPIO_SetPinSpeed (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_SPEED_FREQ_HIGH );
627661 LL_GPIO_SetPinMode (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_MODE_OUTPUT );
662+ #ifndef LL_GPIO_PULL_NO
663+ /* For STM32F1xx */
664+ LL_GPIO_SetPinPull (SD_detect_gpio_port , SD_detect_ll_gpio_pin , LL_GPIO_MODE_FLOATING );
665+ #else
628666 LL_GPIO_SetPinPull (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_PULL_NO );
629-
667+ #endif
630668 /* Enable the level shifter */
631669 LL_GPIO_SetOutputPin (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin );
632670
633671 /* By default start with the default voltage */
634672 LL_GPIO_ResetOutputPin (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin );
635673}
636674
675+ /**
676+ * @brief DeInitializes the SD Transceiver pin MSP.
677+ * @param hsd: SD handle
678+ * @param Params : pointer on additional configuration parameters, can be NULL.
679+ */
680+ __weak void BSP_SD_Transceiver_MspDeInit (SD_HandleTypeDef * hsd , void * Params )
681+ {
682+ UNUSED (hsd );
683+ UNUSED (Params );
684+
685+ LL_GPIO_SetPinSpeed (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_SPEED_FREQ_LOW );
686+ LL_GPIO_SetPinMode (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_MODE_ANALOG );
687+ LL_GPIO_SetPinPull (SD_trans_en_gpio_port , SD_trans_en_ll_gpio_pin , LL_GPIO_PULL_NO );
688+
689+ LL_GPIO_SetPinSpeed (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_SPEED_FREQ_LOW );
690+ LL_GPIO_SetPinMode (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_MODE_ANALOG );
691+ LL_GPIO_SetPinPull (SD_trans_sel_gpio_port , SD_trans_sel_ll_gpio_pin , LL_GPIO_PULL_NO );
692+ }
693+
637694/**
638695 * @brief Enable/Disable the SD Transceiver 1.8V Mode Callback.
639696 * @param status: Voltage Switch State
0 commit comments