Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lypinator 0:bb348c97df44 1 /**
lypinator 0:bb348c97df44 2 ******************************************************************************
lypinator 0:bb348c97df44 3 * @file stm32f4xx_ll_sdmmc.c
lypinator 0:bb348c97df44 4 * @author MCD Application Team
lypinator 0:bb348c97df44 5 * @brief SDMMC Low Layer HAL module driver.
lypinator 0:bb348c97df44 6 *
lypinator 0:bb348c97df44 7 * This file provides firmware functions to manage the following
lypinator 0:bb348c97df44 8 * functionalities of the SDMMC peripheral:
lypinator 0:bb348c97df44 9 * + Initialization/de-initialization functions
lypinator 0:bb348c97df44 10 * + I/O operation functions
lypinator 0:bb348c97df44 11 * + Peripheral Control functions
lypinator 0:bb348c97df44 12 * + Peripheral State functions
lypinator 0:bb348c97df44 13 *
lypinator 0:bb348c97df44 14 @verbatim
lypinator 0:bb348c97df44 15 ==============================================================================
lypinator 0:bb348c97df44 16 ##### SDMMC peripheral features #####
lypinator 0:bb348c97df44 17 ==============================================================================
lypinator 0:bb348c97df44 18 [..] The SD/SDMMC MMC card host interface (SDMMC) provides an interface between the APB2
lypinator 0:bb348c97df44 19 peripheral bus and MultiMedia cards (MMCs), SD memory cards, SDMMC cards and CE-ATA
lypinator 0:bb348c97df44 20 devices.
lypinator 0:bb348c97df44 21
lypinator 0:bb348c97df44 22 [..] The SDMMC features include the following:
lypinator 0:bb348c97df44 23 (+) Full compliance with MultiMedia Card System Specification Version 4.2. Card support
lypinator 0:bb348c97df44 24 for three different databus modes: 1-bit (default), 4-bit and 8-bit
lypinator 0:bb348c97df44 25 (+) Full compatibility with previous versions of MultiMedia Cards (forward compatibility)
lypinator 0:bb348c97df44 26 (+) Full compliance with SD Memory Card Specifications Version 2.0
lypinator 0:bb348c97df44 27 (+) Full compliance with SD I/O Card Specification Version 2.0: card support for two
lypinator 0:bb348c97df44 28 different data bus modes: 1-bit (default) and 4-bit
lypinator 0:bb348c97df44 29 (+) Full support of the CE-ATA features (full compliance with CE-ATA digital protocol
lypinator 0:bb348c97df44 30 Rev1.1)
lypinator 0:bb348c97df44 31 (+) Data transfer up to 48 MHz for the 8 bit mode
lypinator 0:bb348c97df44 32 (+) Data and command output enable signals to control external bidirectional drivers.
lypinator 0:bb348c97df44 33
lypinator 0:bb348c97df44 34
lypinator 0:bb348c97df44 35 ##### How to use this driver #####
lypinator 0:bb348c97df44 36 ==============================================================================
lypinator 0:bb348c97df44 37 [..]
lypinator 0:bb348c97df44 38 This driver is a considered as a driver of service for external devices drivers
lypinator 0:bb348c97df44 39 that interfaces with the SDMMC peripheral.
lypinator 0:bb348c97df44 40 According to the device used (SD card/ MMC card / SDMMC card ...), a set of APIs
lypinator 0:bb348c97df44 41 is used in the device's driver to perform SDMMC operations and functionalities.
lypinator 0:bb348c97df44 42
lypinator 0:bb348c97df44 43 This driver is almost transparent for the final user, it is only used to implement other
lypinator 0:bb348c97df44 44 functionalities of the external device.
lypinator 0:bb348c97df44 45
lypinator 0:bb348c97df44 46 [..]
lypinator 0:bb348c97df44 47 (+) The SDMMC clock (SDMMCCLK = 48 MHz) is coming from a specific output of PLL
lypinator 0:bb348c97df44 48 (PLL48CLK). Before start working with SDMMC peripheral make sure that the
lypinator 0:bb348c97df44 49 PLL is well configured.
lypinator 0:bb348c97df44 50 The SDMMC peripheral uses two clock signals:
lypinator 0:bb348c97df44 51 (++) SDMMC adapter clock (SDMMCCLK = 48 MHz)
lypinator 0:bb348c97df44 52 (++) APB2 bus clock (PCLK2)
lypinator 0:bb348c97df44 53
lypinator 0:bb348c97df44 54 -@@- PCLK2 and SDMMC_CK clock frequencies must respect the following condition:
lypinator 0:bb348c97df44 55 Frequency(PCLK2) >= (3 / 8 x Frequency(SDMMC_CK))
lypinator 0:bb348c97df44 56
lypinator 0:bb348c97df44 57 (+) Enable/Disable peripheral clock using RCC peripheral macros related to SDMMC
lypinator 0:bb348c97df44 58 peripheral.
lypinator 0:bb348c97df44 59
lypinator 0:bb348c97df44 60 (+) Enable the Power ON State using the SDIO_PowerState_ON(SDIOx)
lypinator 0:bb348c97df44 61 function and disable it using the function SDIO_PowerState_ON(SDIOx).
lypinator 0:bb348c97df44 62
lypinator 0:bb348c97df44 63 (+) Enable/Disable the clock using the __SDIO_ENABLE()/__SDIO_DISABLE() macros.
lypinator 0:bb348c97df44 64
lypinator 0:bb348c97df44 65 (+) Enable/Disable the peripheral interrupts using the macros __SDIO_ENABLE_IT(hSDIO, IT)
lypinator 0:bb348c97df44 66 and __SDIO_DISABLE_IT(hSDIO, IT) if you need to use interrupt mode.
lypinator 0:bb348c97df44 67
lypinator 0:bb348c97df44 68 (+) When using the DMA mode
lypinator 0:bb348c97df44 69 (++) Configure the DMA in the MSP layer of the external device
lypinator 0:bb348c97df44 70 (++) Active the needed channel Request
lypinator 0:bb348c97df44 71 (++) Enable the DMA using __SDIO_DMA_ENABLE() macro or Disable it using the macro
lypinator 0:bb348c97df44 72 __SDIO_DMA_DISABLE().
lypinator 0:bb348c97df44 73
lypinator 0:bb348c97df44 74 (+) To control the CPSM (Command Path State Machine) and send
lypinator 0:bb348c97df44 75 commands to the card use the SDIO_SendCommand(),
lypinator 0:bb348c97df44 76 SDIO_GetCommandResponse() and SDIO_GetResponse() functions. First, user has
lypinator 0:bb348c97df44 77 to fill the command structure (pointer to SDIO_CmdInitTypeDef) according
lypinator 0:bb348c97df44 78 to the selected command to be sent.
lypinator 0:bb348c97df44 79 The parameters that should be filled are:
lypinator 0:bb348c97df44 80 (++) Command Argument
lypinator 0:bb348c97df44 81 (++) Command Index
lypinator 0:bb348c97df44 82 (++) Command Response type
lypinator 0:bb348c97df44 83 (++) Command Wait
lypinator 0:bb348c97df44 84 (++) CPSM Status (Enable or Disable).
lypinator 0:bb348c97df44 85
lypinator 0:bb348c97df44 86 -@@- To check if the command is well received, read the SDIO_CMDRESP
lypinator 0:bb348c97df44 87 register using the SDIO_GetCommandResponse().
lypinator 0:bb348c97df44 88 The SDMMC responses registers (SDIO_RESP1 to SDIO_RESP2), use the
lypinator 0:bb348c97df44 89 SDIO_GetResponse() function.
lypinator 0:bb348c97df44 90
lypinator 0:bb348c97df44 91 (+) To control the DPSM (Data Path State Machine) and send/receive
lypinator 0:bb348c97df44 92 data to/from the card use the SDIO_ConfigData(), SDIO_GetDataCounter(),
lypinator 0:bb348c97df44 93 SDIO_ReadFIFO(), SDIO_WriteFIFO() and SDIO_GetFIFOCount() functions.
lypinator 0:bb348c97df44 94
lypinator 0:bb348c97df44 95 *** Read Operations ***
lypinator 0:bb348c97df44 96 =======================
lypinator 0:bb348c97df44 97 [..]
lypinator 0:bb348c97df44 98 (#) First, user has to fill the data structure (pointer to
lypinator 0:bb348c97df44 99 SDIO_DataInitTypeDef) according to the selected data type to be received.
lypinator 0:bb348c97df44 100 The parameters that should be filled are:
lypinator 0:bb348c97df44 101 (++) Data TimeOut
lypinator 0:bb348c97df44 102 (++) Data Length
lypinator 0:bb348c97df44 103 (++) Data Block size
lypinator 0:bb348c97df44 104 (++) Data Transfer direction: should be from card (To SDMMC)
lypinator 0:bb348c97df44 105 (++) Data Transfer mode
lypinator 0:bb348c97df44 106 (++) DPSM Status (Enable or Disable)
lypinator 0:bb348c97df44 107
lypinator 0:bb348c97df44 108 (#) Configure the SDMMC resources to receive the data from the card
lypinator 0:bb348c97df44 109 according to selected transfer mode (Refer to Step 8, 9 and 10).
lypinator 0:bb348c97df44 110
lypinator 0:bb348c97df44 111 (#) Send the selected Read command (refer to step 11).
lypinator 0:bb348c97df44 112
lypinator 0:bb348c97df44 113 (#) Use the SDIO flags/interrupts to check the transfer status.
lypinator 0:bb348c97df44 114
lypinator 0:bb348c97df44 115 *** Write Operations ***
lypinator 0:bb348c97df44 116 ========================
lypinator 0:bb348c97df44 117 [..]
lypinator 0:bb348c97df44 118 (#) First, user has to fill the data structure (pointer to
lypinator 0:bb348c97df44 119 SDIO_DataInitTypeDef) according to the selected data type to be received.
lypinator 0:bb348c97df44 120 The parameters that should be filled are:
lypinator 0:bb348c97df44 121 (++) Data TimeOut
lypinator 0:bb348c97df44 122 (++) Data Length
lypinator 0:bb348c97df44 123 (++) Data Block size
lypinator 0:bb348c97df44 124 (++) Data Transfer direction: should be to card (To CARD)
lypinator 0:bb348c97df44 125 (++) Data Transfer mode
lypinator 0:bb348c97df44 126 (++) DPSM Status (Enable or Disable)
lypinator 0:bb348c97df44 127
lypinator 0:bb348c97df44 128 (#) Configure the SDMMC resources to send the data to the card according to
lypinator 0:bb348c97df44 129 selected transfer mode.
lypinator 0:bb348c97df44 130
lypinator 0:bb348c97df44 131 (#) Send the selected Write command.
lypinator 0:bb348c97df44 132
lypinator 0:bb348c97df44 133 (#) Use the SDIO flags/interrupts to check the transfer status.
lypinator 0:bb348c97df44 134
lypinator 0:bb348c97df44 135 *** Command management operations ***
lypinator 0:bb348c97df44 136 =====================================
lypinator 0:bb348c97df44 137 [..]
lypinator 0:bb348c97df44 138 (#) The commands used for Read/Write/Erase operations are managed in
lypinator 0:bb348c97df44 139 separate functions.
lypinator 0:bb348c97df44 140 Each function allows to send the needed command with the related argument,
lypinator 0:bb348c97df44 141 then check the response.
lypinator 0:bb348c97df44 142 By the same approach, you could implement a command and check the response.
lypinator 0:bb348c97df44 143
lypinator 0:bb348c97df44 144 @endverbatim
lypinator 0:bb348c97df44 145 ******************************************************************************
lypinator 0:bb348c97df44 146 * @attention
lypinator 0:bb348c97df44 147 *
lypinator 0:bb348c97df44 148 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
lypinator 0:bb348c97df44 149 *
lypinator 0:bb348c97df44 150 * Redistribution and use in source and binary forms, with or without modification,
lypinator 0:bb348c97df44 151 * are permitted provided that the following conditions are met:
lypinator 0:bb348c97df44 152 * 1. Redistributions of source code must retain the above copyright notice,
lypinator 0:bb348c97df44 153 * this list of conditions and the following disclaimer.
lypinator 0:bb348c97df44 154 * 2. Redistributions in binary form must reproduce the above copyright notice,
lypinator 0:bb348c97df44 155 * this list of conditions and the following disclaimer in the documentation
lypinator 0:bb348c97df44 156 * and/or other materials provided with the distribution.
lypinator 0:bb348c97df44 157 * 3. Neither the name of STMicroelectronics nor the names of its contributors
lypinator 0:bb348c97df44 158 * may be used to endorse or promote products derived from this software
lypinator 0:bb348c97df44 159 * without specific prior written permission.
lypinator 0:bb348c97df44 160 *
lypinator 0:bb348c97df44 161 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
lypinator 0:bb348c97df44 162 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
lypinator 0:bb348c97df44 163 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
lypinator 0:bb348c97df44 164 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
lypinator 0:bb348c97df44 165 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
lypinator 0:bb348c97df44 166 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
lypinator 0:bb348c97df44 167 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
lypinator 0:bb348c97df44 168 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
lypinator 0:bb348c97df44 169 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
lypinator 0:bb348c97df44 170 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
lypinator 0:bb348c97df44 171 *
lypinator 0:bb348c97df44 172 ******************************************************************************
lypinator 0:bb348c97df44 173 */
lypinator 0:bb348c97df44 174
lypinator 0:bb348c97df44 175 /* Includes ------------------------------------------------------------------*/
lypinator 0:bb348c97df44 176 #include "stm32f4xx_hal.h"
lypinator 0:bb348c97df44 177
lypinator 0:bb348c97df44 178 /** @addtogroup STM32F4xx_HAL_Driver
lypinator 0:bb348c97df44 179 * @{
lypinator 0:bb348c97df44 180 */
lypinator 0:bb348c97df44 181
lypinator 0:bb348c97df44 182 /** @defgroup SDMMC_LL SDMMC Low Layer
lypinator 0:bb348c97df44 183 * @brief Low layer module for SD
lypinator 0:bb348c97df44 184 * @{
lypinator 0:bb348c97df44 185 */
lypinator 0:bb348c97df44 186
lypinator 0:bb348c97df44 187 #if defined(HAL_SD_MODULE_ENABLED) || defined(HAL_MMC_MODULE_ENABLED)
lypinator 0:bb348c97df44 188 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
lypinator 0:bb348c97df44 189 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
lypinator 0:bb348c97df44 190 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
lypinator 0:bb348c97df44 191 defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
lypinator 0:bb348c97df44 192 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
lypinator 0:bb348c97df44 193
lypinator 0:bb348c97df44 194 /* Private typedef -----------------------------------------------------------*/
lypinator 0:bb348c97df44 195 /* Private define ------------------------------------------------------------*/
lypinator 0:bb348c97df44 196 /* Private macro -------------------------------------------------------------*/
lypinator 0:bb348c97df44 197 /* Private variables ---------------------------------------------------------*/
lypinator 0:bb348c97df44 198 /* Private function prototypes -----------------------------------------------*/
lypinator 0:bb348c97df44 199 static uint32_t SDMMC_GetCmdError(SDIO_TypeDef *SDIOx);
lypinator 0:bb348c97df44 200 static uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout);
lypinator 0:bb348c97df44 201 static uint32_t SDMMC_GetCmdResp2(SDIO_TypeDef *SDIOx);
lypinator 0:bb348c97df44 202 static uint32_t SDMMC_GetCmdResp3(SDIO_TypeDef *SDIOx);
lypinator 0:bb348c97df44 203 static uint32_t SDMMC_GetCmdResp7(SDIO_TypeDef *SDIOx);
lypinator 0:bb348c97df44 204 static uint32_t SDMMC_GetCmdResp6(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint16_t *pRCA);
lypinator 0:bb348c97df44 205
lypinator 0:bb348c97df44 206 /* Exported functions --------------------------------------------------------*/
lypinator 0:bb348c97df44 207
lypinator 0:bb348c97df44 208 /** @defgroup SDMMC_LL_Exported_Functions SDMMC Low Layer Exported Functions
lypinator 0:bb348c97df44 209 * @{
lypinator 0:bb348c97df44 210 */
lypinator 0:bb348c97df44 211
lypinator 0:bb348c97df44 212 /** @defgroup HAL_SDMMC_LL_Group1 Initialization de-initialization functions
lypinator 0:bb348c97df44 213 * @brief Initialization and Configuration functions
lypinator 0:bb348c97df44 214 *
lypinator 0:bb348c97df44 215 @verbatim
lypinator 0:bb348c97df44 216 ===============================================================================
lypinator 0:bb348c97df44 217 ##### Initialization/de-initialization functions #####
lypinator 0:bb348c97df44 218 ===============================================================================
lypinator 0:bb348c97df44 219 [..] This section provides functions allowing to:
lypinator 0:bb348c97df44 220
lypinator 0:bb348c97df44 221 @endverbatim
lypinator 0:bb348c97df44 222 * @{
lypinator 0:bb348c97df44 223 */
lypinator 0:bb348c97df44 224
lypinator 0:bb348c97df44 225 /**
lypinator 0:bb348c97df44 226 * @brief Initializes the SDMMC according to the specified
lypinator 0:bb348c97df44 227 * parameters in the SDMMC_InitTypeDef and create the associated handle.
lypinator 0:bb348c97df44 228 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 229 * @param Init SDMMC initialization structure
lypinator 0:bb348c97df44 230 * @retval HAL status
lypinator 0:bb348c97df44 231 */
lypinator 0:bb348c97df44 232 HAL_StatusTypeDef SDIO_Init(SDIO_TypeDef *SDIOx, SDIO_InitTypeDef Init)
lypinator 0:bb348c97df44 233 {
lypinator 0:bb348c97df44 234 uint32_t tmpreg = 0U;
lypinator 0:bb348c97df44 235
lypinator 0:bb348c97df44 236 /* Check the parameters */
lypinator 0:bb348c97df44 237 assert_param(IS_SDIO_ALL_INSTANCE(SDIOx));
lypinator 0:bb348c97df44 238 assert_param(IS_SDIO_CLOCK_EDGE(Init.ClockEdge));
lypinator 0:bb348c97df44 239 assert_param(IS_SDIO_CLOCK_BYPASS(Init.ClockBypass));
lypinator 0:bb348c97df44 240 assert_param(IS_SDIO_CLOCK_POWER_SAVE(Init.ClockPowerSave));
lypinator 0:bb348c97df44 241 assert_param(IS_SDIO_BUS_WIDE(Init.BusWide));
lypinator 0:bb348c97df44 242 assert_param(IS_SDIO_HARDWARE_FLOW_CONTROL(Init.HardwareFlowControl));
lypinator 0:bb348c97df44 243 assert_param(IS_SDIO_CLKDIV(Init.ClockDiv));
lypinator 0:bb348c97df44 244
lypinator 0:bb348c97df44 245 /* Set SDMMC configuration parameters */
lypinator 0:bb348c97df44 246 tmpreg |= (Init.ClockEdge |\
lypinator 0:bb348c97df44 247 Init.ClockBypass |\
lypinator 0:bb348c97df44 248 Init.ClockPowerSave |\
lypinator 0:bb348c97df44 249 Init.BusWide |\
lypinator 0:bb348c97df44 250 Init.HardwareFlowControl |\
lypinator 0:bb348c97df44 251 Init.ClockDiv
lypinator 0:bb348c97df44 252 );
lypinator 0:bb348c97df44 253
lypinator 0:bb348c97df44 254 /* Write to SDMMC CLKCR */
lypinator 0:bb348c97df44 255 MODIFY_REG(SDIOx->CLKCR, CLKCR_CLEAR_MASK, tmpreg);
lypinator 0:bb348c97df44 256
lypinator 0:bb348c97df44 257 return HAL_OK;
lypinator 0:bb348c97df44 258 }
lypinator 0:bb348c97df44 259
lypinator 0:bb348c97df44 260
lypinator 0:bb348c97df44 261 /**
lypinator 0:bb348c97df44 262 * @}
lypinator 0:bb348c97df44 263 */
lypinator 0:bb348c97df44 264
lypinator 0:bb348c97df44 265 /** @defgroup HAL_SDMMC_LL_Group2 IO operation functions
lypinator 0:bb348c97df44 266 * @brief Data transfers functions
lypinator 0:bb348c97df44 267 *
lypinator 0:bb348c97df44 268 @verbatim
lypinator 0:bb348c97df44 269 ===============================================================================
lypinator 0:bb348c97df44 270 ##### I/O operation functions #####
lypinator 0:bb348c97df44 271 ===============================================================================
lypinator 0:bb348c97df44 272 [..]
lypinator 0:bb348c97df44 273 This subsection provides a set of functions allowing to manage the SDMMC data
lypinator 0:bb348c97df44 274 transfers.
lypinator 0:bb348c97df44 275
lypinator 0:bb348c97df44 276 @endverbatim
lypinator 0:bb348c97df44 277 * @{
lypinator 0:bb348c97df44 278 */
lypinator 0:bb348c97df44 279
lypinator 0:bb348c97df44 280 /**
lypinator 0:bb348c97df44 281 * @brief Read data (word) from Rx FIFO in blocking mode (polling)
lypinator 0:bb348c97df44 282 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 283 * @retval HAL status
lypinator 0:bb348c97df44 284 */
lypinator 0:bb348c97df44 285 uint32_t SDIO_ReadFIFO(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 286 {
lypinator 0:bb348c97df44 287 /* Read data from Rx FIFO */
lypinator 0:bb348c97df44 288 return (SDIOx->FIFO);
lypinator 0:bb348c97df44 289 }
lypinator 0:bb348c97df44 290
lypinator 0:bb348c97df44 291 /**
lypinator 0:bb348c97df44 292 * @brief Write data (word) to Tx FIFO in blocking mode (polling)
lypinator 0:bb348c97df44 293 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 294 * @param pWriteData pointer to data to write
lypinator 0:bb348c97df44 295 * @retval HAL status
lypinator 0:bb348c97df44 296 */
lypinator 0:bb348c97df44 297 HAL_StatusTypeDef SDIO_WriteFIFO(SDIO_TypeDef *SDIOx, uint32_t *pWriteData)
lypinator 0:bb348c97df44 298 {
lypinator 0:bb348c97df44 299 /* Write data to FIFO */
lypinator 0:bb348c97df44 300 SDIOx->FIFO = *pWriteData;
lypinator 0:bb348c97df44 301
lypinator 0:bb348c97df44 302 return HAL_OK;
lypinator 0:bb348c97df44 303 }
lypinator 0:bb348c97df44 304
lypinator 0:bb348c97df44 305 /**
lypinator 0:bb348c97df44 306 * @}
lypinator 0:bb348c97df44 307 */
lypinator 0:bb348c97df44 308
lypinator 0:bb348c97df44 309 /** @defgroup HAL_SDMMC_LL_Group3 Peripheral Control functions
lypinator 0:bb348c97df44 310 * @brief management functions
lypinator 0:bb348c97df44 311 *
lypinator 0:bb348c97df44 312 @verbatim
lypinator 0:bb348c97df44 313 ===============================================================================
lypinator 0:bb348c97df44 314 ##### Peripheral Control functions #####
lypinator 0:bb348c97df44 315 ===============================================================================
lypinator 0:bb348c97df44 316 [..]
lypinator 0:bb348c97df44 317 This subsection provides a set of functions allowing to control the SDMMC data
lypinator 0:bb348c97df44 318 transfers.
lypinator 0:bb348c97df44 319
lypinator 0:bb348c97df44 320 @endverbatim
lypinator 0:bb348c97df44 321 * @{
lypinator 0:bb348c97df44 322 */
lypinator 0:bb348c97df44 323
lypinator 0:bb348c97df44 324 /**
lypinator 0:bb348c97df44 325 * @brief Set SDMMC Power state to ON.
lypinator 0:bb348c97df44 326 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 327 * @retval HAL status
lypinator 0:bb348c97df44 328 */
lypinator 0:bb348c97df44 329 HAL_StatusTypeDef SDIO_PowerState_ON(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 330 {
lypinator 0:bb348c97df44 331 /* Set power state to ON */
lypinator 0:bb348c97df44 332 SDIOx->POWER = SDIO_POWER_PWRCTRL;
lypinator 0:bb348c97df44 333
lypinator 0:bb348c97df44 334 return HAL_OK;
lypinator 0:bb348c97df44 335 }
lypinator 0:bb348c97df44 336
lypinator 0:bb348c97df44 337 /**
lypinator 0:bb348c97df44 338 * @brief Set SDMMC Power state to OFF.
lypinator 0:bb348c97df44 339 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 340 * @retval HAL status
lypinator 0:bb348c97df44 341 */
lypinator 0:bb348c97df44 342 HAL_StatusTypeDef SDIO_PowerState_OFF(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 343 {
lypinator 0:bb348c97df44 344 /* Set power state to OFF */
lypinator 0:bb348c97df44 345 SDIOx->POWER = 0x00000000U;
lypinator 0:bb348c97df44 346
lypinator 0:bb348c97df44 347 return HAL_OK;
lypinator 0:bb348c97df44 348 }
lypinator 0:bb348c97df44 349
lypinator 0:bb348c97df44 350 /**
lypinator 0:bb348c97df44 351 * @brief Get SDMMC Power state.
lypinator 0:bb348c97df44 352 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 353 * @retval Power status of the controller. The returned value can be one of the
lypinator 0:bb348c97df44 354 * following values:
lypinator 0:bb348c97df44 355 * - 0x00: Power OFF
lypinator 0:bb348c97df44 356 * - 0x02: Power UP
lypinator 0:bb348c97df44 357 * - 0x03: Power ON
lypinator 0:bb348c97df44 358 */
lypinator 0:bb348c97df44 359 uint32_t SDIO_GetPowerState(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 360 {
lypinator 0:bb348c97df44 361 return (SDIOx->POWER & SDIO_POWER_PWRCTRL);
lypinator 0:bb348c97df44 362 }
lypinator 0:bb348c97df44 363
lypinator 0:bb348c97df44 364 /**
lypinator 0:bb348c97df44 365 * @brief Configure the SDMMC command path according to the specified parameters in
lypinator 0:bb348c97df44 366 * SDIO_CmdInitTypeDef structure and send the command
lypinator 0:bb348c97df44 367 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 368 * @param Command pointer to a SDIO_CmdInitTypeDef structure that contains
lypinator 0:bb348c97df44 369 * the configuration information for the SDMMC command
lypinator 0:bb348c97df44 370 * @retval HAL status
lypinator 0:bb348c97df44 371 */
lypinator 0:bb348c97df44 372 HAL_StatusTypeDef SDIO_SendCommand(SDIO_TypeDef *SDIOx, SDIO_CmdInitTypeDef *Command)
lypinator 0:bb348c97df44 373 {
lypinator 0:bb348c97df44 374 uint32_t tmpreg = 0U;
lypinator 0:bb348c97df44 375
lypinator 0:bb348c97df44 376 /* Check the parameters */
lypinator 0:bb348c97df44 377 assert_param(IS_SDIO_CMD_INDEX(Command->CmdIndex));
lypinator 0:bb348c97df44 378 assert_param(IS_SDIO_RESPONSE(Command->Response));
lypinator 0:bb348c97df44 379 assert_param(IS_SDIO_WAIT(Command->WaitForInterrupt));
lypinator 0:bb348c97df44 380 assert_param(IS_SDIO_CPSM(Command->CPSM));
lypinator 0:bb348c97df44 381
lypinator 0:bb348c97df44 382 /* Set the SDMMC Argument value */
lypinator 0:bb348c97df44 383 SDIOx->ARG = Command->Argument;
lypinator 0:bb348c97df44 384
lypinator 0:bb348c97df44 385 /* Set SDMMC command parameters */
lypinator 0:bb348c97df44 386 tmpreg |= (uint32_t)(Command->CmdIndex |\
lypinator 0:bb348c97df44 387 Command->Response |\
lypinator 0:bb348c97df44 388 Command->WaitForInterrupt |\
lypinator 0:bb348c97df44 389 Command->CPSM);
lypinator 0:bb348c97df44 390
lypinator 0:bb348c97df44 391 /* Write to SDMMC CMD register */
lypinator 0:bb348c97df44 392 MODIFY_REG(SDIOx->CMD, CMD_CLEAR_MASK, tmpreg);
lypinator 0:bb348c97df44 393
lypinator 0:bb348c97df44 394 return HAL_OK;
lypinator 0:bb348c97df44 395 }
lypinator 0:bb348c97df44 396
lypinator 0:bb348c97df44 397 /**
lypinator 0:bb348c97df44 398 * @brief Return the command index of last command for which response received
lypinator 0:bb348c97df44 399 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 400 * @retval Command index of the last command response received
lypinator 0:bb348c97df44 401 */
lypinator 0:bb348c97df44 402 uint8_t SDIO_GetCommandResponse(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 403 {
lypinator 0:bb348c97df44 404 return (uint8_t)(SDIOx->RESPCMD);
lypinator 0:bb348c97df44 405 }
lypinator 0:bb348c97df44 406
lypinator 0:bb348c97df44 407
lypinator 0:bb348c97df44 408 /**
lypinator 0:bb348c97df44 409 * @brief Return the response received from the card for the last command
lypinator 0:bb348c97df44 410 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 411 * @param Response Specifies the SDMMC response register.
lypinator 0:bb348c97df44 412 * This parameter can be one of the following values:
lypinator 0:bb348c97df44 413 * @arg SDIO_RESP1: Response Register 1
lypinator 0:bb348c97df44 414 * @arg SDIO_RESP1: Response Register 2
lypinator 0:bb348c97df44 415 * @arg SDIO_RESP1: Response Register 3
lypinator 0:bb348c97df44 416 * @arg SDIO_RESP1: Response Register 4
lypinator 0:bb348c97df44 417 * @retval The Corresponding response register value
lypinator 0:bb348c97df44 418 */
lypinator 0:bb348c97df44 419 uint32_t SDIO_GetResponse(SDIO_TypeDef *SDIOx, uint32_t Response)
lypinator 0:bb348c97df44 420 {
lypinator 0:bb348c97df44 421 __IO uint32_t tmp = 0U;
lypinator 0:bb348c97df44 422
lypinator 0:bb348c97df44 423 /* Check the parameters */
lypinator 0:bb348c97df44 424 assert_param(IS_SDIO_RESP(Response));
lypinator 0:bb348c97df44 425
lypinator 0:bb348c97df44 426 /* Get the response */
lypinator 0:bb348c97df44 427 tmp = (uint32_t)&(SDIOx->RESP1) + Response;
lypinator 0:bb348c97df44 428
lypinator 0:bb348c97df44 429 return (*(__IO uint32_t *) tmp);
lypinator 0:bb348c97df44 430 }
lypinator 0:bb348c97df44 431
lypinator 0:bb348c97df44 432 /**
lypinator 0:bb348c97df44 433 * @brief Configure the SDMMC data path according to the specified
lypinator 0:bb348c97df44 434 * parameters in the SDIO_DataInitTypeDef.
lypinator 0:bb348c97df44 435 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 436 * @param Data pointer to a SDIO_DataInitTypeDef structure
lypinator 0:bb348c97df44 437 * that contains the configuration information for the SDMMC data.
lypinator 0:bb348c97df44 438 * @retval HAL status
lypinator 0:bb348c97df44 439 */
lypinator 0:bb348c97df44 440 HAL_StatusTypeDef SDIO_ConfigData(SDIO_TypeDef *SDIOx, SDIO_DataInitTypeDef* Data)
lypinator 0:bb348c97df44 441 {
lypinator 0:bb348c97df44 442 uint32_t tmpreg = 0U;
lypinator 0:bb348c97df44 443
lypinator 0:bb348c97df44 444 /* Check the parameters */
lypinator 0:bb348c97df44 445 assert_param(IS_SDIO_DATA_LENGTH(Data->DataLength));
lypinator 0:bb348c97df44 446 assert_param(IS_SDIO_BLOCK_SIZE(Data->DataBlockSize));
lypinator 0:bb348c97df44 447 assert_param(IS_SDIO_TRANSFER_DIR(Data->TransferDir));
lypinator 0:bb348c97df44 448 assert_param(IS_SDIO_TRANSFER_MODE(Data->TransferMode));
lypinator 0:bb348c97df44 449 assert_param(IS_SDIO_DPSM(Data->DPSM));
lypinator 0:bb348c97df44 450
lypinator 0:bb348c97df44 451 /* Set the SDMMC Data TimeOut value */
lypinator 0:bb348c97df44 452 SDIOx->DTIMER = Data->DataTimeOut;
lypinator 0:bb348c97df44 453
lypinator 0:bb348c97df44 454 /* Set the SDMMC DataLength value */
lypinator 0:bb348c97df44 455 SDIOx->DLEN = Data->DataLength;
lypinator 0:bb348c97df44 456
lypinator 0:bb348c97df44 457 /* Set the SDMMC data configuration parameters */
lypinator 0:bb348c97df44 458 tmpreg |= (uint32_t)(Data->DataBlockSize |\
lypinator 0:bb348c97df44 459 Data->TransferDir |\
lypinator 0:bb348c97df44 460 Data->TransferMode |\
lypinator 0:bb348c97df44 461 Data->DPSM);
lypinator 0:bb348c97df44 462
lypinator 0:bb348c97df44 463 /* Write to SDMMC DCTRL */
lypinator 0:bb348c97df44 464 MODIFY_REG(SDIOx->DCTRL, DCTRL_CLEAR_MASK, tmpreg);
lypinator 0:bb348c97df44 465
lypinator 0:bb348c97df44 466 return HAL_OK;
lypinator 0:bb348c97df44 467
lypinator 0:bb348c97df44 468 }
lypinator 0:bb348c97df44 469
lypinator 0:bb348c97df44 470 /**
lypinator 0:bb348c97df44 471 * @brief Returns number of remaining data bytes to be transferred.
lypinator 0:bb348c97df44 472 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 473 * @retval Number of remaining data bytes to be transferred
lypinator 0:bb348c97df44 474 */
lypinator 0:bb348c97df44 475 uint32_t SDIO_GetDataCounter(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 476 {
lypinator 0:bb348c97df44 477 return (SDIOx->DCOUNT);
lypinator 0:bb348c97df44 478 }
lypinator 0:bb348c97df44 479
lypinator 0:bb348c97df44 480 /**
lypinator 0:bb348c97df44 481 * @brief Get the FIFO data
lypinator 0:bb348c97df44 482 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 483 * @retval Data received
lypinator 0:bb348c97df44 484 */
lypinator 0:bb348c97df44 485 uint32_t SDIO_GetFIFOCount(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 486 {
lypinator 0:bb348c97df44 487 return (SDIOx->FIFO);
lypinator 0:bb348c97df44 488 }
lypinator 0:bb348c97df44 489
lypinator 0:bb348c97df44 490 /**
lypinator 0:bb348c97df44 491 * @brief Sets one of the two options of inserting read wait interval.
lypinator 0:bb348c97df44 492 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 493 * @param SDIO_ReadWaitMode SDMMC Read Wait operation mode.
lypinator 0:bb348c97df44 494 * This parameter can be:
lypinator 0:bb348c97df44 495 * @arg SDIO_READ_WAIT_MODE_CLK: Read Wait control by stopping SDMMCCLK
lypinator 0:bb348c97df44 496 * @arg SDIO_READ_WAIT_MODE_DATA2: Read Wait control using SDMMC_DATA2
lypinator 0:bb348c97df44 497 * @retval None
lypinator 0:bb348c97df44 498 */
lypinator 0:bb348c97df44 499 HAL_StatusTypeDef SDIO_SetSDMMCReadWaitMode(SDIO_TypeDef *SDIOx, uint32_t SDIO_ReadWaitMode)
lypinator 0:bb348c97df44 500 {
lypinator 0:bb348c97df44 501 /* Check the parameters */
lypinator 0:bb348c97df44 502 assert_param(IS_SDIO_READWAIT_MODE(SDIO_ReadWaitMode));
lypinator 0:bb348c97df44 503
lypinator 0:bb348c97df44 504 /* Set SDMMC read wait mode */
lypinator 0:bb348c97df44 505 MODIFY_REG(SDIOx->DCTRL, SDIO_DCTRL_RWMOD, SDIO_ReadWaitMode);
lypinator 0:bb348c97df44 506
lypinator 0:bb348c97df44 507 return HAL_OK;
lypinator 0:bb348c97df44 508 }
lypinator 0:bb348c97df44 509
lypinator 0:bb348c97df44 510 /**
lypinator 0:bb348c97df44 511 * @}
lypinator 0:bb348c97df44 512 */
lypinator 0:bb348c97df44 513
lypinator 0:bb348c97df44 514
lypinator 0:bb348c97df44 515 /** @defgroup HAL_SDMMC_LL_Group4 Command management functions
lypinator 0:bb348c97df44 516 * @brief Data transfers functions
lypinator 0:bb348c97df44 517 *
lypinator 0:bb348c97df44 518 @verbatim
lypinator 0:bb348c97df44 519 ===============================================================================
lypinator 0:bb348c97df44 520 ##### Commands management functions #####
lypinator 0:bb348c97df44 521 ===============================================================================
lypinator 0:bb348c97df44 522 [..]
lypinator 0:bb348c97df44 523 This subsection provides a set of functions allowing to manage the needed commands.
lypinator 0:bb348c97df44 524
lypinator 0:bb348c97df44 525 @endverbatim
lypinator 0:bb348c97df44 526 * @{
lypinator 0:bb348c97df44 527 */
lypinator 0:bb348c97df44 528
lypinator 0:bb348c97df44 529 /**
lypinator 0:bb348c97df44 530 * @brief Send the Data Block Lenght command and check the response
lypinator 0:bb348c97df44 531 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 532 * @retval HAL status
lypinator 0:bb348c97df44 533 */
lypinator 0:bb348c97df44 534 uint32_t SDMMC_CmdBlockLength(SDIO_TypeDef *SDIOx, uint32_t BlockSize)
lypinator 0:bb348c97df44 535 {
lypinator 0:bb348c97df44 536 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 537 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 538
lypinator 0:bb348c97df44 539 /* Set Block Size for Card */
lypinator 0:bb348c97df44 540 sdmmc_cmdinit.Argument = (uint32_t)BlockSize;
lypinator 0:bb348c97df44 541 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SET_BLOCKLEN;
lypinator 0:bb348c97df44 542 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 543 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 544 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 545 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 546
lypinator 0:bb348c97df44 547 /* Check for error conditions */
lypinator 0:bb348c97df44 548 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SET_BLOCKLEN, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 549
lypinator 0:bb348c97df44 550 return errorstate;
lypinator 0:bb348c97df44 551 }
lypinator 0:bb348c97df44 552
lypinator 0:bb348c97df44 553 /**
lypinator 0:bb348c97df44 554 * @brief Send the Read Single Block command and check the response
lypinator 0:bb348c97df44 555 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 556 * @retval HAL status
lypinator 0:bb348c97df44 557 */
lypinator 0:bb348c97df44 558 uint32_t SDMMC_CmdReadSingleBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd)
lypinator 0:bb348c97df44 559 {
lypinator 0:bb348c97df44 560 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 561 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 562
lypinator 0:bb348c97df44 563 /* Set Block Size for Card */
lypinator 0:bb348c97df44 564 sdmmc_cmdinit.Argument = (uint32_t)ReadAdd;
lypinator 0:bb348c97df44 565 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_READ_SINGLE_BLOCK;
lypinator 0:bb348c97df44 566 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 567 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 568 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 569 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 570
lypinator 0:bb348c97df44 571 /* Check for error conditions */
lypinator 0:bb348c97df44 572 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_READ_SINGLE_BLOCK, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 573
lypinator 0:bb348c97df44 574 return errorstate;
lypinator 0:bb348c97df44 575 }
lypinator 0:bb348c97df44 576
lypinator 0:bb348c97df44 577 /**
lypinator 0:bb348c97df44 578 * @brief Send the Read Multi Block command and check the response
lypinator 0:bb348c97df44 579 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 580 * @retval HAL status
lypinator 0:bb348c97df44 581 */
lypinator 0:bb348c97df44 582 uint32_t SDMMC_CmdReadMultiBlock(SDIO_TypeDef *SDIOx, uint32_t ReadAdd)
lypinator 0:bb348c97df44 583 {
lypinator 0:bb348c97df44 584 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 585 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 586
lypinator 0:bb348c97df44 587 /* Set Block Size for Card */
lypinator 0:bb348c97df44 588 sdmmc_cmdinit.Argument = (uint32_t)ReadAdd;
lypinator 0:bb348c97df44 589 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_READ_MULT_BLOCK;
lypinator 0:bb348c97df44 590 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 591 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 592 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 593 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 594
lypinator 0:bb348c97df44 595 /* Check for error conditions */
lypinator 0:bb348c97df44 596 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_READ_MULT_BLOCK, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 597
lypinator 0:bb348c97df44 598 return errorstate;
lypinator 0:bb348c97df44 599 }
lypinator 0:bb348c97df44 600
lypinator 0:bb348c97df44 601 /**
lypinator 0:bb348c97df44 602 * @brief Send the Write Single Block command and check the response
lypinator 0:bb348c97df44 603 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 604 * @retval HAL status
lypinator 0:bb348c97df44 605 */
lypinator 0:bb348c97df44 606 uint32_t SDMMC_CmdWriteSingleBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd)
lypinator 0:bb348c97df44 607 {
lypinator 0:bb348c97df44 608 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 609 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 610
lypinator 0:bb348c97df44 611 /* Set Block Size for Card */
lypinator 0:bb348c97df44 612 sdmmc_cmdinit.Argument = (uint32_t)WriteAdd;
lypinator 0:bb348c97df44 613 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_WRITE_SINGLE_BLOCK;
lypinator 0:bb348c97df44 614 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 615 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 616 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 617 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 618
lypinator 0:bb348c97df44 619 /* Check for error conditions */
lypinator 0:bb348c97df44 620 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_WRITE_SINGLE_BLOCK, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 621
lypinator 0:bb348c97df44 622 return errorstate;
lypinator 0:bb348c97df44 623 }
lypinator 0:bb348c97df44 624
lypinator 0:bb348c97df44 625 /**
lypinator 0:bb348c97df44 626 * @brief Send the Write Multi Block command and check the response
lypinator 0:bb348c97df44 627 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 628 * @retval HAL status
lypinator 0:bb348c97df44 629 */
lypinator 0:bb348c97df44 630 uint32_t SDMMC_CmdWriteMultiBlock(SDIO_TypeDef *SDIOx, uint32_t WriteAdd)
lypinator 0:bb348c97df44 631 {
lypinator 0:bb348c97df44 632 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 633 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 634
lypinator 0:bb348c97df44 635 /* Set Block Size for Card */
lypinator 0:bb348c97df44 636 sdmmc_cmdinit.Argument = (uint32_t)WriteAdd;
lypinator 0:bb348c97df44 637 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_WRITE_MULT_BLOCK;
lypinator 0:bb348c97df44 638 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 639 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 640 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 641 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 642
lypinator 0:bb348c97df44 643 /* Check for error conditions */
lypinator 0:bb348c97df44 644 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_WRITE_MULT_BLOCK, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 645
lypinator 0:bb348c97df44 646 return errorstate;
lypinator 0:bb348c97df44 647 }
lypinator 0:bb348c97df44 648
lypinator 0:bb348c97df44 649 /**
lypinator 0:bb348c97df44 650 * @brief Send the Start Address Erase command for SD and check the response
lypinator 0:bb348c97df44 651 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 652 * @retval HAL status
lypinator 0:bb348c97df44 653 */
lypinator 0:bb348c97df44 654 uint32_t SDMMC_CmdSDEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd)
lypinator 0:bb348c97df44 655 {
lypinator 0:bb348c97df44 656 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 657 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 658
lypinator 0:bb348c97df44 659 /* Set Block Size for Card */
lypinator 0:bb348c97df44 660 sdmmc_cmdinit.Argument = (uint32_t)StartAdd;
lypinator 0:bb348c97df44 661 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_ERASE_GRP_START;
lypinator 0:bb348c97df44 662 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 663 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 664 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 665 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 666
lypinator 0:bb348c97df44 667 /* Check for error conditions */
lypinator 0:bb348c97df44 668 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_ERASE_GRP_START, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 669
lypinator 0:bb348c97df44 670 return errorstate;
lypinator 0:bb348c97df44 671 }
lypinator 0:bb348c97df44 672
lypinator 0:bb348c97df44 673 /**
lypinator 0:bb348c97df44 674 * @brief Send the End Address Erase command for SD and check the response
lypinator 0:bb348c97df44 675 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 676 * @retval HAL status
lypinator 0:bb348c97df44 677 */
lypinator 0:bb348c97df44 678 uint32_t SDMMC_CmdSDEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd)
lypinator 0:bb348c97df44 679 {
lypinator 0:bb348c97df44 680 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 681 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 682
lypinator 0:bb348c97df44 683 /* Set Block Size for Card */
lypinator 0:bb348c97df44 684 sdmmc_cmdinit.Argument = (uint32_t)EndAdd;
lypinator 0:bb348c97df44 685 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_ERASE_GRP_END;
lypinator 0:bb348c97df44 686 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 687 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 688 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 689 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 690
lypinator 0:bb348c97df44 691 /* Check for error conditions */
lypinator 0:bb348c97df44 692 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_ERASE_GRP_END, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 693
lypinator 0:bb348c97df44 694 return errorstate;
lypinator 0:bb348c97df44 695 }
lypinator 0:bb348c97df44 696
lypinator 0:bb348c97df44 697 /**
lypinator 0:bb348c97df44 698 * @brief Send the Start Address Erase command and check the response
lypinator 0:bb348c97df44 699 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 700 * @retval HAL status
lypinator 0:bb348c97df44 701 */
lypinator 0:bb348c97df44 702 uint32_t SDMMC_CmdEraseStartAdd(SDIO_TypeDef *SDIOx, uint32_t StartAdd)
lypinator 0:bb348c97df44 703 {
lypinator 0:bb348c97df44 704 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 705 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 706
lypinator 0:bb348c97df44 707 /* Set Block Size for Card */
lypinator 0:bb348c97df44 708 sdmmc_cmdinit.Argument = (uint32_t)StartAdd;
lypinator 0:bb348c97df44 709 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE_GRP_START;
lypinator 0:bb348c97df44 710 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 711 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 712 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 713 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 714
lypinator 0:bb348c97df44 715 /* Check for error conditions */
lypinator 0:bb348c97df44 716 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE_GRP_START, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 717
lypinator 0:bb348c97df44 718 return errorstate;
lypinator 0:bb348c97df44 719 }
lypinator 0:bb348c97df44 720
lypinator 0:bb348c97df44 721 /**
lypinator 0:bb348c97df44 722 * @brief Send the End Address Erase command and check the response
lypinator 0:bb348c97df44 723 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 724 * @retval HAL status
lypinator 0:bb348c97df44 725 */
lypinator 0:bb348c97df44 726 uint32_t SDMMC_CmdEraseEndAdd(SDIO_TypeDef *SDIOx, uint32_t EndAdd)
lypinator 0:bb348c97df44 727 {
lypinator 0:bb348c97df44 728 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 729 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 730
lypinator 0:bb348c97df44 731 /* Set Block Size for Card */
lypinator 0:bb348c97df44 732 sdmmc_cmdinit.Argument = (uint32_t)EndAdd;
lypinator 0:bb348c97df44 733 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE_GRP_END;
lypinator 0:bb348c97df44 734 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 735 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 736 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 737 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 738
lypinator 0:bb348c97df44 739 /* Check for error conditions */
lypinator 0:bb348c97df44 740 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE_GRP_END, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 741
lypinator 0:bb348c97df44 742 return errorstate;
lypinator 0:bb348c97df44 743 }
lypinator 0:bb348c97df44 744
lypinator 0:bb348c97df44 745 /**
lypinator 0:bb348c97df44 746 * @brief Send the Erase command and check the response
lypinator 0:bb348c97df44 747 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 748 * @retval HAL status
lypinator 0:bb348c97df44 749 */
lypinator 0:bb348c97df44 750 uint32_t SDMMC_CmdErase(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 751 {
lypinator 0:bb348c97df44 752 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 753 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 754
lypinator 0:bb348c97df44 755 /* Set Block Size for Card */
lypinator 0:bb348c97df44 756 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 757 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ERASE;
lypinator 0:bb348c97df44 758 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 759 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 760 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 761 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 762
lypinator 0:bb348c97df44 763 /* Check for error conditions */
lypinator 0:bb348c97df44 764 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_ERASE, SDIO_MAXERASETIMEOUT);
lypinator 0:bb348c97df44 765
lypinator 0:bb348c97df44 766 return errorstate;
lypinator 0:bb348c97df44 767 }
lypinator 0:bb348c97df44 768
lypinator 0:bb348c97df44 769 /**
lypinator 0:bb348c97df44 770 * @brief Send the Stop Transfer command and check the response.
lypinator 0:bb348c97df44 771 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 772 * @retval HAL status
lypinator 0:bb348c97df44 773 */
lypinator 0:bb348c97df44 774 uint32_t SDMMC_CmdStopTransfer(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 775 {
lypinator 0:bb348c97df44 776 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 777 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 778
lypinator 0:bb348c97df44 779 /* Send CMD12 STOP_TRANSMISSION */
lypinator 0:bb348c97df44 780 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 781 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_STOP_TRANSMISSION;
lypinator 0:bb348c97df44 782 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 783 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 784 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 785 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 786
lypinator 0:bb348c97df44 787 /* Check for error conditions */
lypinator 0:bb348c97df44 788 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_STOP_TRANSMISSION, 100000000U);
lypinator 0:bb348c97df44 789
lypinator 0:bb348c97df44 790 return errorstate;
lypinator 0:bb348c97df44 791 }
lypinator 0:bb348c97df44 792
lypinator 0:bb348c97df44 793 /**
lypinator 0:bb348c97df44 794 * @brief Send the Select Deselect command and check the response.
lypinator 0:bb348c97df44 795 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 796 * @param addr Address of the card to be selected
lypinator 0:bb348c97df44 797 * @retval HAL status
lypinator 0:bb348c97df44 798 */
lypinator 0:bb348c97df44 799 uint32_t SDMMC_CmdSelDesel(SDIO_TypeDef *SDIOx, uint64_t Addr)
lypinator 0:bb348c97df44 800 {
lypinator 0:bb348c97df44 801 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 802 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 803
lypinator 0:bb348c97df44 804 /* Send CMD7 SDMMC_SEL_DESEL_CARD */
lypinator 0:bb348c97df44 805 sdmmc_cmdinit.Argument = (uint32_t)Addr;
lypinator 0:bb348c97df44 806 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEL_DESEL_CARD;
lypinator 0:bb348c97df44 807 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 808 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 809 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 810 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 811
lypinator 0:bb348c97df44 812 /* Check for error conditions */
lypinator 0:bb348c97df44 813 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SEL_DESEL_CARD, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 814
lypinator 0:bb348c97df44 815 return errorstate;
lypinator 0:bb348c97df44 816 }
lypinator 0:bb348c97df44 817
lypinator 0:bb348c97df44 818 /**
lypinator 0:bb348c97df44 819 * @brief Send the Go Idle State command and check the response.
lypinator 0:bb348c97df44 820 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 821 * @retval HAL status
lypinator 0:bb348c97df44 822 */
lypinator 0:bb348c97df44 823 uint32_t SDMMC_CmdGoIdleState(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 824 {
lypinator 0:bb348c97df44 825 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 826 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 827
lypinator 0:bb348c97df44 828 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 829 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_GO_IDLE_STATE;
lypinator 0:bb348c97df44 830 sdmmc_cmdinit.Response = SDIO_RESPONSE_NO;
lypinator 0:bb348c97df44 831 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 832 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 833 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 834
lypinator 0:bb348c97df44 835 /* Check for error conditions */
lypinator 0:bb348c97df44 836 errorstate = SDMMC_GetCmdError(SDIOx);
lypinator 0:bb348c97df44 837
lypinator 0:bb348c97df44 838 return errorstate;
lypinator 0:bb348c97df44 839 }
lypinator 0:bb348c97df44 840
lypinator 0:bb348c97df44 841 /**
lypinator 0:bb348c97df44 842 * @brief Send the Operating Condition command and check the response.
lypinator 0:bb348c97df44 843 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 844 * @retval HAL status
lypinator 0:bb348c97df44 845 */
lypinator 0:bb348c97df44 846 uint32_t SDMMC_CmdOperCond(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 847 {
lypinator 0:bb348c97df44 848 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 849 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 850
lypinator 0:bb348c97df44 851 /* Send CMD8 to verify SD card interface operating condition */
lypinator 0:bb348c97df44 852 /* Argument: - [31:12]: Reserved (shall be set to '0')
lypinator 0:bb348c97df44 853 - [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
lypinator 0:bb348c97df44 854 - [7:0]: Check Pattern (recommended 0xAA) */
lypinator 0:bb348c97df44 855 /* CMD Response: R7 */
lypinator 0:bb348c97df44 856 sdmmc_cmdinit.Argument = SDMMC_CHECK_PATTERN;
lypinator 0:bb348c97df44 857 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_HS_SEND_EXT_CSD;
lypinator 0:bb348c97df44 858 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 859 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 860 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 861 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 862
lypinator 0:bb348c97df44 863 /* Check for error conditions */
lypinator 0:bb348c97df44 864 errorstate = SDMMC_GetCmdResp7(SDIOx);
lypinator 0:bb348c97df44 865
lypinator 0:bb348c97df44 866 return errorstate;
lypinator 0:bb348c97df44 867 }
lypinator 0:bb348c97df44 868
lypinator 0:bb348c97df44 869 /**
lypinator 0:bb348c97df44 870 * @brief Send the Application command to verify that that the next command
lypinator 0:bb348c97df44 871 * is an application specific com-mand rather than a standard command
lypinator 0:bb348c97df44 872 * and check the response.
lypinator 0:bb348c97df44 873 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 874 * @retval HAL status
lypinator 0:bb348c97df44 875 */
lypinator 0:bb348c97df44 876 uint32_t SDMMC_CmdAppCommand(SDIO_TypeDef *SDIOx, uint32_t Argument)
lypinator 0:bb348c97df44 877 {
lypinator 0:bb348c97df44 878 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 879 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 880
lypinator 0:bb348c97df44 881 sdmmc_cmdinit.Argument = (uint32_t)Argument;
lypinator 0:bb348c97df44 882 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_APP_CMD;
lypinator 0:bb348c97df44 883 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 884 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 885 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 886 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 887
lypinator 0:bb348c97df44 888 /* Check for error conditions */
lypinator 0:bb348c97df44 889 /* If there is a HAL_ERROR, it is a MMC card, else
lypinator 0:bb348c97df44 890 it is a SD card: SD card 2.0 (voltage range mismatch)
lypinator 0:bb348c97df44 891 or SD card 1.x */
lypinator 0:bb348c97df44 892 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_APP_CMD, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 893
lypinator 0:bb348c97df44 894 return errorstate;
lypinator 0:bb348c97df44 895 }
lypinator 0:bb348c97df44 896
lypinator 0:bb348c97df44 897 /**
lypinator 0:bb348c97df44 898 * @brief Send the command asking the accessed card to send its operating
lypinator 0:bb348c97df44 899 * condition register (OCR)
lypinator 0:bb348c97df44 900 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 901 * @retval HAL status
lypinator 0:bb348c97df44 902 */
lypinator 0:bb348c97df44 903 uint32_t SDMMC_CmdAppOperCommand(SDIO_TypeDef *SDIOx, uint32_t SdType)
lypinator 0:bb348c97df44 904 {
lypinator 0:bb348c97df44 905 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 906 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 907
lypinator 0:bb348c97df44 908 sdmmc_cmdinit.Argument = SDMMC_VOLTAGE_WINDOW_SD | SdType;
lypinator 0:bb348c97df44 909 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_OP_COND;
lypinator 0:bb348c97df44 910 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 911 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 912 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 913 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 914
lypinator 0:bb348c97df44 915 /* Check for error conditions */
lypinator 0:bb348c97df44 916 errorstate = SDMMC_GetCmdResp3(SDIOx);
lypinator 0:bb348c97df44 917
lypinator 0:bb348c97df44 918 return errorstate;
lypinator 0:bb348c97df44 919 }
lypinator 0:bb348c97df44 920
lypinator 0:bb348c97df44 921 /**
lypinator 0:bb348c97df44 922 * @brief Send the Bus Width command and check the response.
lypinator 0:bb348c97df44 923 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 924 * @retval HAL status
lypinator 0:bb348c97df44 925 */
lypinator 0:bb348c97df44 926 uint32_t SDMMC_CmdBusWidth(SDIO_TypeDef *SDIOx, uint32_t BusWidth)
lypinator 0:bb348c97df44 927 {
lypinator 0:bb348c97df44 928 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 929 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 930
lypinator 0:bb348c97df44 931 sdmmc_cmdinit.Argument = (uint32_t)BusWidth;
lypinator 0:bb348c97df44 932 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_APP_SD_SET_BUSWIDTH;
lypinator 0:bb348c97df44 933 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 934 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 935 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 936 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 937
lypinator 0:bb348c97df44 938 /* Check for error conditions */
lypinator 0:bb348c97df44 939 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_APP_SD_SET_BUSWIDTH, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 940
lypinator 0:bb348c97df44 941 return errorstate;
lypinator 0:bb348c97df44 942 }
lypinator 0:bb348c97df44 943
lypinator 0:bb348c97df44 944 /**
lypinator 0:bb348c97df44 945 * @brief Send the Send SCR command and check the response.
lypinator 0:bb348c97df44 946 * @param SDIOx Pointer to SDMMC register base
lypinator 0:bb348c97df44 947 * @retval HAL status
lypinator 0:bb348c97df44 948 */
lypinator 0:bb348c97df44 949 uint32_t SDMMC_CmdSendSCR(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 950 {
lypinator 0:bb348c97df44 951 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 952 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 953
lypinator 0:bb348c97df44 954 /* Send CMD51 SD_APP_SEND_SCR */
lypinator 0:bb348c97df44 955 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 956 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_SEND_SCR;
lypinator 0:bb348c97df44 957 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 958 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 959 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 960 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 961
lypinator 0:bb348c97df44 962 /* Check for error conditions */
lypinator 0:bb348c97df44 963 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_APP_SEND_SCR, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 964
lypinator 0:bb348c97df44 965 return errorstate;
lypinator 0:bb348c97df44 966 }
lypinator 0:bb348c97df44 967
lypinator 0:bb348c97df44 968 /**
lypinator 0:bb348c97df44 969 * @brief Send the Send CID command and check the response.
lypinator 0:bb348c97df44 970 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 971 * @retval HAL status
lypinator 0:bb348c97df44 972 */
lypinator 0:bb348c97df44 973 uint32_t SDMMC_CmdSendCID(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 974 {
lypinator 0:bb348c97df44 975 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 976 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 977
lypinator 0:bb348c97df44 978 /* Send CMD2 ALL_SEND_CID */
lypinator 0:bb348c97df44 979 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 980 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_ALL_SEND_CID;
lypinator 0:bb348c97df44 981 sdmmc_cmdinit.Response = SDIO_RESPONSE_LONG;
lypinator 0:bb348c97df44 982 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 983 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 984 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 985
lypinator 0:bb348c97df44 986 /* Check for error conditions */
lypinator 0:bb348c97df44 987 errorstate = SDMMC_GetCmdResp2(SDIOx);
lypinator 0:bb348c97df44 988
lypinator 0:bb348c97df44 989 return errorstate;
lypinator 0:bb348c97df44 990 }
lypinator 0:bb348c97df44 991
lypinator 0:bb348c97df44 992 /**
lypinator 0:bb348c97df44 993 * @brief Send the Send CSD command and check the response.
lypinator 0:bb348c97df44 994 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 995 * @retval HAL status
lypinator 0:bb348c97df44 996 */
lypinator 0:bb348c97df44 997 uint32_t SDMMC_CmdSendCSD(SDIO_TypeDef *SDIOx, uint32_t Argument)
lypinator 0:bb348c97df44 998 {
lypinator 0:bb348c97df44 999 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1000 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1001
lypinator 0:bb348c97df44 1002 /* Send CMD9 SEND_CSD */
lypinator 0:bb348c97df44 1003 sdmmc_cmdinit.Argument = (uint32_t)Argument;
lypinator 0:bb348c97df44 1004 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_CSD;
lypinator 0:bb348c97df44 1005 sdmmc_cmdinit.Response = SDIO_RESPONSE_LONG;
lypinator 0:bb348c97df44 1006 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1007 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1008 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1009
lypinator 0:bb348c97df44 1010 /* Check for error conditions */
lypinator 0:bb348c97df44 1011 errorstate = SDMMC_GetCmdResp2(SDIOx);
lypinator 0:bb348c97df44 1012
lypinator 0:bb348c97df44 1013 return errorstate;
lypinator 0:bb348c97df44 1014 }
lypinator 0:bb348c97df44 1015
lypinator 0:bb348c97df44 1016 /**
lypinator 0:bb348c97df44 1017 * @brief Send the Send CSD command and check the response.
lypinator 0:bb348c97df44 1018 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 1019 * @retval HAL status
lypinator 0:bb348c97df44 1020 */
lypinator 0:bb348c97df44 1021 uint32_t SDMMC_CmdSetRelAdd(SDIO_TypeDef *SDIOx, uint16_t *pRCA)
lypinator 0:bb348c97df44 1022 {
lypinator 0:bb348c97df44 1023 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1024 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1025
lypinator 0:bb348c97df44 1026 /* Send CMD3 SD_CMD_SET_REL_ADDR */
lypinator 0:bb348c97df44 1027 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 1028 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SET_REL_ADDR;
lypinator 0:bb348c97df44 1029 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 1030 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1031 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1032 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1033
lypinator 0:bb348c97df44 1034 /* Check for error conditions */
lypinator 0:bb348c97df44 1035 errorstate = SDMMC_GetCmdResp6(SDIOx, SDMMC_CMD_SET_REL_ADDR, pRCA);
lypinator 0:bb348c97df44 1036
lypinator 0:bb348c97df44 1037 return errorstate;
lypinator 0:bb348c97df44 1038 }
lypinator 0:bb348c97df44 1039
lypinator 0:bb348c97df44 1040 /**
lypinator 0:bb348c97df44 1041 * @brief Send the Status command and check the response.
lypinator 0:bb348c97df44 1042 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 1043 * @retval HAL status
lypinator 0:bb348c97df44 1044 */
lypinator 0:bb348c97df44 1045 uint32_t SDMMC_CmdSendStatus(SDIO_TypeDef *SDIOx, uint32_t Argument)
lypinator 0:bb348c97df44 1046 {
lypinator 0:bb348c97df44 1047 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1048 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1049
lypinator 0:bb348c97df44 1050 sdmmc_cmdinit.Argument = (uint32_t)Argument;
lypinator 0:bb348c97df44 1051 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_STATUS;
lypinator 0:bb348c97df44 1052 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 1053 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1054 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1055 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1056
lypinator 0:bb348c97df44 1057 /* Check for error conditions */
lypinator 0:bb348c97df44 1058 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SEND_STATUS, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 1059
lypinator 0:bb348c97df44 1060 return errorstate;
lypinator 0:bb348c97df44 1061 }
lypinator 0:bb348c97df44 1062
lypinator 0:bb348c97df44 1063 /**
lypinator 0:bb348c97df44 1064 * @brief Send the Status register command and check the response.
lypinator 0:bb348c97df44 1065 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 1066 * @retval HAL status
lypinator 0:bb348c97df44 1067 */
lypinator 0:bb348c97df44 1068 uint32_t SDMMC_CmdStatusRegister(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 1069 {
lypinator 0:bb348c97df44 1070 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1071 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1072
lypinator 0:bb348c97df44 1073 sdmmc_cmdinit.Argument = 0U;
lypinator 0:bb348c97df44 1074 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SD_APP_STATUS;
lypinator 0:bb348c97df44 1075 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 1076 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1077 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1078 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1079
lypinator 0:bb348c97df44 1080 /* Check for error conditions */
lypinator 0:bb348c97df44 1081 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_SD_APP_STATUS, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 1082
lypinator 0:bb348c97df44 1083 return errorstate;
lypinator 0:bb348c97df44 1084 }
lypinator 0:bb348c97df44 1085
lypinator 0:bb348c97df44 1086 /**
lypinator 0:bb348c97df44 1087 * @brief Sends host capacity support information and activates the card's
lypinator 0:bb348c97df44 1088 * initialization process. Send SDMMC_CMD_SEND_OP_COND command
lypinator 0:bb348c97df44 1089 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 1090 * @parame Argument Argument used for the command
lypinator 0:bb348c97df44 1091 * @retval HAL status
lypinator 0:bb348c97df44 1092 */
lypinator 0:bb348c97df44 1093 uint32_t SDMMC_CmdOpCondition(SDIO_TypeDef *SDIOx, uint32_t Argument)
lypinator 0:bb348c97df44 1094 {
lypinator 0:bb348c97df44 1095 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1096 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1097
lypinator 0:bb348c97df44 1098 sdmmc_cmdinit.Argument = Argument;
lypinator 0:bb348c97df44 1099 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_SEND_OP_COND;
lypinator 0:bb348c97df44 1100 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 1101 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1102 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1103 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1104
lypinator 0:bb348c97df44 1105 /* Check for error conditions */
lypinator 0:bb348c97df44 1106 errorstate = SDMMC_GetCmdResp3(SDIOx);
lypinator 0:bb348c97df44 1107
lypinator 0:bb348c97df44 1108 return errorstate;
lypinator 0:bb348c97df44 1109 }
lypinator 0:bb348c97df44 1110
lypinator 0:bb348c97df44 1111 /**
lypinator 0:bb348c97df44 1112 * @brief Checks switchable function and switch card function. SDMMC_CMD_HS_SWITCH comand
lypinator 0:bb348c97df44 1113 * @param SDIOx Pointer to SDIO register base
lypinator 0:bb348c97df44 1114 * @parame Argument Argument used for the command
lypinator 0:bb348c97df44 1115 * @retval HAL status
lypinator 0:bb348c97df44 1116 */
lypinator 0:bb348c97df44 1117 uint32_t SDMMC_CmdSwitch(SDIO_TypeDef *SDIOx, uint32_t Argument)
lypinator 0:bb348c97df44 1118 {
lypinator 0:bb348c97df44 1119 SDIO_CmdInitTypeDef sdmmc_cmdinit;
lypinator 0:bb348c97df44 1120 uint32_t errorstate = SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1121
lypinator 0:bb348c97df44 1122 sdmmc_cmdinit.Argument = Argument;
lypinator 0:bb348c97df44 1123 sdmmc_cmdinit.CmdIndex = SDMMC_CMD_HS_SWITCH;
lypinator 0:bb348c97df44 1124 sdmmc_cmdinit.Response = SDIO_RESPONSE_SHORT;
lypinator 0:bb348c97df44 1125 sdmmc_cmdinit.WaitForInterrupt = SDIO_WAIT_NO;
lypinator 0:bb348c97df44 1126 sdmmc_cmdinit.CPSM = SDIO_CPSM_ENABLE;
lypinator 0:bb348c97df44 1127 SDIO_SendCommand(SDIOx, &sdmmc_cmdinit);
lypinator 0:bb348c97df44 1128
lypinator 0:bb348c97df44 1129 /* Check for error conditions */
lypinator 0:bb348c97df44 1130 errorstate = SDMMC_GetCmdResp1(SDIOx, SDMMC_CMD_HS_SWITCH, SDIO_CMDTIMEOUT);
lypinator 0:bb348c97df44 1131
lypinator 0:bb348c97df44 1132 return errorstate;
lypinator 0:bb348c97df44 1133 }
lypinator 0:bb348c97df44 1134
lypinator 0:bb348c97df44 1135 /**
lypinator 0:bb348c97df44 1136 * @}
lypinator 0:bb348c97df44 1137 */
lypinator 0:bb348c97df44 1138
lypinator 0:bb348c97df44 1139 /* Private function ----------------------------------------------------------*/
lypinator 0:bb348c97df44 1140 /** @addtogroup SD_Private_Functions
lypinator 0:bb348c97df44 1141 * @{
lypinator 0:bb348c97df44 1142 */
lypinator 0:bb348c97df44 1143
lypinator 0:bb348c97df44 1144 /**
lypinator 0:bb348c97df44 1145 * @brief Checks for error conditions for CMD0.
lypinator 0:bb348c97df44 1146 * @param hsd SD handle
lypinator 0:bb348c97df44 1147 * @retval SD Card error state
lypinator 0:bb348c97df44 1148 */
lypinator 0:bb348c97df44 1149 static uint32_t SDMMC_GetCmdError(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 1150 {
lypinator 0:bb348c97df44 1151 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1152 The SDMMC_CMDTIMEOUT is expressed in ms */
lypinator 0:bb348c97df44 1153 register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1154
lypinator 0:bb348c97df44 1155 do
lypinator 0:bb348c97df44 1156 {
lypinator 0:bb348c97df44 1157 if (count-- == 0U)
lypinator 0:bb348c97df44 1158 {
lypinator 0:bb348c97df44 1159 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1160 }
lypinator 0:bb348c97df44 1161
lypinator 0:bb348c97df44 1162 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CMDSENT));
lypinator 0:bb348c97df44 1163
lypinator 0:bb348c97df44 1164 /* Clear all the static flags */
lypinator 0:bb348c97df44 1165 __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_FLAGS);
lypinator 0:bb348c97df44 1166
lypinator 0:bb348c97df44 1167 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1168 }
lypinator 0:bb348c97df44 1169
lypinator 0:bb348c97df44 1170 /**
lypinator 0:bb348c97df44 1171 * @brief Checks for error conditions for R1 response.
lypinator 0:bb348c97df44 1172 * @param hsd SD handle
lypinator 0:bb348c97df44 1173 * @param SD_CMD The sent command index
lypinator 0:bb348c97df44 1174 * @retval SD Card error state
lypinator 0:bb348c97df44 1175 */
lypinator 0:bb348c97df44 1176 static uint32_t SDMMC_GetCmdResp1(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint32_t Timeout)
lypinator 0:bb348c97df44 1177 {
lypinator 0:bb348c97df44 1178 uint32_t response_r1;
lypinator 0:bb348c97df44 1179
lypinator 0:bb348c97df44 1180 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1181 The Timeout is expressed in ms */
lypinator 0:bb348c97df44 1182 register uint32_t count = Timeout * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1183
lypinator 0:bb348c97df44 1184 do
lypinator 0:bb348c97df44 1185 {
lypinator 0:bb348c97df44 1186 if (count-- == 0U)
lypinator 0:bb348c97df44 1187 {
lypinator 0:bb348c97df44 1188 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1189 }
lypinator 0:bb348c97df44 1190
lypinator 0:bb348c97df44 1191 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT));
lypinator 0:bb348c97df44 1192
lypinator 0:bb348c97df44 1193 if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT))
lypinator 0:bb348c97df44 1194 {
lypinator 0:bb348c97df44 1195 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT);
lypinator 0:bb348c97df44 1196
lypinator 0:bb348c97df44 1197 return SDMMC_ERROR_CMD_RSP_TIMEOUT;
lypinator 0:bb348c97df44 1198 }
lypinator 0:bb348c97df44 1199 else if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL))
lypinator 0:bb348c97df44 1200 {
lypinator 0:bb348c97df44 1201 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL);
lypinator 0:bb348c97df44 1202
lypinator 0:bb348c97df44 1203 return SDMMC_ERROR_CMD_CRC_FAIL;
lypinator 0:bb348c97df44 1204 }
lypinator 0:bb348c97df44 1205
lypinator 0:bb348c97df44 1206 /* Check response received is of desired command */
lypinator 0:bb348c97df44 1207 if(SDIO_GetCommandResponse(SDIOx) != SD_CMD)
lypinator 0:bb348c97df44 1208 {
lypinator 0:bb348c97df44 1209 return SDMMC_ERROR_CMD_CRC_FAIL;
lypinator 0:bb348c97df44 1210 }
lypinator 0:bb348c97df44 1211
lypinator 0:bb348c97df44 1212 /* Clear all the static flags */
lypinator 0:bb348c97df44 1213 __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_FLAGS);
lypinator 0:bb348c97df44 1214
lypinator 0:bb348c97df44 1215 /* We have received response, retrieve it for analysis */
lypinator 0:bb348c97df44 1216 response_r1 = SDIO_GetResponse(SDIOx, SDIO_RESP1);
lypinator 0:bb348c97df44 1217
lypinator 0:bb348c97df44 1218 if((response_r1 & SDMMC_OCR_ERRORBITS) == SDMMC_ALLZERO)
lypinator 0:bb348c97df44 1219 {
lypinator 0:bb348c97df44 1220 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1221 }
lypinator 0:bb348c97df44 1222 else if((response_r1 & SDMMC_OCR_ADDR_OUT_OF_RANGE) == SDMMC_OCR_ADDR_OUT_OF_RANGE)
lypinator 0:bb348c97df44 1223 {
lypinator 0:bb348c97df44 1224 return SDMMC_ERROR_ADDR_OUT_OF_RANGE;
lypinator 0:bb348c97df44 1225 }
lypinator 0:bb348c97df44 1226 else if((response_r1 & SDMMC_OCR_ADDR_MISALIGNED) == SDMMC_OCR_ADDR_MISALIGNED)
lypinator 0:bb348c97df44 1227 {
lypinator 0:bb348c97df44 1228 return SDMMC_ERROR_ADDR_MISALIGNED;
lypinator 0:bb348c97df44 1229 }
lypinator 0:bb348c97df44 1230 else if((response_r1 & SDMMC_OCR_BLOCK_LEN_ERR) == SDMMC_OCR_BLOCK_LEN_ERR)
lypinator 0:bb348c97df44 1231 {
lypinator 0:bb348c97df44 1232 return SDMMC_ERROR_BLOCK_LEN_ERR;
lypinator 0:bb348c97df44 1233 }
lypinator 0:bb348c97df44 1234 else if((response_r1 & SDMMC_OCR_ERASE_SEQ_ERR) == SDMMC_OCR_ERASE_SEQ_ERR)
lypinator 0:bb348c97df44 1235 {
lypinator 0:bb348c97df44 1236 return SDMMC_ERROR_ERASE_SEQ_ERR;
lypinator 0:bb348c97df44 1237 }
lypinator 0:bb348c97df44 1238 else if((response_r1 & SDMMC_OCR_BAD_ERASE_PARAM) == SDMMC_OCR_BAD_ERASE_PARAM)
lypinator 0:bb348c97df44 1239 {
lypinator 0:bb348c97df44 1240 return SDMMC_ERROR_BAD_ERASE_PARAM;
lypinator 0:bb348c97df44 1241 }
lypinator 0:bb348c97df44 1242 else if((response_r1 & SDMMC_OCR_WRITE_PROT_VIOLATION) == SDMMC_OCR_WRITE_PROT_VIOLATION)
lypinator 0:bb348c97df44 1243 {
lypinator 0:bb348c97df44 1244 return SDMMC_ERROR_WRITE_PROT_VIOLATION;
lypinator 0:bb348c97df44 1245 }
lypinator 0:bb348c97df44 1246 else if((response_r1 & SDMMC_OCR_LOCK_UNLOCK_FAILED) == SDMMC_OCR_LOCK_UNLOCK_FAILED)
lypinator 0:bb348c97df44 1247 {
lypinator 0:bb348c97df44 1248 return SDMMC_ERROR_LOCK_UNLOCK_FAILED;
lypinator 0:bb348c97df44 1249 }
lypinator 0:bb348c97df44 1250 else if((response_r1 & SDMMC_OCR_COM_CRC_FAILED) == SDMMC_OCR_COM_CRC_FAILED)
lypinator 0:bb348c97df44 1251 {
lypinator 0:bb348c97df44 1252 return SDMMC_ERROR_COM_CRC_FAILED;
lypinator 0:bb348c97df44 1253 }
lypinator 0:bb348c97df44 1254 else if((response_r1 & SDMMC_OCR_ILLEGAL_CMD) == SDMMC_OCR_ILLEGAL_CMD)
lypinator 0:bb348c97df44 1255 {
lypinator 0:bb348c97df44 1256 return SDMMC_ERROR_ILLEGAL_CMD;
lypinator 0:bb348c97df44 1257 }
lypinator 0:bb348c97df44 1258 else if((response_r1 & SDMMC_OCR_CARD_ECC_FAILED) == SDMMC_OCR_CARD_ECC_FAILED)
lypinator 0:bb348c97df44 1259 {
lypinator 0:bb348c97df44 1260 return SDMMC_ERROR_CARD_ECC_FAILED;
lypinator 0:bb348c97df44 1261 }
lypinator 0:bb348c97df44 1262 else if((response_r1 & SDMMC_OCR_CC_ERROR) == SDMMC_OCR_CC_ERROR)
lypinator 0:bb348c97df44 1263 {
lypinator 0:bb348c97df44 1264 return SDMMC_ERROR_CC_ERR;
lypinator 0:bb348c97df44 1265 }
lypinator 0:bb348c97df44 1266 else if((response_r1 & SDMMC_OCR_STREAM_READ_UNDERRUN) == SDMMC_OCR_STREAM_READ_UNDERRUN)
lypinator 0:bb348c97df44 1267 {
lypinator 0:bb348c97df44 1268 return SDMMC_ERROR_STREAM_READ_UNDERRUN;
lypinator 0:bb348c97df44 1269 }
lypinator 0:bb348c97df44 1270 else if((response_r1 & SDMMC_OCR_STREAM_WRITE_OVERRUN) == SDMMC_OCR_STREAM_WRITE_OVERRUN)
lypinator 0:bb348c97df44 1271 {
lypinator 0:bb348c97df44 1272 return SDMMC_ERROR_STREAM_WRITE_OVERRUN;
lypinator 0:bb348c97df44 1273 }
lypinator 0:bb348c97df44 1274 else if((response_r1 & SDMMC_OCR_CID_CSD_OVERWRITE) == SDMMC_OCR_CID_CSD_OVERWRITE)
lypinator 0:bb348c97df44 1275 {
lypinator 0:bb348c97df44 1276 return SDMMC_ERROR_CID_CSD_OVERWRITE;
lypinator 0:bb348c97df44 1277 }
lypinator 0:bb348c97df44 1278 else if((response_r1 & SDMMC_OCR_WP_ERASE_SKIP) == SDMMC_OCR_WP_ERASE_SKIP)
lypinator 0:bb348c97df44 1279 {
lypinator 0:bb348c97df44 1280 return SDMMC_ERROR_WP_ERASE_SKIP;
lypinator 0:bb348c97df44 1281 }
lypinator 0:bb348c97df44 1282 else if((response_r1 & SDMMC_OCR_CARD_ECC_DISABLED) == SDMMC_OCR_CARD_ECC_DISABLED)
lypinator 0:bb348c97df44 1283 {
lypinator 0:bb348c97df44 1284 return SDMMC_ERROR_CARD_ECC_DISABLED;
lypinator 0:bb348c97df44 1285 }
lypinator 0:bb348c97df44 1286 else if((response_r1 & SDMMC_OCR_ERASE_RESET) == SDMMC_OCR_ERASE_RESET)
lypinator 0:bb348c97df44 1287 {
lypinator 0:bb348c97df44 1288 return SDMMC_ERROR_ERASE_RESET;
lypinator 0:bb348c97df44 1289 }
lypinator 0:bb348c97df44 1290 else if((response_r1 & SDMMC_OCR_AKE_SEQ_ERROR) == SDMMC_OCR_AKE_SEQ_ERROR)
lypinator 0:bb348c97df44 1291 {
lypinator 0:bb348c97df44 1292 return SDMMC_ERROR_AKE_SEQ_ERR;
lypinator 0:bb348c97df44 1293 }
lypinator 0:bb348c97df44 1294 else
lypinator 0:bb348c97df44 1295 {
lypinator 0:bb348c97df44 1296 return SDMMC_ERROR_GENERAL_UNKNOWN_ERR;
lypinator 0:bb348c97df44 1297 }
lypinator 0:bb348c97df44 1298 }
lypinator 0:bb348c97df44 1299
lypinator 0:bb348c97df44 1300 /**
lypinator 0:bb348c97df44 1301 * @brief Checks for error conditions for R2 (CID or CSD) response.
lypinator 0:bb348c97df44 1302 * @param hsd SD handle
lypinator 0:bb348c97df44 1303 * @retval SD Card error state
lypinator 0:bb348c97df44 1304 */
lypinator 0:bb348c97df44 1305 static uint32_t SDMMC_GetCmdResp2(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 1306 {
lypinator 0:bb348c97df44 1307 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1308 The SDMMC_CMDTIMEOUT is expressed in ms */
lypinator 0:bb348c97df44 1309 register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1310
lypinator 0:bb348c97df44 1311 do
lypinator 0:bb348c97df44 1312 {
lypinator 0:bb348c97df44 1313 if (count-- == 0U)
lypinator 0:bb348c97df44 1314 {
lypinator 0:bb348c97df44 1315 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1316 }
lypinator 0:bb348c97df44 1317
lypinator 0:bb348c97df44 1318 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT));
lypinator 0:bb348c97df44 1319
lypinator 0:bb348c97df44 1320 if (__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT))
lypinator 0:bb348c97df44 1321 {
lypinator 0:bb348c97df44 1322 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT);
lypinator 0:bb348c97df44 1323
lypinator 0:bb348c97df44 1324 return SDMMC_ERROR_CMD_RSP_TIMEOUT;
lypinator 0:bb348c97df44 1325 }
lypinator 0:bb348c97df44 1326 else if (__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL))
lypinator 0:bb348c97df44 1327 {
lypinator 0:bb348c97df44 1328 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL);
lypinator 0:bb348c97df44 1329
lypinator 0:bb348c97df44 1330 return SDMMC_ERROR_CMD_CRC_FAIL;
lypinator 0:bb348c97df44 1331 }
lypinator 0:bb348c97df44 1332 else
lypinator 0:bb348c97df44 1333 {
lypinator 0:bb348c97df44 1334 /* No error flag set */
lypinator 0:bb348c97df44 1335 /* Clear all the static flags */
lypinator 0:bb348c97df44 1336 __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_FLAGS);
lypinator 0:bb348c97df44 1337 }
lypinator 0:bb348c97df44 1338
lypinator 0:bb348c97df44 1339 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1340 }
lypinator 0:bb348c97df44 1341
lypinator 0:bb348c97df44 1342 /**
lypinator 0:bb348c97df44 1343 * @brief Checks for error conditions for R3 (OCR) response.
lypinator 0:bb348c97df44 1344 * @param hsd SD handle
lypinator 0:bb348c97df44 1345 * @retval SD Card error state
lypinator 0:bb348c97df44 1346 */
lypinator 0:bb348c97df44 1347 static uint32_t SDMMC_GetCmdResp3(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 1348 {
lypinator 0:bb348c97df44 1349 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1350 The SDMMC_CMDTIMEOUT is expressed in ms */
lypinator 0:bb348c97df44 1351 register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1352
lypinator 0:bb348c97df44 1353 do
lypinator 0:bb348c97df44 1354 {
lypinator 0:bb348c97df44 1355 if (count-- == 0U)
lypinator 0:bb348c97df44 1356 {
lypinator 0:bb348c97df44 1357 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1358 }
lypinator 0:bb348c97df44 1359
lypinator 0:bb348c97df44 1360 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT));
lypinator 0:bb348c97df44 1361
lypinator 0:bb348c97df44 1362 if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT))
lypinator 0:bb348c97df44 1363 {
lypinator 0:bb348c97df44 1364 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT);
lypinator 0:bb348c97df44 1365
lypinator 0:bb348c97df44 1366 return SDMMC_ERROR_CMD_RSP_TIMEOUT;
lypinator 0:bb348c97df44 1367 }
lypinator 0:bb348c97df44 1368 else
lypinator 0:bb348c97df44 1369
lypinator 0:bb348c97df44 1370 {
lypinator 0:bb348c97df44 1371 /* Clear all the static flags */
lypinator 0:bb348c97df44 1372 __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_FLAGS);
lypinator 0:bb348c97df44 1373 }
lypinator 0:bb348c97df44 1374
lypinator 0:bb348c97df44 1375 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1376 }
lypinator 0:bb348c97df44 1377
lypinator 0:bb348c97df44 1378 /**
lypinator 0:bb348c97df44 1379 * @brief Checks for error conditions for R6 (RCA) response.
lypinator 0:bb348c97df44 1380 * @param hsd SD handle
lypinator 0:bb348c97df44 1381 * @param SD_CMD The sent command index
lypinator 0:bb348c97df44 1382 * @param pRCA Pointer to the variable that will contain the SD card relative
lypinator 0:bb348c97df44 1383 * address RCA
lypinator 0:bb348c97df44 1384 * @retval SD Card error state
lypinator 0:bb348c97df44 1385 */
lypinator 0:bb348c97df44 1386 static uint32_t SDMMC_GetCmdResp6(SDIO_TypeDef *SDIOx, uint8_t SD_CMD, uint16_t *pRCA)
lypinator 0:bb348c97df44 1387 {
lypinator 0:bb348c97df44 1388 uint32_t response_r1;
lypinator 0:bb348c97df44 1389
lypinator 0:bb348c97df44 1390 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1391 The SDMMC_CMDTIMEOUT is expressed in ms */
lypinator 0:bb348c97df44 1392 register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1393
lypinator 0:bb348c97df44 1394 do
lypinator 0:bb348c97df44 1395 {
lypinator 0:bb348c97df44 1396 if (count-- == 0U)
lypinator 0:bb348c97df44 1397 {
lypinator 0:bb348c97df44 1398 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1399 }
lypinator 0:bb348c97df44 1400
lypinator 0:bb348c97df44 1401 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT));
lypinator 0:bb348c97df44 1402
lypinator 0:bb348c97df44 1403 if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT))
lypinator 0:bb348c97df44 1404 {
lypinator 0:bb348c97df44 1405 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT);
lypinator 0:bb348c97df44 1406
lypinator 0:bb348c97df44 1407 return SDMMC_ERROR_CMD_RSP_TIMEOUT;
lypinator 0:bb348c97df44 1408 }
lypinator 0:bb348c97df44 1409 else if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL))
lypinator 0:bb348c97df44 1410 {
lypinator 0:bb348c97df44 1411 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL);
lypinator 0:bb348c97df44 1412
lypinator 0:bb348c97df44 1413 return SDMMC_ERROR_CMD_CRC_FAIL;
lypinator 0:bb348c97df44 1414 }
lypinator 0:bb348c97df44 1415
lypinator 0:bb348c97df44 1416 /* Check response received is of desired command */
lypinator 0:bb348c97df44 1417 if(SDIO_GetCommandResponse(SDIOx) != SD_CMD)
lypinator 0:bb348c97df44 1418 {
lypinator 0:bb348c97df44 1419 return SDMMC_ERROR_CMD_CRC_FAIL;
lypinator 0:bb348c97df44 1420 }
lypinator 0:bb348c97df44 1421
lypinator 0:bb348c97df44 1422 /* Clear all the static flags */
lypinator 0:bb348c97df44 1423 __SDIO_CLEAR_FLAG(SDIOx, SDIO_STATIC_FLAGS);
lypinator 0:bb348c97df44 1424
lypinator 0:bb348c97df44 1425 /* We have received response, retrieve it. */
lypinator 0:bb348c97df44 1426 response_r1 = SDIO_GetResponse(SDIOx, SDIO_RESP1);
lypinator 0:bb348c97df44 1427
lypinator 0:bb348c97df44 1428 if((response_r1 & (SDMMC_R6_GENERAL_UNKNOWN_ERROR | SDMMC_R6_ILLEGAL_CMD | SDMMC_R6_COM_CRC_FAILED)) == SDMMC_ALLZERO)
lypinator 0:bb348c97df44 1429 {
lypinator 0:bb348c97df44 1430 *pRCA = (uint16_t) (response_r1 >> 16);
lypinator 0:bb348c97df44 1431
lypinator 0:bb348c97df44 1432 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1433 }
lypinator 0:bb348c97df44 1434 else if((response_r1 & SDMMC_R6_ILLEGAL_CMD) == SDMMC_R6_ILLEGAL_CMD)
lypinator 0:bb348c97df44 1435 {
lypinator 0:bb348c97df44 1436 return SDMMC_ERROR_ILLEGAL_CMD;
lypinator 0:bb348c97df44 1437 }
lypinator 0:bb348c97df44 1438 else if((response_r1 & SDMMC_R6_COM_CRC_FAILED) == SDMMC_R6_COM_CRC_FAILED)
lypinator 0:bb348c97df44 1439 {
lypinator 0:bb348c97df44 1440 return SDMMC_ERROR_COM_CRC_FAILED;
lypinator 0:bb348c97df44 1441 }
lypinator 0:bb348c97df44 1442 else
lypinator 0:bb348c97df44 1443 {
lypinator 0:bb348c97df44 1444 return SDMMC_ERROR_GENERAL_UNKNOWN_ERR;
lypinator 0:bb348c97df44 1445 }
lypinator 0:bb348c97df44 1446 }
lypinator 0:bb348c97df44 1447
lypinator 0:bb348c97df44 1448 /**
lypinator 0:bb348c97df44 1449 * @brief Checks for error conditions for R7 response.
lypinator 0:bb348c97df44 1450 * @param hsd SD handle
lypinator 0:bb348c97df44 1451 * @retval SD Card error state
lypinator 0:bb348c97df44 1452 */
lypinator 0:bb348c97df44 1453 static uint32_t SDMMC_GetCmdResp7(SDIO_TypeDef *SDIOx)
lypinator 0:bb348c97df44 1454 {
lypinator 0:bb348c97df44 1455 /* 8 is the number of required instructions cycles for the below loop statement.
lypinator 0:bb348c97df44 1456 The SDIO_CMDTIMEOUT is expressed in ms */
lypinator 0:bb348c97df44 1457 register uint32_t count = SDIO_CMDTIMEOUT * (SystemCoreClock / 8U /1000U);
lypinator 0:bb348c97df44 1458
lypinator 0:bb348c97df44 1459 do
lypinator 0:bb348c97df44 1460 {
lypinator 0:bb348c97df44 1461 if (count-- == 0U)
lypinator 0:bb348c97df44 1462 {
lypinator 0:bb348c97df44 1463 return SDMMC_ERROR_TIMEOUT;
lypinator 0:bb348c97df44 1464 }
lypinator 0:bb348c97df44 1465
lypinator 0:bb348c97df44 1466 }while(!__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CCRCFAIL | SDIO_FLAG_CMDREND | SDIO_FLAG_CTIMEOUT));
lypinator 0:bb348c97df44 1467
lypinator 0:bb348c97df44 1468 if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CTIMEOUT))
lypinator 0:bb348c97df44 1469 {
lypinator 0:bb348c97df44 1470 /* Card is SD V2.0 compliant */
lypinator 0:bb348c97df44 1471 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CMDREND);
lypinator 0:bb348c97df44 1472
lypinator 0:bb348c97df44 1473 return SDMMC_ERROR_CMD_RSP_TIMEOUT;
lypinator 0:bb348c97df44 1474 }
lypinator 0:bb348c97df44 1475
lypinator 0:bb348c97df44 1476 if(__SDIO_GET_FLAG(SDIOx, SDIO_FLAG_CMDREND))
lypinator 0:bb348c97df44 1477 {
lypinator 0:bb348c97df44 1478 /* Card is SD V2.0 compliant */
lypinator 0:bb348c97df44 1479 __SDIO_CLEAR_FLAG(SDIOx, SDIO_FLAG_CMDREND);
lypinator 0:bb348c97df44 1480 }
lypinator 0:bb348c97df44 1481
lypinator 0:bb348c97df44 1482 return SDMMC_ERROR_NONE;
lypinator 0:bb348c97df44 1483
lypinator 0:bb348c97df44 1484 }
lypinator 0:bb348c97df44 1485
lypinator 0:bb348c97df44 1486 /**
lypinator 0:bb348c97df44 1487 * @}
lypinator 0:bb348c97df44 1488 */
lypinator 0:bb348c97df44 1489
lypinator 0:bb348c97df44 1490 /**
lypinator 0:bb348c97df44 1491 * @}
lypinator 0:bb348c97df44 1492 */
lypinator 0:bb348c97df44 1493
lypinator 0:bb348c97df44 1494 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
lypinator 0:bb348c97df44 1495 STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
lypinator 0:bb348c97df44 1496 STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
lypinator 0:bb348c97df44 1497 #endif /* (HAL_SD_MODULE_ENABLED) || (HAL_MMC_MODULE_ENABLED) */
lypinator 0:bb348c97df44 1498
lypinator 0:bb348c97df44 1499 /**
lypinator 0:bb348c97df44 1500 * @}
lypinator 0:bb348c97df44 1501 */
lypinator 0:bb348c97df44 1502
lypinator 0:bb348c97df44 1503 /**
lypinator 0:bb348c97df44 1504 * @}
lypinator 0:bb348c97df44 1505 */
lypinator 0:bb348c97df44 1506
lypinator 0:bb348c97df44 1507 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/