STM32746G-Discovery board drivers V1.0.0

Dependents:   DISCO-F746NG_LCDTS_CC3000_NTP DISCO-F746NG_ROPE_WIFI F746_SpectralAnalysis_NoPhoto ecte433 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers stm32746g_discovery_sd.c Source File

stm32746g_discovery_sd.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32746g_discovery_sd.c
00004   * @author  MCD Application Team
00005   * @brief   This file includes the uSD card driver mounted on STM32746G-Discovery
00006   *          board.
00007   @verbatim
00008    1. How To use this driver:
00009    --------------------------
00010       - This driver is used to drive the micro SD external card mounted on STM32746G-Discovery
00011         board.
00012       - This driver does not need a specific component driver for the micro SD device
00013         to be included with.
00014    
00015    2. Driver description:
00016    ---------------------
00017      + Initialization steps:
00018         o Initialize the micro SD card using the BSP_SD_Init() function. This 
00019           function includes the MSP layer hardware resources initialization and the
00020           SDIO interface configuration to interface with the external micro SD. It 
00021           also includes the micro SD initialization sequence.
00022         o To check the SD card presence you can use the function BSP_SD_IsDetected() which 
00023           returns the detection status 
00024         o If SD presence detection interrupt mode is desired, you must configure the 
00025           SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt 
00026           is generated as an external interrupt whenever the micro SD card is 
00027           plugged/unplugged in/from the board.
00028         o The function BSP_SD_GetCardInfo() is used to get the micro SD card information 
00029           which is stored in the structure "HAL_SD_CardInfoTypedef".
00030      
00031      + Micro SD card operations
00032         o The micro SD card can be accessed with read/write block(s) operations once 
00033           it is ready for access. The access can be performed whether using the polling
00034           mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA 
00035           transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA()
00036         o The DMA transfer complete is used with interrupt mode. Once the SD transfer
00037           is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(),
00038           the DMA Tx/Rx transfer complete are handled using the functions
00039           BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks 
00040           are implemented by the user at application level. 
00041         o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying
00042           the number of blocks to erase.
00043         o The SD runtime status is returned when calling the function BSP_SD_GetCardState().
00044 
00045   @endverbatim
00046   ******************************************************************************
00047   * @attention
00048   *
00049   * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
00050   *
00051   * Redistribution and use in source and binary forms, with or without modification,
00052   * are permitted provided that the following conditions are met:
00053   *   1. Redistributions of source code must retain the above copyright notice,
00054   *      this list of conditions and the following disclaimer.
00055   *   2. Redistributions in binary form must reproduce the above copyright notice,
00056   *      this list of conditions and the following disclaimer in the documentation
00057   *      and/or other materials provided with the distribution.
00058   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00059   *      may be used to endorse or promote products derived from this software
00060   *      without specific prior written permission.
00061   *
00062   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00063   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00064   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00065   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00066   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00067   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00068   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00069   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00070   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00071   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00072   *
00073   ******************************************************************************
00074   */ 
00075 
00076 /* Dependencies
00077 - stm32746g_discovery.c
00078 - stm32f7xx_hal_sd.c
00079 - stm32f7xx_ll_sdmmc.c
00080 - stm32f7xx_hal_dma.c  
00081 - stm32f7xx_hal_gpio.c
00082 - stm32f7xx_hal_cortex.c
00083 - stm32f7xx_hal_rcc_ex.h
00084 EndDependencies */
00085 
00086 /* Includes ------------------------------------------------------------------*/
00087 #include "stm32746g_discovery_sd.h"
00088 
00089 /** @addtogroup BSP
00090   * @{
00091   */
00092 
00093 /** @addtogroup STM32746G_DISCOVERY
00094   * @{
00095   */ 
00096   
00097 /** @defgroup STM32746G_DISCOVERY_SD STM32746G_DISCOVERY_SD
00098   * @{
00099   */ 
00100 
00101 
00102 /** @defgroup STM32746G_DISCOVERY_SD_Private_TypesDefinitions STM32746G_DISCOVERY_SD Private Types Definitions
00103   * @{
00104   */
00105 /**
00106   * @}
00107   */ 
00108 
00109 /** @defgroup STM32746G_DISCOVERY_SD_Private_Defines STM32746G_DISCOVERY_SD Private Defines
00110   * @{
00111   */
00112 /**
00113   * @}
00114   */ 
00115   
00116 /** @defgroup STM32746G_DISCOVERY_SD_Private_Macros STM32746G_DISCOVERY_SD Private Macros
00117   * @{
00118   */    
00119 /**
00120   * @}
00121   */  
00122 
00123 /** @defgroup STM32746G_DISCOVERY_SD_Private_Variables STM32746G_DISCOVERY_SD Private Variables
00124   * @{
00125   */
00126 SD_HandleTypeDef uSdHandle;
00127 
00128 /**
00129   * @}
00130   */ 
00131   
00132 /** @defgroup STM32746G_DISCOVERY_SD_Private_FunctionPrototypes STM32746G_DISCOVERY_SD Private Function Prototypes
00133   * @{
00134   */
00135 /**
00136   * @}
00137   */ 
00138   
00139 /** @defgroup STM32746G_DISCOVERY_SD_Exported_Functions STM32746G_DISCOVERY_SD Exported Functions
00140   * @{
00141   */
00142 
00143 /**
00144   * @brief  Initializes the SD card device.
00145   * @retval SD status
00146   */
00147 uint8_t BSP_SD_Init(void)
00148 { 
00149   uint8_t sd_state = MSD_OK;
00150   
00151   /* uSD device interface configuration */
00152   uSdHandle.Instance = SDMMC1;
00153 
00154   uSdHandle.Init.ClockEdge           = SDMMC_CLOCK_EDGE_RISING;
00155   uSdHandle.Init.ClockBypass         = SDMMC_CLOCK_BYPASS_DISABLE;
00156   uSdHandle.Init.ClockPowerSave      = SDMMC_CLOCK_POWER_SAVE_DISABLE;
00157   uSdHandle.Init.BusWide             = SDMMC_BUS_WIDE_1B;
00158   uSdHandle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE;
00159   uSdHandle.Init.ClockDiv            = SDMMC_TRANSFER_CLK_DIV;
00160   
00161   /* Msp SD Detect pin initialization */
00162   BSP_SD_Detect_MspInit(&uSdHandle, NULL);
00163   if(BSP_SD_IsDetected() != SD_PRESENT)   /* Check if SD card is present */
00164   {
00165     return MSD_ERROR_SD_NOT_PRESENT;
00166   }
00167   
00168   /* Msp SD initialization */
00169   BSP_SD_MspInit(&uSdHandle, NULL);
00170 
00171   /* HAL SD initialization */
00172   if(HAL_SD_Init(&uSdHandle) != HAL_OK)
00173   {
00174     sd_state = MSD_ERROR;
00175   }
00176   
00177   /* Configure SD Bus width */
00178   if(sd_state == MSD_OK)
00179   {
00180     /* Enable wide operation */ 
00181     if(HAL_SD_ConfigWideBusOperation(&uSdHandle, SDMMC_BUS_WIDE_4B) != HAL_OK)
00182     {
00183       sd_state = MSD_ERROR;
00184     }
00185     else
00186     {
00187       sd_state = MSD_OK;
00188     }
00189   }
00190   
00191   return  sd_state;
00192 }
00193 
00194 /**
00195   * @brief  DeInitializes the SD card device.
00196   * @retval SD status
00197   */
00198 uint8_t BSP_SD_DeInit(void)
00199 { 
00200   uint8_t sd_state = MSD_OK;
00201  
00202   uSdHandle.Instance = SDMMC1;
00203   
00204   /* HAL SD deinitialization */
00205   if(HAL_SD_DeInit(&uSdHandle) != HAL_OK)
00206   {
00207     sd_state = MSD_ERROR;
00208   }
00209 
00210   /* Msp SD deinitialization */
00211   uSdHandle.Instance = SDMMC1;
00212   BSP_SD_MspDeInit(&uSdHandle, NULL);
00213   
00214   return  sd_state;
00215 }
00216 
00217 /**
00218   * @brief  Configures Interrupt mode for SD detection pin.
00219   * @retval Returns MSD_OK
00220   */
00221 uint8_t BSP_SD_ITConfig(void)
00222 {  
00223   GPIO_InitTypeDef gpio_init_structure;
00224 
00225   /* Configure Interrupt mode for SD detection pin */  
00226   gpio_init_structure.Pin = SD_DETECT_PIN;
00227   gpio_init_structure.Pull = GPIO_PULLUP;
00228   gpio_init_structure.Speed = GPIO_SPEED_FAST;
00229   gpio_init_structure.Mode = GPIO_MODE_IT_RISING_FALLING;
00230   HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure);
00231 
00232   /* Enable and set SD detect EXTI Interrupt to the lowest priority */
00233   HAL_NVIC_SetPriority((IRQn_Type)(SD_DETECT_EXTI_IRQn), 0x0F, 0x00);
00234   HAL_NVIC_EnableIRQ((IRQn_Type)(SD_DETECT_EXTI_IRQn));
00235 
00236   return MSD_OK;
00237 }
00238 
00239 /**
00240   * @brief  Detects if SD card is correctly plugged in the memory slot or not.
00241   * @retval Returns if SD is detected or not
00242   */
00243 uint8_t BSP_SD_IsDetected(void)
00244 {
00245   __IO uint8_t      status = SD_PRESENT;
00246   
00247   /* Check SD card detect pin */
00248   if (HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == GPIO_PIN_SET)
00249   {
00250     status = SD_NOT_PRESENT;
00251   }
00252 
00253   return status;
00254 }
00255 
00256 /**
00257   * @brief  Reads block(s) from a specified address in an SD card, in polling mode.
00258   * @param  pData: Pointer to the buffer that will contain the data to transmit
00259   * @param  ReadAddr: Address from where data is to be read
00260   * @param  NumOfBlocks: Number of SD blocks to read
00261   * @param  Timeout: Timeout for read operation
00262   * @retval SD status
00263   */
00264 uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks, uint32_t Timeout)
00265 {
00266   if(HAL_SD_ReadBlocks(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks, Timeout) != HAL_OK)
00267   {
00268     return MSD_ERROR;
00269   }
00270   else
00271   {
00272     return MSD_OK;
00273   }
00274 }
00275 
00276 /**
00277   * @brief  Writes block(s) to a specified address in an SD card, in polling mode. 
00278   * @param  pData: Pointer to the buffer that will contain the data to transmit
00279   * @param  WriteAddr: Address from where data is to be written
00280   * @param  NumOfBlocks: Number of SD blocks to write
00281   * @param  Timeout: Timeout for write operation
00282   * @retval SD status
00283   */
00284 uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks, uint32_t Timeout)
00285 {
00286   if(HAL_SD_WriteBlocks(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks, Timeout) != HAL_OK)
00287   {
00288     return MSD_ERROR;
00289   }
00290   else
00291   {
00292     return MSD_OK;
00293   }
00294 }
00295 
00296 /**
00297   * @brief  Reads block(s) from a specified address in an SD card, in DMA mode.
00298   * @param  pData: Pointer to the buffer that will contain the data to transmit
00299   * @param  ReadAddr: Address from where data is to be read
00300   * @param  NumOfBlocks: Number of SD blocks to read 
00301   * @retval SD status
00302   */
00303 uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint32_t ReadAddr, uint32_t NumOfBlocks)
00304 {  
00305   /* Read block(s) in DMA transfer mode */
00306   if(HAL_SD_ReadBlocks_DMA(&uSdHandle, (uint8_t *)pData, ReadAddr, NumOfBlocks) != HAL_OK)
00307   {
00308     return MSD_ERROR;
00309   }
00310   else
00311   {
00312     return MSD_OK;
00313   }
00314 }
00315 
00316 /**
00317   * @brief  Writes block(s) to a specified address in an SD card, in DMA mode.
00318   * @param  pData: Pointer to the buffer that will contain the data to transmit
00319   * @param  WriteAddr: Address from where data is to be written
00320   * @param  NumOfBlocks: Number of SD blocks to write 
00321   * @retval SD status
00322   */
00323 uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint32_t WriteAddr, uint32_t NumOfBlocks)
00324 { 
00325   /* Write block(s) in DMA transfer mode */
00326   if(HAL_SD_WriteBlocks_DMA(&uSdHandle, (uint8_t *)pData, WriteAddr, NumOfBlocks) != HAL_OK)
00327   {
00328     return MSD_ERROR;
00329   }
00330   else
00331   {
00332     return MSD_OK;
00333   }
00334 }
00335 
00336 /**
00337   * @brief  Erases the specified memory area of the given SD card. 
00338   * @param  StartAddr: Start byte address
00339   * @param  EndAddr: End byte address
00340   * @retval SD status
00341   */
00342 uint8_t BSP_SD_Erase(uint32_t StartAddr, uint32_t EndAddr)
00343 {
00344   if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != HAL_OK)
00345   {
00346     return MSD_ERROR;
00347   }
00348   else
00349   {
00350     return MSD_OK;
00351   }
00352 }
00353 
00354 /**
00355   * @brief  Initializes the SD MSP.
00356   * @param  hsd: SD handle
00357   * @param  Params
00358   * @retval None
00359   */
00360 __weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params)
00361 {
00362   static DMA_HandleTypeDef dma_rx_handle;
00363   static DMA_HandleTypeDef dma_tx_handle;
00364   GPIO_InitTypeDef gpio_init_structure;
00365 
00366   /* Enable SDIO clock */
00367   __HAL_RCC_SDMMC1_CLK_ENABLE();
00368   
00369   /* Enable DMA2 clocks */
00370   __DMAx_TxRx_CLK_ENABLE();
00371 
00372   /* Enable GPIOs clock */
00373   __HAL_RCC_GPIOC_CLK_ENABLE();
00374   __HAL_RCC_GPIOD_CLK_ENABLE();
00375   
00376   /* Common GPIO configuration */
00377   gpio_init_structure.Mode      = GPIO_MODE_AF_PP;
00378   gpio_init_structure.Pull      = GPIO_PULLUP;
00379   gpio_init_structure.Speed     = GPIO_SPEED_HIGH;
00380   gpio_init_structure.Alternate = GPIO_AF12_SDMMC1;
00381   
00382   /* GPIOC configuration */
00383   gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12;
00384   HAL_GPIO_Init(GPIOC, &gpio_init_structure);
00385 
00386   /* GPIOD configuration */
00387   gpio_init_structure.Pin = GPIO_PIN_2;
00388   HAL_GPIO_Init(GPIOD, &gpio_init_structure);
00389 
00390   /* NVIC configuration for SDIO interrupts */
00391   HAL_NVIC_SetPriority(SDMMC1_IRQn, 0x0E, 0);
00392   HAL_NVIC_EnableIRQ(SDMMC1_IRQn);
00393     
00394   /* Configure DMA Rx parameters */
00395   dma_rx_handle.Init.Channel             = SD_DMAx_Rx_CHANNEL;
00396   dma_rx_handle.Init.Direction           = DMA_PERIPH_TO_MEMORY;
00397   dma_rx_handle.Init.PeriphInc           = DMA_PINC_DISABLE;
00398   dma_rx_handle.Init.MemInc              = DMA_MINC_ENABLE;
00399   dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
00400   dma_rx_handle.Init.MemDataAlignment    = DMA_MDATAALIGN_WORD;
00401   dma_rx_handle.Init.Mode                = DMA_PFCTRL;
00402   dma_rx_handle.Init.Priority            = DMA_PRIORITY_VERY_HIGH;
00403   dma_rx_handle.Init.FIFOMode            = DMA_FIFOMODE_ENABLE;
00404   dma_rx_handle.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
00405   dma_rx_handle.Init.MemBurst            = DMA_MBURST_INC4;
00406   dma_rx_handle.Init.PeriphBurst         = DMA_PBURST_INC4;
00407   
00408   dma_rx_handle.Instance = SD_DMAx_Rx_STREAM;
00409   
00410   /* Associate the DMA handle */
00411   __HAL_LINKDMA(hsd, hdmarx, dma_rx_handle);
00412   
00413   /* Deinitialize the stream for new transfer */
00414   HAL_DMA_DeInit(&dma_rx_handle);
00415   
00416   /* Configure the DMA stream */
00417   HAL_DMA_Init(&dma_rx_handle);
00418   
00419   /* Configure DMA Tx parameters */
00420   dma_tx_handle.Init.Channel             = SD_DMAx_Tx_CHANNEL;
00421   dma_tx_handle.Init.Direction           = DMA_MEMORY_TO_PERIPH;
00422   dma_tx_handle.Init.PeriphInc           = DMA_PINC_DISABLE;
00423   dma_tx_handle.Init.MemInc              = DMA_MINC_ENABLE;
00424   dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD;
00425   dma_tx_handle.Init.MemDataAlignment    = DMA_MDATAALIGN_WORD;
00426   dma_tx_handle.Init.Mode                = DMA_PFCTRL;
00427   dma_tx_handle.Init.Priority            = DMA_PRIORITY_VERY_HIGH;
00428   dma_tx_handle.Init.FIFOMode            = DMA_FIFOMODE_ENABLE;
00429   dma_tx_handle.Init.FIFOThreshold       = DMA_FIFO_THRESHOLD_FULL;
00430   dma_tx_handle.Init.MemBurst            = DMA_MBURST_INC4;
00431   dma_tx_handle.Init.PeriphBurst         = DMA_PBURST_INC4;
00432   
00433   dma_tx_handle.Instance = SD_DMAx_Tx_STREAM;
00434   
00435   /* Associate the DMA handle */
00436   __HAL_LINKDMA(hsd, hdmatx, dma_tx_handle);
00437   
00438   /* Deinitialize the stream for new transfer */
00439   HAL_DMA_DeInit(&dma_tx_handle);
00440   
00441   /* Configure the DMA stream */
00442   HAL_DMA_Init(&dma_tx_handle); 
00443   
00444   /* NVIC configuration for DMA transfer complete interrupt */
00445   HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 0x0F, 0);
00446   HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn);
00447   
00448   /* NVIC configuration for DMA transfer complete interrupt */
00449   HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 0x0F, 0);
00450   HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn);
00451 }
00452 
00453 /**
00454   * @brief  Initializes the SD Detect pin MSP.
00455   * @param  hsd: SD handle
00456   * @param  Params
00457   * @retval None
00458   */
00459 __weak void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params)
00460 {
00461   GPIO_InitTypeDef  gpio_init_structure;
00462 
00463   SD_DETECT_GPIO_CLK_ENABLE();
00464 
00465   /* GPIO configuration in input for uSD_Detect signal */
00466   gpio_init_structure.Pin       = SD_DETECT_PIN;
00467   gpio_init_structure.Mode      = GPIO_MODE_INPUT;
00468   gpio_init_structure.Pull      = GPIO_PULLUP;
00469   gpio_init_structure.Speed     = GPIO_SPEED_HIGH;
00470   HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure);
00471 }
00472 
00473 /**
00474   * @brief  DeInitializes the SD MSP.
00475   * @param  hsd: SD handle
00476   * @param  Params
00477   * @retval None
00478   */
00479 __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params)
00480 {
00481   static DMA_HandleTypeDef dma_rx_handle;
00482   static DMA_HandleTypeDef dma_tx_handle;
00483 
00484   /* Disable NVIC for DMA transfer complete interrupts */
00485   HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn);
00486   HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn);
00487 
00488   /* Deinitialize the stream for new transfer */
00489   dma_rx_handle.Instance = SD_DMAx_Rx_STREAM;
00490   HAL_DMA_DeInit(&dma_rx_handle);
00491 
00492   /* Deinitialize the stream for new transfer */
00493   dma_tx_handle.Instance = SD_DMAx_Tx_STREAM;
00494   HAL_DMA_DeInit(&dma_tx_handle);
00495 
00496   /* Disable NVIC for SDIO interrupts */
00497   HAL_NVIC_DisableIRQ(SDMMC1_IRQn);
00498 
00499   /* DeInit GPIO pins can be done in the application
00500      (by surcharging this __weak function) */
00501 
00502   /* Disable SDMMC1 clock */
00503   __HAL_RCC_SDMMC1_CLK_DISABLE();
00504 
00505   /* GPIO pins clock and DMA clocks can be shut down in the application
00506      by surcharging this __weak function */
00507 }
00508 
00509 /**
00510   * @brief  Gets the current SD card data status.
00511   * @retval Data transfer state.
00512   *          This value can be one of the following values:
00513   *            @arg  SD_TRANSFER_OK: No data transfer is acting
00514   *            @arg  SD_TRANSFER_BUSY: Data transfer is acting
00515   */
00516 uint8_t BSP_SD_GetCardState(void)
00517 {
00518   return((HAL_SD_GetCardState(&uSdHandle) == HAL_SD_CARD_TRANSFER ) ? SD_TRANSFER_OK : SD_TRANSFER_BUSY);
00519 }
00520   
00521 
00522 /**
00523   * @brief  Get SD information about specific SD card.
00524   * @param  CardInfo: Pointer to HAL_SD_CardInfoTypedef structure
00525   * @retval None 
00526   */
00527 void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypeDef *CardInfo)
00528 {
00529   /* Get SD card Information */
00530   HAL_SD_GetCardInfo(&uSdHandle, CardInfo);
00531 }
00532 
00533 /**
00534   * @brief SD Abort callbacks
00535   * @param hsd: SD handle
00536   * @retval None
00537   */
00538 void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd)
00539 {
00540   BSP_SD_AbortCallback();
00541 }
00542 
00543 /**
00544   * @brief Tx Transfer completed callbacks
00545   * @param hsd: SD handle
00546   * @retval None
00547   */
00548 void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd)
00549 {
00550   BSP_SD_WriteCpltCallback();
00551 }
00552 
00553 /**
00554   * @brief Rx Transfer completed callbacks
00555   * @param hsd: SD handle
00556   * @retval None
00557   */
00558 void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd)
00559 {
00560   BSP_SD_ReadCpltCallback();
00561 }
00562 
00563 /**
00564   * @brief BSP SD Abort callbacks
00565   * @retval None
00566   */
00567 __weak void BSP_SD_AbortCallback(void)
00568 {
00569 
00570 }
00571 
00572 /**
00573   * @brief BSP Tx Transfer completed callbacks
00574   * @retval None
00575   */
00576 __weak void BSP_SD_WriteCpltCallback(void)
00577 {
00578 
00579 }
00580 
00581 /**
00582   * @brief BSP Rx Transfer completed callbacks
00583   * @retval None
00584   */
00585 __weak void BSP_SD_ReadCpltCallback(void)
00586 {
00587 
00588 }
00589 
00590 /**
00591   * @}
00592   */ 
00593 
00594 /**
00595   * @}
00596   */ 
00597 
00598 /**
00599   * @}
00600   */ 
00601 
00602 /**
00603   * @}
00604   */
00605  
00606 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/