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