JPA sdcard
stm32746g_discovery_sd.c@15:435cacf7f874, 2020-12-30 (annotated)
- Committer:
- jeanpierreaulas
- Date:
- Wed Dec 30 14:46:04 2020 +0000
- Revision:
- 15:435cacf7f874
- Parent:
- 14:ed51426706bd
JPA
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
38domo | 14:ed51426706bd | 1 | /** |
38domo | 14:ed51426706bd | 2 | ****************************************************************************** |
38domo | 14:ed51426706bd | 3 | * @file stm32746g_discovery_sd.c |
38domo | 14:ed51426706bd | 4 | * @author MCD Application Team |
38domo | 14:ed51426706bd | 5 | * @version V1.0.0 |
38domo | 14:ed51426706bd | 6 | * @date 25-June-2015 |
38domo | 14:ed51426706bd | 7 | * @brief This file includes the uSD card driver mounted on STM32746G-Discovery |
38domo | 14:ed51426706bd | 8 | * board. |
38domo | 14:ed51426706bd | 9 | @verbatim |
38domo | 14:ed51426706bd | 10 | 1. How To use this driver: |
38domo | 14:ed51426706bd | 11 | -------------------------- |
38domo | 14:ed51426706bd | 12 | - This driver is used to drive the micro SD external card mounted on STM32746G-Discovery |
38domo | 14:ed51426706bd | 13 | board. |
38domo | 14:ed51426706bd | 14 | - This driver does not need a specific component driver for the micro SD device |
38domo | 14:ed51426706bd | 15 | to be included with. |
38domo | 14:ed51426706bd | 16 | |
38domo | 14:ed51426706bd | 17 | 2. Driver description: |
38domo | 14:ed51426706bd | 18 | --------------------- |
38domo | 14:ed51426706bd | 19 | + Initialization steps: |
38domo | 14:ed51426706bd | 20 | o Initialize the micro SD card using the BSP_SD_Init() function. This |
38domo | 14:ed51426706bd | 21 | function includes the MSP layer hardware resources initialization and the |
38domo | 14:ed51426706bd | 22 | SDIO interface configuration to interface with the external micro SD. It |
38domo | 14:ed51426706bd | 23 | also includes the micro SD initialization sequence. |
38domo | 14:ed51426706bd | 24 | o To check the SD card presence you can use the function BSP_SD_IsDetected() which |
38domo | 14:ed51426706bd | 25 | returns the detection status |
38domo | 14:ed51426706bd | 26 | o If SD presence detection interrupt mode is desired, you must configure the |
38domo | 14:ed51426706bd | 27 | SD detection interrupt mode by calling the function BSP_SD_ITConfig(). The interrupt |
38domo | 14:ed51426706bd | 28 | is generated as an external interrupt whenever the micro SD card is |
38domo | 14:ed51426706bd | 29 | plugged/unplugged in/from the board. |
38domo | 14:ed51426706bd | 30 | o The function BSP_SD_GetCardInfo() is used to get the micro SD card information |
38domo | 14:ed51426706bd | 31 | which is stored in the structure "HAL_SD_CardInfoTypedef". |
38domo | 14:ed51426706bd | 32 | |
38domo | 14:ed51426706bd | 33 | + Micro SD card operations |
38domo | 14:ed51426706bd | 34 | o The micro SD card can be accessed with read/write block(s) operations once |
38domo | 14:ed51426706bd | 35 | it is ready for access. The access can be performed whether using the polling |
38domo | 14:ed51426706bd | 36 | mode by calling the functions BSP_SD_ReadBlocks()/BSP_SD_WriteBlocks(), or by DMA |
38domo | 14:ed51426706bd | 37 | transfer using the functions BSP_SD_ReadBlocks_DMA()/BSP_SD_WriteBlocks_DMA() |
38domo | 14:ed51426706bd | 38 | o The DMA transfer complete is used with interrupt mode. Once the SD transfer |
38domo | 14:ed51426706bd | 39 | is complete, the SD interrupt is handled using the function BSP_SD_IRQHandler(), |
38domo | 14:ed51426706bd | 40 | the DMA Tx/Rx transfer complete are handled using the functions |
38domo | 14:ed51426706bd | 41 | BSP_SD_DMA_Tx_IRQHandler()/BSP_SD_DMA_Rx_IRQHandler(). The corresponding user callbacks |
38domo | 14:ed51426706bd | 42 | are implemented by the user at application level. |
38domo | 14:ed51426706bd | 43 | o The SD erase block(s) is performed using the function BSP_SD_Erase() with specifying |
38domo | 14:ed51426706bd | 44 | the number of blocks to erase. |
38domo | 14:ed51426706bd | 45 | o The SD runtime status is returned when calling the function BSP_SD_GetStatus(). |
38domo | 14:ed51426706bd | 46 | @endverbatim |
38domo | 14:ed51426706bd | 47 | ****************************************************************************** |
38domo | 14:ed51426706bd | 48 | * @attention |
38domo | 14:ed51426706bd | 49 | * |
38domo | 14:ed51426706bd | 50 | * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> |
38domo | 14:ed51426706bd | 51 | * |
38domo | 14:ed51426706bd | 52 | * Redistribution and use in source and binary forms, with or without modification, |
38domo | 14:ed51426706bd | 53 | * are permitted provided that the following conditions are met: |
38domo | 14:ed51426706bd | 54 | * 1. Redistributions of source code must retain the above copyright notice, |
38domo | 14:ed51426706bd | 55 | * this list of conditions and the following disclaimer. |
38domo | 14:ed51426706bd | 56 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
38domo | 14:ed51426706bd | 57 | * this list of conditions and the following disclaimer in the documentation |
38domo | 14:ed51426706bd | 58 | * and/or other materials provided with the distribution. |
38domo | 14:ed51426706bd | 59 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
38domo | 14:ed51426706bd | 60 | * may be used to endorse or promote products derived from this software |
38domo | 14:ed51426706bd | 61 | * without specific prior written permission. |
38domo | 14:ed51426706bd | 62 | * |
38domo | 14:ed51426706bd | 63 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
38domo | 14:ed51426706bd | 64 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
38domo | 14:ed51426706bd | 65 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
38domo | 14:ed51426706bd | 66 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
38domo | 14:ed51426706bd | 67 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
38domo | 14:ed51426706bd | 68 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
38domo | 14:ed51426706bd | 69 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
38domo | 14:ed51426706bd | 70 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
38domo | 14:ed51426706bd | 71 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
38domo | 14:ed51426706bd | 72 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
38domo | 14:ed51426706bd | 73 | * |
38domo | 14:ed51426706bd | 74 | ****************************************************************************** |
38domo | 14:ed51426706bd | 75 | */ |
38domo | 14:ed51426706bd | 76 | |
38domo | 14:ed51426706bd | 77 | /* Includes ------------------------------------------------------------------*/ |
38domo | 14:ed51426706bd | 78 | #include "stm32746g_discovery_sd.h" |
38domo | 14:ed51426706bd | 79 | |
38domo | 14:ed51426706bd | 80 | /** @addtogroup BSP |
38domo | 14:ed51426706bd | 81 | * @{ |
38domo | 14:ed51426706bd | 82 | */ |
38domo | 14:ed51426706bd | 83 | |
38domo | 14:ed51426706bd | 84 | /** @addtogroup STM32746G_DISCOVERY |
38domo | 14:ed51426706bd | 85 | * @{ |
38domo | 14:ed51426706bd | 86 | */ |
38domo | 14:ed51426706bd | 87 | |
38domo | 14:ed51426706bd | 88 | /** @defgroup STM32746G_DISCOVERY_SD STM32746G_DISCOVERY_SD |
38domo | 14:ed51426706bd | 89 | * @{ |
38domo | 14:ed51426706bd | 90 | */ |
38domo | 14:ed51426706bd | 91 | |
38domo | 14:ed51426706bd | 92 | |
38domo | 14:ed51426706bd | 93 | /** @defgroup STM32746G_DISCOVERY_SD_Private_TypesDefinitions STM32746G_DISCOVERY_SD Private Types Definitions |
38domo | 14:ed51426706bd | 94 | * @{ |
38domo | 14:ed51426706bd | 95 | */ |
38domo | 14:ed51426706bd | 96 | /** |
38domo | 14:ed51426706bd | 97 | * @} |
38domo | 14:ed51426706bd | 98 | */ |
38domo | 14:ed51426706bd | 99 | |
38domo | 14:ed51426706bd | 100 | /** @defgroup STM32746G_DISCOVERY_SD_Private_Defines STM32746G_DISCOVERY_SD Private Defines |
38domo | 14:ed51426706bd | 101 | * @{ |
38domo | 14:ed51426706bd | 102 | */ |
38domo | 14:ed51426706bd | 103 | /** |
38domo | 14:ed51426706bd | 104 | * @} |
38domo | 14:ed51426706bd | 105 | */ |
38domo | 14:ed51426706bd | 106 | |
38domo | 14:ed51426706bd | 107 | /** @defgroup STM32746G_DISCOVERY_SD_Private_Macros STM32746G_DISCOVERY_SD Private Macros |
38domo | 14:ed51426706bd | 108 | * @{ |
38domo | 14:ed51426706bd | 109 | */ |
38domo | 14:ed51426706bd | 110 | /** |
38domo | 14:ed51426706bd | 111 | * @} |
38domo | 14:ed51426706bd | 112 | */ |
38domo | 14:ed51426706bd | 113 | |
38domo | 14:ed51426706bd | 114 | /** @defgroup STM32746G_DISCOVERY_SD_Private_Variables STM32746G_DISCOVERY_SD Private Variables |
38domo | 14:ed51426706bd | 115 | * @{ |
38domo | 14:ed51426706bd | 116 | */ |
38domo | 14:ed51426706bd | 117 | static SD_HandleTypeDef uSdHandle; |
38domo | 14:ed51426706bd | 118 | static SD_CardInfo uSdCardInfo; |
38domo | 14:ed51426706bd | 119 | |
38domo | 14:ed51426706bd | 120 | /** |
38domo | 14:ed51426706bd | 121 | * @} |
38domo | 14:ed51426706bd | 122 | */ |
38domo | 14:ed51426706bd | 123 | |
38domo | 14:ed51426706bd | 124 | /** @defgroup STM32746G_DISCOVERY_SD_Private_FunctionPrototypes STM32746G_DISCOVERY_SD Private Function Prototypes |
38domo | 14:ed51426706bd | 125 | * @{ |
38domo | 14:ed51426706bd | 126 | */ |
38domo | 14:ed51426706bd | 127 | /** |
38domo | 14:ed51426706bd | 128 | * @} |
38domo | 14:ed51426706bd | 129 | */ |
38domo | 14:ed51426706bd | 130 | |
38domo | 14:ed51426706bd | 131 | /** @defgroup STM32746G_DISCOVERY_SD_Exported_Functions STM32746G_DISCOVERY_SD Exported Functions |
38domo | 14:ed51426706bd | 132 | * @{ |
38domo | 14:ed51426706bd | 133 | */ |
38domo | 14:ed51426706bd | 134 | |
38domo | 14:ed51426706bd | 135 | /** |
38domo | 14:ed51426706bd | 136 | * @brief Initializes the SD card device. |
38domo | 14:ed51426706bd | 137 | * @retval SD status |
38domo | 14:ed51426706bd | 138 | */ |
38domo | 14:ed51426706bd | 139 | uint8_t BSP_SD_Init(void) |
38domo | 14:ed51426706bd | 140 | { |
38domo | 14:ed51426706bd | 141 | uint8_t sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 142 | |
38domo | 14:ed51426706bd | 143 | /* uSD device interface configuration */ |
38domo | 14:ed51426706bd | 144 | uSdHandle.Instance = SDMMC1; |
38domo | 14:ed51426706bd | 145 | |
38domo | 14:ed51426706bd | 146 | uSdHandle.Init.ClockEdge = SDMMC_CLOCK_EDGE_RISING; |
38domo | 14:ed51426706bd | 147 | uSdHandle.Init.ClockBypass = SDMMC_CLOCK_BYPASS_DISABLE; |
38domo | 14:ed51426706bd | 148 | uSdHandle.Init.ClockPowerSave = SDMMC_CLOCK_POWER_SAVE_DISABLE; |
38domo | 14:ed51426706bd | 149 | uSdHandle.Init.BusWide = SDMMC_BUS_WIDE_1B; |
38domo | 14:ed51426706bd | 150 | uSdHandle.Init.HardwareFlowControl = SDMMC_HARDWARE_FLOW_CONTROL_DISABLE; |
38domo | 14:ed51426706bd | 151 | uSdHandle.Init.ClockDiv = SDMMC_TRANSFER_CLK_DIV; |
38domo | 14:ed51426706bd | 152 | |
38domo | 14:ed51426706bd | 153 | /* Msp SD Detect pin initialization */ |
38domo | 14:ed51426706bd | 154 | BSP_SD_Detect_MspInit(&uSdHandle, NULL); |
38domo | 14:ed51426706bd | 155 | if(BSP_SD_IsDetected() != SD_PRESENT) /* Check if SD card is present */ |
38domo | 14:ed51426706bd | 156 | { |
38domo | 14:ed51426706bd | 157 | return MSD_ERROR_SD_NOT_PRESENT; |
38domo | 14:ed51426706bd | 158 | } |
38domo | 14:ed51426706bd | 159 | |
38domo | 14:ed51426706bd | 160 | /* Msp SD initialization */ |
38domo | 14:ed51426706bd | 161 | BSP_SD_MspInit(&uSdHandle, NULL); |
38domo | 14:ed51426706bd | 162 | |
38domo | 14:ed51426706bd | 163 | /* HAL SD initialization */ |
38domo | 14:ed51426706bd | 164 | if(HAL_SD_Init(&uSdHandle, &uSdCardInfo) != SD_OK) |
38domo | 14:ed51426706bd | 165 | { |
38domo | 14:ed51426706bd | 166 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 167 | } |
38domo | 14:ed51426706bd | 168 | |
38domo | 14:ed51426706bd | 169 | /* Configure SD Bus width */ |
38domo | 14:ed51426706bd | 170 | if(sd_state == MSD_OK) |
38domo | 14:ed51426706bd | 171 | { |
38domo | 14:ed51426706bd | 172 | /* Enable wide operation */ |
38domo | 14:ed51426706bd | 173 | if(HAL_SD_WideBusOperation_Config(&uSdHandle, SDMMC_BUS_WIDE_4B) != SD_OK) |
38domo | 14:ed51426706bd | 174 | { |
38domo | 14:ed51426706bd | 175 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 176 | } |
38domo | 14:ed51426706bd | 177 | else |
38domo | 14:ed51426706bd | 178 | { |
38domo | 14:ed51426706bd | 179 | sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 180 | } |
38domo | 14:ed51426706bd | 181 | } |
38domo | 14:ed51426706bd | 182 | |
38domo | 14:ed51426706bd | 183 | return sd_state; |
38domo | 14:ed51426706bd | 184 | } |
38domo | 14:ed51426706bd | 185 | |
38domo | 14:ed51426706bd | 186 | /** |
38domo | 14:ed51426706bd | 187 | * @brief DeInitializes the SD card device. |
38domo | 14:ed51426706bd | 188 | * @retval SD status |
38domo | 14:ed51426706bd | 189 | */ |
38domo | 14:ed51426706bd | 190 | uint8_t BSP_SD_DeInit(void) |
38domo | 14:ed51426706bd | 191 | { |
38domo | 14:ed51426706bd | 192 | uint8_t sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 193 | |
38domo | 14:ed51426706bd | 194 | uSdHandle.Instance = SDMMC1; |
38domo | 14:ed51426706bd | 195 | |
38domo | 14:ed51426706bd | 196 | /* HAL SD deinitialization */ |
38domo | 14:ed51426706bd | 197 | if(HAL_SD_DeInit(&uSdHandle) != HAL_OK) |
38domo | 14:ed51426706bd | 198 | { |
38domo | 14:ed51426706bd | 199 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 200 | } |
38domo | 14:ed51426706bd | 201 | |
38domo | 14:ed51426706bd | 202 | /* Msp SD deinitialization */ |
38domo | 14:ed51426706bd | 203 | uSdHandle.Instance = SDMMC1; |
38domo | 14:ed51426706bd | 204 | BSP_SD_MspDeInit(&uSdHandle, NULL); |
38domo | 14:ed51426706bd | 205 | |
38domo | 14:ed51426706bd | 206 | return sd_state; |
38domo | 14:ed51426706bd | 207 | } |
38domo | 14:ed51426706bd | 208 | |
38domo | 14:ed51426706bd | 209 | /** |
38domo | 14:ed51426706bd | 210 | * @brief Configures Interrupt mode for SD detection pin. |
38domo | 14:ed51426706bd | 211 | * @retval Returns MSD_OK |
38domo | 14:ed51426706bd | 212 | */ |
38domo | 14:ed51426706bd | 213 | uint8_t BSP_SD_ITConfig(void) |
38domo | 14:ed51426706bd | 214 | { |
38domo | 14:ed51426706bd | 215 | GPIO_InitTypeDef gpio_init_structure; |
38domo | 14:ed51426706bd | 216 | |
38domo | 14:ed51426706bd | 217 | /* Configure Interrupt mode for SD detection pin */ |
38domo | 14:ed51426706bd | 218 | gpio_init_structure.Pin = SD_DETECT_PIN; |
38domo | 14:ed51426706bd | 219 | gpio_init_structure.Pull = GPIO_PULLUP; |
38domo | 14:ed51426706bd | 220 | gpio_init_structure.Speed = GPIO_SPEED_FAST; |
38domo | 14:ed51426706bd | 221 | gpio_init_structure.Mode = GPIO_MODE_IT_RISING_FALLING; |
38domo | 14:ed51426706bd | 222 | HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure); |
38domo | 14:ed51426706bd | 223 | |
38domo | 14:ed51426706bd | 224 | /* Enable and set SD detect EXTI Interrupt to the lowest priority */ |
38domo | 14:ed51426706bd | 225 | HAL_NVIC_SetPriority((IRQn_Type)(SD_DETECT_EXTI_IRQn), 0x0F, 0x00); |
38domo | 14:ed51426706bd | 226 | HAL_NVIC_EnableIRQ((IRQn_Type)(SD_DETECT_EXTI_IRQn)); |
38domo | 14:ed51426706bd | 227 | |
38domo | 14:ed51426706bd | 228 | return MSD_OK; |
38domo | 14:ed51426706bd | 229 | } |
38domo | 14:ed51426706bd | 230 | |
38domo | 14:ed51426706bd | 231 | /** |
38domo | 14:ed51426706bd | 232 | * @brief Detects if SD card is correctly plugged in the memory slot or not. |
38domo | 14:ed51426706bd | 233 | * @retval Returns if SD is detected or not |
38domo | 14:ed51426706bd | 234 | */ |
38domo | 14:ed51426706bd | 235 | uint8_t BSP_SD_IsDetected(void) |
38domo | 14:ed51426706bd | 236 | { |
38domo | 14:ed51426706bd | 237 | __IO uint8_t status = SD_PRESENT; |
38domo | 14:ed51426706bd | 238 | |
38domo | 14:ed51426706bd | 239 | /* Check SD card detect pin */ |
38domo | 14:ed51426706bd | 240 | if (HAL_GPIO_ReadPin(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) == GPIO_PIN_SET) |
38domo | 14:ed51426706bd | 241 | { |
38domo | 14:ed51426706bd | 242 | status = SD_NOT_PRESENT; |
38domo | 14:ed51426706bd | 243 | } |
38domo | 14:ed51426706bd | 244 | |
38domo | 14:ed51426706bd | 245 | return status; |
38domo | 14:ed51426706bd | 246 | } |
38domo | 14:ed51426706bd | 247 | |
38domo | 14:ed51426706bd | 248 | /** |
38domo | 14:ed51426706bd | 249 | * @brief Reads block(s) from a specified address in an SD card, in polling mode. |
38domo | 14:ed51426706bd | 250 | * @param pData: Pointer to the buffer that will contain the data to transmit |
38domo | 14:ed51426706bd | 251 | * @param ReadAddr: Address from where data is to be read |
38domo | 14:ed51426706bd | 252 | * @param BlockSize: SD card data block size, that should be 512 |
38domo | 14:ed51426706bd | 253 | * @param NumOfBlocks: Number of SD blocks to read |
38domo | 14:ed51426706bd | 254 | * @retval SD status |
38domo | 14:ed51426706bd | 255 | */ |
38domo | 14:ed51426706bd | 256 | uint8_t BSP_SD_ReadBlocks(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) |
38domo | 14:ed51426706bd | 257 | { |
38domo | 14:ed51426706bd | 258 | if(HAL_SD_ReadBlocks(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) |
38domo | 14:ed51426706bd | 259 | { |
38domo | 14:ed51426706bd | 260 | return MSD_ERROR; |
38domo | 14:ed51426706bd | 261 | } |
38domo | 14:ed51426706bd | 262 | else |
38domo | 14:ed51426706bd | 263 | { |
38domo | 14:ed51426706bd | 264 | return MSD_OK; |
38domo | 14:ed51426706bd | 265 | } |
38domo | 14:ed51426706bd | 266 | } |
38domo | 14:ed51426706bd | 267 | |
38domo | 14:ed51426706bd | 268 | /** |
38domo | 14:ed51426706bd | 269 | * @brief Writes block(s) to a specified address in an SD card, in polling mode. |
38domo | 14:ed51426706bd | 270 | * @param pData: Pointer to the buffer that will contain the data to transmit |
38domo | 14:ed51426706bd | 271 | * @param WriteAddr: Address from where data is to be written |
38domo | 14:ed51426706bd | 272 | * @param BlockSize: SD card data block size, that should be 512 |
38domo | 14:ed51426706bd | 273 | * @param NumOfBlocks: Number of SD blocks to write |
38domo | 14:ed51426706bd | 274 | * @retval SD status |
38domo | 14:ed51426706bd | 275 | */ |
38domo | 14:ed51426706bd | 276 | uint8_t BSP_SD_WriteBlocks(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) |
38domo | 14:ed51426706bd | 277 | { |
38domo | 14:ed51426706bd | 278 | if(HAL_SD_WriteBlocks(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) |
38domo | 14:ed51426706bd | 279 | { |
38domo | 14:ed51426706bd | 280 | return MSD_ERROR; |
38domo | 14:ed51426706bd | 281 | } |
38domo | 14:ed51426706bd | 282 | else |
38domo | 14:ed51426706bd | 283 | { |
38domo | 14:ed51426706bd | 284 | return MSD_OK; |
38domo | 14:ed51426706bd | 285 | } |
38domo | 14:ed51426706bd | 286 | } |
38domo | 14:ed51426706bd | 287 | |
38domo | 14:ed51426706bd | 288 | /** |
38domo | 14:ed51426706bd | 289 | * @brief Reads block(s) from a specified address in an SD card, in DMA mode. |
38domo | 14:ed51426706bd | 290 | * @param pData: Pointer to the buffer that will contain the data to transmit |
38domo | 14:ed51426706bd | 291 | * @param ReadAddr: Address from where data is to be read |
38domo | 14:ed51426706bd | 292 | * @param BlockSize: SD card data block size, that should be 512 |
38domo | 14:ed51426706bd | 293 | * @param NumOfBlocks: Number of SD blocks to read |
38domo | 14:ed51426706bd | 294 | * @retval SD status |
38domo | 14:ed51426706bd | 295 | */ |
38domo | 14:ed51426706bd | 296 | uint8_t BSP_SD_ReadBlocks_DMA(uint32_t *pData, uint64_t ReadAddr, uint32_t BlockSize, uint32_t NumOfBlocks) |
38domo | 14:ed51426706bd | 297 | { |
38domo | 14:ed51426706bd | 298 | uint8_t sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 299 | |
38domo | 14:ed51426706bd | 300 | /* Read block(s) in DMA transfer mode */ |
38domo | 14:ed51426706bd | 301 | if(HAL_SD_ReadBlocks_DMA(&uSdHandle, pData, ReadAddr, BlockSize, NumOfBlocks) != SD_OK) |
38domo | 14:ed51426706bd | 302 | { |
38domo | 14:ed51426706bd | 303 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 304 | } |
38domo | 14:ed51426706bd | 305 | |
38domo | 14:ed51426706bd | 306 | /* Wait until transfer is complete */ |
38domo | 14:ed51426706bd | 307 | if(sd_state == MSD_OK) |
38domo | 14:ed51426706bd | 308 | { |
38domo | 14:ed51426706bd | 309 | if(HAL_SD_CheckReadOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) |
38domo | 14:ed51426706bd | 310 | { |
38domo | 14:ed51426706bd | 311 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 312 | } |
38domo | 14:ed51426706bd | 313 | else |
38domo | 14:ed51426706bd | 314 | { |
38domo | 14:ed51426706bd | 315 | sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 316 | } |
38domo | 14:ed51426706bd | 317 | } |
38domo | 14:ed51426706bd | 318 | |
38domo | 14:ed51426706bd | 319 | return sd_state; |
38domo | 14:ed51426706bd | 320 | } |
38domo | 14:ed51426706bd | 321 | |
38domo | 14:ed51426706bd | 322 | /** |
38domo | 14:ed51426706bd | 323 | * @brief Writes block(s) to a specified address in an SD card, in DMA mode. |
38domo | 14:ed51426706bd | 324 | * @param pData: Pointer to the buffer that will contain the data to transmit |
38domo | 14:ed51426706bd | 325 | * @param WriteAddr: Address from where data is to be written |
38domo | 14:ed51426706bd | 326 | * @param BlockSize: SD card data block size, that should be 512 |
38domo | 14:ed51426706bd | 327 | * @param NumOfBlocks: Number of SD blocks to write |
38domo | 14:ed51426706bd | 328 | * @retval SD status |
38domo | 14:ed51426706bd | 329 | */ |
38domo | 14:ed51426706bd | 330 | uint8_t BSP_SD_WriteBlocks_DMA(uint32_t *pData, uint64_t WriteAddr, uint32_t BlockSize, uint32_t NumOfBlocks) |
38domo | 14:ed51426706bd | 331 | { |
38domo | 14:ed51426706bd | 332 | uint8_t sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 333 | |
38domo | 14:ed51426706bd | 334 | /* Write block(s) in DMA transfer mode */ |
38domo | 14:ed51426706bd | 335 | if(HAL_SD_WriteBlocks_DMA(&uSdHandle, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) |
38domo | 14:ed51426706bd | 336 | { |
38domo | 14:ed51426706bd | 337 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 338 | } |
38domo | 14:ed51426706bd | 339 | |
38domo | 14:ed51426706bd | 340 | /* Wait until transfer is complete */ |
38domo | 14:ed51426706bd | 341 | if(sd_state == MSD_OK) |
38domo | 14:ed51426706bd | 342 | { |
38domo | 14:ed51426706bd | 343 | if(HAL_SD_CheckWriteOperation(&uSdHandle, (uint32_t)SD_DATATIMEOUT) != SD_OK) |
38domo | 14:ed51426706bd | 344 | { |
38domo | 14:ed51426706bd | 345 | sd_state = MSD_ERROR; |
38domo | 14:ed51426706bd | 346 | } |
38domo | 14:ed51426706bd | 347 | else |
38domo | 14:ed51426706bd | 348 | { |
38domo | 14:ed51426706bd | 349 | sd_state = MSD_OK; |
38domo | 14:ed51426706bd | 350 | } |
38domo | 14:ed51426706bd | 351 | } |
38domo | 14:ed51426706bd | 352 | |
38domo | 14:ed51426706bd | 353 | return sd_state; |
38domo | 14:ed51426706bd | 354 | } |
38domo | 14:ed51426706bd | 355 | |
38domo | 14:ed51426706bd | 356 | /** |
38domo | 14:ed51426706bd | 357 | * @brief Erases the specified memory area of the given SD card. |
38domo | 14:ed51426706bd | 358 | * @param StartAddr: Start byte address |
38domo | 14:ed51426706bd | 359 | * @param EndAddr: End byte address |
38domo | 14:ed51426706bd | 360 | * @retval SD status |
38domo | 14:ed51426706bd | 361 | */ |
38domo | 14:ed51426706bd | 362 | uint8_t BSP_SD_Erase(uint64_t StartAddr, uint64_t EndAddr) |
38domo | 14:ed51426706bd | 363 | { |
38domo | 14:ed51426706bd | 364 | if(HAL_SD_Erase(&uSdHandle, StartAddr, EndAddr) != SD_OK) |
38domo | 14:ed51426706bd | 365 | { |
38domo | 14:ed51426706bd | 366 | return MSD_ERROR; |
38domo | 14:ed51426706bd | 367 | } |
38domo | 14:ed51426706bd | 368 | else |
38domo | 14:ed51426706bd | 369 | { |
38domo | 14:ed51426706bd | 370 | return MSD_OK; |
38domo | 14:ed51426706bd | 371 | } |
38domo | 14:ed51426706bd | 372 | } |
38domo | 14:ed51426706bd | 373 | |
38domo | 14:ed51426706bd | 374 | /** |
38domo | 14:ed51426706bd | 375 | * @brief Initializes the SD MSP. |
38domo | 14:ed51426706bd | 376 | * @param hsd: SD handle |
38domo | 14:ed51426706bd | 377 | * @param Params |
38domo | 14:ed51426706bd | 378 | * @retval None |
38domo | 14:ed51426706bd | 379 | */ |
38domo | 14:ed51426706bd | 380 | __weak void BSP_SD_MspInit(SD_HandleTypeDef *hsd, void *Params) |
38domo | 14:ed51426706bd | 381 | { |
38domo | 14:ed51426706bd | 382 | static DMA_HandleTypeDef dma_rx_handle; |
38domo | 14:ed51426706bd | 383 | static DMA_HandleTypeDef dma_tx_handle; |
38domo | 14:ed51426706bd | 384 | GPIO_InitTypeDef gpio_init_structure; |
38domo | 14:ed51426706bd | 385 | |
38domo | 14:ed51426706bd | 386 | /* Enable SDIO clock */ |
38domo | 14:ed51426706bd | 387 | __HAL_RCC_SDMMC1_CLK_ENABLE(); |
38domo | 14:ed51426706bd | 388 | |
38domo | 14:ed51426706bd | 389 | /* Enable DMA2 clocks */ |
38domo | 14:ed51426706bd | 390 | __DMAx_TxRx_CLK_ENABLE(); |
38domo | 14:ed51426706bd | 391 | |
38domo | 14:ed51426706bd | 392 | /* Enable GPIOs clock */ |
38domo | 14:ed51426706bd | 393 | __HAL_RCC_GPIOC_CLK_ENABLE(); |
38domo | 14:ed51426706bd | 394 | __HAL_RCC_GPIOD_CLK_ENABLE(); |
38domo | 14:ed51426706bd | 395 | |
38domo | 14:ed51426706bd | 396 | /* Common GPIO configuration */ |
38domo | 14:ed51426706bd | 397 | gpio_init_structure.Mode = GPIO_MODE_AF_PP; |
38domo | 14:ed51426706bd | 398 | gpio_init_structure.Pull = GPIO_PULLUP; |
38domo | 14:ed51426706bd | 399 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
38domo | 14:ed51426706bd | 400 | gpio_init_structure.Alternate = GPIO_AF12_SDMMC1; |
38domo | 14:ed51426706bd | 401 | |
38domo | 14:ed51426706bd | 402 | /* GPIOC configuration */ |
38domo | 14:ed51426706bd | 403 | gpio_init_structure.Pin = GPIO_PIN_8 | GPIO_PIN_9 | GPIO_PIN_10 | GPIO_PIN_11 | GPIO_PIN_12; |
38domo | 14:ed51426706bd | 404 | HAL_GPIO_Init(GPIOC, &gpio_init_structure); |
38domo | 14:ed51426706bd | 405 | |
38domo | 14:ed51426706bd | 406 | /* GPIOD configuration */ |
38domo | 14:ed51426706bd | 407 | gpio_init_structure.Pin = GPIO_PIN_2; |
38domo | 14:ed51426706bd | 408 | HAL_GPIO_Init(GPIOD, &gpio_init_structure); |
38domo | 14:ed51426706bd | 409 | |
38domo | 14:ed51426706bd | 410 | /* NVIC configuration for SDIO interrupts */ |
38domo | 14:ed51426706bd | 411 | HAL_NVIC_SetPriority(SDMMC1_IRQn, 5, 0); |
38domo | 14:ed51426706bd | 412 | HAL_NVIC_EnableIRQ(SDMMC1_IRQn); |
38domo | 14:ed51426706bd | 413 | |
38domo | 14:ed51426706bd | 414 | /* Configure DMA Rx parameters */ |
38domo | 14:ed51426706bd | 415 | dma_rx_handle.Init.Channel = SD_DMAx_Rx_CHANNEL; |
38domo | 14:ed51426706bd | 416 | dma_rx_handle.Init.Direction = DMA_PERIPH_TO_MEMORY; |
38domo | 14:ed51426706bd | 417 | dma_rx_handle.Init.PeriphInc = DMA_PINC_DISABLE; |
38domo | 14:ed51426706bd | 418 | dma_rx_handle.Init.MemInc = DMA_MINC_ENABLE; |
38domo | 14:ed51426706bd | 419 | dma_rx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
38domo | 14:ed51426706bd | 420 | dma_rx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
38domo | 14:ed51426706bd | 421 | dma_rx_handle.Init.Mode = DMA_PFCTRL; |
38domo | 14:ed51426706bd | 422 | dma_rx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; |
38domo | 14:ed51426706bd | 423 | dma_rx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; |
38domo | 14:ed51426706bd | 424 | dma_rx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; |
38domo | 14:ed51426706bd | 425 | dma_rx_handle.Init.MemBurst = DMA_MBURST_INC4; |
38domo | 14:ed51426706bd | 426 | dma_rx_handle.Init.PeriphBurst = DMA_PBURST_INC4; |
38domo | 14:ed51426706bd | 427 | |
38domo | 14:ed51426706bd | 428 | dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; |
38domo | 14:ed51426706bd | 429 | |
38domo | 14:ed51426706bd | 430 | /* Associate the DMA handle */ |
38domo | 14:ed51426706bd | 431 | __HAL_LINKDMA(hsd, hdmarx, dma_rx_handle); |
38domo | 14:ed51426706bd | 432 | |
38domo | 14:ed51426706bd | 433 | /* Deinitialize the stream for new transfer */ |
38domo | 14:ed51426706bd | 434 | HAL_DMA_DeInit(&dma_rx_handle); |
38domo | 14:ed51426706bd | 435 | |
38domo | 14:ed51426706bd | 436 | /* Configure the DMA stream */ |
38domo | 14:ed51426706bd | 437 | HAL_DMA_Init(&dma_rx_handle); |
38domo | 14:ed51426706bd | 438 | |
38domo | 14:ed51426706bd | 439 | /* Configure DMA Tx parameters */ |
38domo | 14:ed51426706bd | 440 | dma_tx_handle.Init.Channel = SD_DMAx_Tx_CHANNEL; |
38domo | 14:ed51426706bd | 441 | dma_tx_handle.Init.Direction = DMA_MEMORY_TO_PERIPH; |
38domo | 14:ed51426706bd | 442 | dma_tx_handle.Init.PeriphInc = DMA_PINC_DISABLE; |
38domo | 14:ed51426706bd | 443 | dma_tx_handle.Init.MemInc = DMA_MINC_ENABLE; |
38domo | 14:ed51426706bd | 444 | dma_tx_handle.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; |
38domo | 14:ed51426706bd | 445 | dma_tx_handle.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; |
38domo | 14:ed51426706bd | 446 | dma_tx_handle.Init.Mode = DMA_PFCTRL; |
38domo | 14:ed51426706bd | 447 | dma_tx_handle.Init.Priority = DMA_PRIORITY_VERY_HIGH; |
38domo | 14:ed51426706bd | 448 | dma_tx_handle.Init.FIFOMode = DMA_FIFOMODE_ENABLE; |
38domo | 14:ed51426706bd | 449 | dma_tx_handle.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; |
38domo | 14:ed51426706bd | 450 | dma_tx_handle.Init.MemBurst = DMA_MBURST_INC4; |
38domo | 14:ed51426706bd | 451 | dma_tx_handle.Init.PeriphBurst = DMA_PBURST_INC4; |
38domo | 14:ed51426706bd | 452 | |
38domo | 14:ed51426706bd | 453 | dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; |
38domo | 14:ed51426706bd | 454 | |
38domo | 14:ed51426706bd | 455 | /* Associate the DMA handle */ |
38domo | 14:ed51426706bd | 456 | __HAL_LINKDMA(hsd, hdmatx, dma_tx_handle); |
38domo | 14:ed51426706bd | 457 | |
38domo | 14:ed51426706bd | 458 | /* Deinitialize the stream for new transfer */ |
38domo | 14:ed51426706bd | 459 | HAL_DMA_DeInit(&dma_tx_handle); |
38domo | 14:ed51426706bd | 460 | |
38domo | 14:ed51426706bd | 461 | /* Configure the DMA stream */ |
38domo | 14:ed51426706bd | 462 | HAL_DMA_Init(&dma_tx_handle); |
38domo | 14:ed51426706bd | 463 | |
38domo | 14:ed51426706bd | 464 | /* NVIC configuration for DMA transfer complete interrupt */ |
38domo | 14:ed51426706bd | 465 | HAL_NVIC_SetPriority(SD_DMAx_Rx_IRQn, 6, 0); |
38domo | 14:ed51426706bd | 466 | HAL_NVIC_EnableIRQ(SD_DMAx_Rx_IRQn); |
38domo | 14:ed51426706bd | 467 | |
38domo | 14:ed51426706bd | 468 | /* NVIC configuration for DMA transfer complete interrupt */ |
38domo | 14:ed51426706bd | 469 | HAL_NVIC_SetPriority(SD_DMAx_Tx_IRQn, 6, 0); |
38domo | 14:ed51426706bd | 470 | HAL_NVIC_EnableIRQ(SD_DMAx_Tx_IRQn); |
38domo | 14:ed51426706bd | 471 | } |
38domo | 14:ed51426706bd | 472 | |
38domo | 14:ed51426706bd | 473 | /** |
38domo | 14:ed51426706bd | 474 | * @brief Initializes the SD Detect pin MSP. |
38domo | 14:ed51426706bd | 475 | * @param hsd: SD handle |
38domo | 14:ed51426706bd | 476 | * @param Params |
38domo | 14:ed51426706bd | 477 | * @retval None |
38domo | 14:ed51426706bd | 478 | */ |
38domo | 14:ed51426706bd | 479 | __weak void BSP_SD_Detect_MspInit(SD_HandleTypeDef *hsd, void *Params) |
38domo | 14:ed51426706bd | 480 | { |
38domo | 14:ed51426706bd | 481 | GPIO_InitTypeDef gpio_init_structure; |
38domo | 14:ed51426706bd | 482 | |
38domo | 14:ed51426706bd | 483 | SD_DETECT_GPIO_CLK_ENABLE(); |
38domo | 14:ed51426706bd | 484 | |
38domo | 14:ed51426706bd | 485 | /* GPIO configuration in input for uSD_Detect signal */ |
38domo | 14:ed51426706bd | 486 | gpio_init_structure.Pin = SD_DETECT_PIN; |
38domo | 14:ed51426706bd | 487 | gpio_init_structure.Mode = GPIO_MODE_INPUT; |
38domo | 14:ed51426706bd | 488 | gpio_init_structure.Pull = GPIO_PULLUP; |
38domo | 14:ed51426706bd | 489 | gpio_init_structure.Speed = GPIO_SPEED_HIGH; |
38domo | 14:ed51426706bd | 490 | HAL_GPIO_Init(SD_DETECT_GPIO_PORT, &gpio_init_structure); |
38domo | 14:ed51426706bd | 491 | } |
38domo | 14:ed51426706bd | 492 | |
38domo | 14:ed51426706bd | 493 | /** |
38domo | 14:ed51426706bd | 494 | * @brief DeInitializes the SD MSP. |
38domo | 14:ed51426706bd | 495 | * @param hsd: SD handle |
38domo | 14:ed51426706bd | 496 | * @param Params |
38domo | 14:ed51426706bd | 497 | * @retval None |
38domo | 14:ed51426706bd | 498 | */ |
38domo | 14:ed51426706bd | 499 | __weak void BSP_SD_MspDeInit(SD_HandleTypeDef *hsd, void *Params) |
38domo | 14:ed51426706bd | 500 | { |
38domo | 14:ed51426706bd | 501 | static DMA_HandleTypeDef dma_rx_handle; |
38domo | 14:ed51426706bd | 502 | static DMA_HandleTypeDef dma_tx_handle; |
38domo | 14:ed51426706bd | 503 | |
38domo | 14:ed51426706bd | 504 | /* Disable NVIC for DMA transfer complete interrupts */ |
38domo | 14:ed51426706bd | 505 | HAL_NVIC_DisableIRQ(SD_DMAx_Rx_IRQn); |
38domo | 14:ed51426706bd | 506 | HAL_NVIC_DisableIRQ(SD_DMAx_Tx_IRQn); |
38domo | 14:ed51426706bd | 507 | |
38domo | 14:ed51426706bd | 508 | /* Deinitialize the stream for new transfer */ |
38domo | 14:ed51426706bd | 509 | dma_rx_handle.Instance = SD_DMAx_Rx_STREAM; |
38domo | 14:ed51426706bd | 510 | HAL_DMA_DeInit(&dma_rx_handle); |
38domo | 14:ed51426706bd | 511 | |
38domo | 14:ed51426706bd | 512 | /* Deinitialize the stream for new transfer */ |
38domo | 14:ed51426706bd | 513 | dma_tx_handle.Instance = SD_DMAx_Tx_STREAM; |
38domo | 14:ed51426706bd | 514 | HAL_DMA_DeInit(&dma_tx_handle); |
38domo | 14:ed51426706bd | 515 | |
38domo | 14:ed51426706bd | 516 | /* Disable NVIC for SDIO interrupts */ |
38domo | 14:ed51426706bd | 517 | HAL_NVIC_DisableIRQ(SDMMC1_IRQn); |
38domo | 14:ed51426706bd | 518 | |
38domo | 14:ed51426706bd | 519 | /* DeInit GPIO pins can be done in the application |
38domo | 14:ed51426706bd | 520 | (by surcharging this __weak function) */ |
38domo | 14:ed51426706bd | 521 | |
38domo | 14:ed51426706bd | 522 | /* Disable SDMMC1 clock */ |
38domo | 14:ed51426706bd | 523 | __HAL_RCC_SDMMC1_CLK_DISABLE(); |
38domo | 14:ed51426706bd | 524 | |
38domo | 14:ed51426706bd | 525 | /* GPIO pins clock and DMA clocks can be shut down in the application |
38domo | 14:ed51426706bd | 526 | by surcharging this __weak function */ |
38domo | 14:ed51426706bd | 527 | } |
38domo | 14:ed51426706bd | 528 | |
38domo | 14:ed51426706bd | 529 | /** |
38domo | 14:ed51426706bd | 530 | * @brief Handles SD card interrupt request. |
38domo | 14:ed51426706bd | 531 | * @retval None |
38domo | 14:ed51426706bd | 532 | */ |
38domo | 14:ed51426706bd | 533 | void BSP_SD_IRQHandler(void) |
38domo | 14:ed51426706bd | 534 | { |
38domo | 14:ed51426706bd | 535 | HAL_SD_IRQHandler(&uSdHandle); |
38domo | 14:ed51426706bd | 536 | } |
38domo | 14:ed51426706bd | 537 | |
38domo | 14:ed51426706bd | 538 | /** |
38domo | 14:ed51426706bd | 539 | * @brief Handles SD DMA Tx transfer interrupt request. |
38domo | 14:ed51426706bd | 540 | * @retval None |
38domo | 14:ed51426706bd | 541 | */ |
38domo | 14:ed51426706bd | 542 | void BSP_SD_DMA_Tx_IRQHandler(void) |
38domo | 14:ed51426706bd | 543 | { |
38domo | 14:ed51426706bd | 544 | HAL_DMA_IRQHandler(uSdHandle.hdmatx); |
38domo | 14:ed51426706bd | 545 | } |
38domo | 14:ed51426706bd | 546 | |
38domo | 14:ed51426706bd | 547 | /** |
38domo | 14:ed51426706bd | 548 | * @brief Handles SD DMA Rx transfer interrupt request. |
38domo | 14:ed51426706bd | 549 | * @retval None |
38domo | 14:ed51426706bd | 550 | */ |
38domo | 14:ed51426706bd | 551 | void BSP_SD_DMA_Rx_IRQHandler(void) |
38domo | 14:ed51426706bd | 552 | { |
38domo | 14:ed51426706bd | 553 | HAL_DMA_IRQHandler(uSdHandle.hdmarx); |
38domo | 14:ed51426706bd | 554 | } |
38domo | 14:ed51426706bd | 555 | |
38domo | 14:ed51426706bd | 556 | /** |
38domo | 14:ed51426706bd | 557 | * @brief Gets the current SD card data status. |
38domo | 14:ed51426706bd | 558 | * @retval Data transfer state. |
38domo | 14:ed51426706bd | 559 | * This value can be one of the following values: |
38domo | 14:ed51426706bd | 560 | * @arg SD_TRANSFER_OK: No data transfer is acting |
38domo | 14:ed51426706bd | 561 | * @arg SD_TRANSFER_BUSY: Data transfer is acting |
38domo | 14:ed51426706bd | 562 | * @arg SD_TRANSFER_ERROR: Data transfer error |
38domo | 14:ed51426706bd | 563 | */ |
38domo | 14:ed51426706bd | 564 | HAL_SD_TransferStateTypedef BSP_SD_GetStatus(void) |
38domo | 14:ed51426706bd | 565 | { |
38domo | 14:ed51426706bd | 566 | return(HAL_SD_GetStatus(&uSdHandle)); |
38domo | 14:ed51426706bd | 567 | } |
38domo | 14:ed51426706bd | 568 | |
38domo | 14:ed51426706bd | 569 | /** |
38domo | 14:ed51426706bd | 570 | * @brief Get SD information about specific SD card. |
38domo | 14:ed51426706bd | 571 | * @param CardInfo: Pointer to HAL_SD_CardInfoTypedef structure |
38domo | 14:ed51426706bd | 572 | * @retval None |
38domo | 14:ed51426706bd | 573 | */ |
38domo | 14:ed51426706bd | 574 | void BSP_SD_GetCardInfo(HAL_SD_CardInfoTypedef *CardInfo) |
38domo | 14:ed51426706bd | 575 | { |
38domo | 14:ed51426706bd | 576 | /* Get SD card Information */ |
38domo | 14:ed51426706bd | 577 | HAL_SD_Get_CardInfo(&uSdHandle, CardInfo); |
38domo | 14:ed51426706bd | 578 | } |
38domo | 14:ed51426706bd | 579 | |
38domo | 14:ed51426706bd | 580 | /** |
38domo | 14:ed51426706bd | 581 | * @} |
38domo | 14:ed51426706bd | 582 | */ |
38domo | 14:ed51426706bd | 583 | |
38domo | 14:ed51426706bd | 584 | /** |
38domo | 14:ed51426706bd | 585 | * @} |
38domo | 14:ed51426706bd | 586 | */ |
38domo | 14:ed51426706bd | 587 | |
38domo | 14:ed51426706bd | 588 | /** |
38domo | 14:ed51426706bd | 589 | * @} |
38domo | 14:ed51426706bd | 590 | */ |
38domo | 14:ed51426706bd | 591 | |
38domo | 14:ed51426706bd | 592 | /** |
38domo | 14:ed51426706bd | 593 | * @} |
38domo | 14:ed51426706bd | 594 | */ |
38domo | 14:ed51426706bd | 595 | |
38domo | 14:ed51426706bd | 596 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
38domo | 14:ed51426706bd | 597 |