STM32F439xx HAL User Manual
stm32f4xx_hal_mmc.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_mmc.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of MMC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
00010   *
00011   * Redistribution and use in source and binary forms, with or without modification,
00012   * are permitted provided that the following conditions are met:
00013   *   1. Redistributions of source code must retain the above copyright notice,
00014   *      this list of conditions and the following disclaimer.
00015   *   2. Redistributions in binary form must reproduce the above copyright notice,
00016   *      this list of conditions and the following disclaimer in the documentation
00017   *      and/or other materials provided with the distribution.
00018   *   3. Neither the name of STMicroelectronics nor the names of its contributors
00019   *      may be used to endorse or promote products derived from this software
00020   *      without specific prior written permission.
00021   *
00022   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00023   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00026   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00028   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00030   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00031   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032   *
00033   ******************************************************************************
00034   */ 
00035 
00036 /* Define to prevent recursive inclusion -------------------------------------*/
00037 #ifndef __STM32F4xx_HAL_MMC_H
00038 #define __STM32F4xx_HAL_MMC_H
00039 
00040 #ifdef __cplusplus
00041  extern "C" {
00042 #endif
00043 
00044 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
00045     defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
00046     defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
00047     defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
00048     defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
00049 
00050 /* Includes ------------------------------------------------------------------*/
00051 #include "stm32f4xx_ll_sdmmc.h"
00052 
00053 /** @addtogroup STM32F4xx_HAL_Driver
00054   * @{
00055   */
00056 
00057 /** @defgroup MMC MMC
00058   * @brief MMC HAL module driver
00059   * @{
00060   */ 
00061 
00062 /* Exported types ------------------------------------------------------------*/ 
00063 /** @defgroup MMC_Exported_Types MMC Exported Types
00064   * @{
00065   */
00066 
00067 /** @defgroup MMC_Exported_Types_Group1 MMC State enumeration structure
00068   * @{
00069   */   
00070 typedef enum
00071 {
00072   HAL_MMC_STATE_RESET                  = 0x00000000U,  /*!< MMC not yet initialized or disabled  */
00073   HAL_MMC_STATE_READY                  = 0x00000001U,  /*!< MMC initialized and ready for use    */
00074   HAL_MMC_STATE_TIMEOUT                = 0x00000002U,  /*!< MMC Timeout state                    */
00075   HAL_MMC_STATE_BUSY                   = 0x00000003U,  /*!< MMC process ongoing                  */
00076   HAL_MMC_STATE_PROGRAMMING            = 0x00000004U,  /*!< MMC Programming State                */
00077   HAL_MMC_STATE_RECEIVING              = 0x00000005U,  /*!< MMC Receinving State                 */
00078   HAL_MMC_STATE_TRANSFER               = 0x00000006U,  /*!< MMC Transfert State                  */
00079   HAL_MMC_STATE_ERROR                  = 0x0000000FU   /*!< MMC is in error state                */
00080 }HAL_MMC_StateTypeDef;
00081 /** 
00082   * @}
00083   */
00084 
00085 /** @defgroup MMC_Exported_Types_Group2 MMC Card State enumeration structure
00086   * @{
00087   */   
00088 typedef enum
00089 {
00090   HAL_MMC_CARD_READY                  = 0x00000001U,  /*!< Card state is ready                     */
00091   HAL_MMC_CARD_IDENTIFICATION         = 0x00000002U,  /*!< Card is in identification state         */
00092   HAL_MMC_CARD_STANDBY                = 0x00000003U,  /*!< Card is in standby state                */
00093   HAL_MMC_CARD_TRANSFER               = 0x00000004U,  /*!< Card is in transfer state               */  
00094   HAL_MMC_CARD_SENDING                = 0x00000005U,  /*!< Card is sending an operation            */
00095   HAL_MMC_CARD_RECEIVING              = 0x00000006U,  /*!< Card is receiving operation information */
00096   HAL_MMC_CARD_PROGRAMMING            = 0x00000007U,  /*!< Card is in programming state            */
00097   HAL_MMC_CARD_DISCONNECTED           = 0x00000008U,  /*!< Card is disconnected                    */
00098   HAL_MMC_CARD_ERROR                  = 0x000000FFU   /*!< Card response Error                     */
00099 }HAL_MMC_CardStateTypeDef;
00100 /** 
00101   * @}
00102   */
00103 
00104 /** @defgroup MMC_Exported_Types_Group3 MMC Handle Structure definition   
00105   * @{
00106   */
00107 #define MMC_InitTypeDef      SDIO_InitTypeDef 
00108 #define MMC_TypeDef          SDIO_TypeDef
00109 
00110 /** 
00111   * @brief  MMC Card Information Structure definition
00112   */ 
00113 typedef struct
00114 {
00115   uint32_t CardType;                     /*!< Specifies the card Type                         */
00116 
00117   uint32_t Class;                        /*!< Specifies the class of the card class           */
00118 
00119   uint32_t RelCardAdd;                   /*!< Specifies the Relative Card Address             */
00120   
00121   uint32_t BlockNbr;                     /*!< Specifies the Card Capacity in blocks           */
00122 
00123   uint32_t BlockSize;                    /*!< Specifies one block size in bytes               */
00124   
00125   uint32_t LogBlockNbr;                  /*!< Specifies the Card logical Capacity in blocks   */
00126 
00127   uint32_t LogBlockSize;                 /*!< Specifies logical block size in bytes           */
00128 
00129 }HAL_MMC_CardInfoTypeDef;
00130 
00131 /** 
00132   * @brief  MMC handle Structure definition
00133   */ 
00134 typedef struct
00135 {
00136   MMC_TypeDef                 *Instance;        /*!< MMC registers base address           */
00137   
00138   MMC_InitTypeDef              Init;             /*!< MMC required parameters              */
00139   
00140   HAL_LockTypeDef              Lock;             /*!< MMC locking object                   */
00141   
00142   uint32_t                     *pTxBuffPtr;      /*!< Pointer to MMC Tx transfer Buffer    */
00143 
00144   uint32_t                     TxXferSize;       /*!< MMC Tx Transfer size                 */
00145 
00146   uint32_t                     *pRxBuffPtr;      /*!< Pointer to MMC Rx transfer Buffer    */
00147 
00148   uint32_t                     RxXferSize;       /*!< MMC Rx Transfer size                 */
00149   
00150   __IO uint32_t                Context;          /*!< MMC transfer context                 */
00151  
00152   __IO HAL_MMC_StateTypeDef    State;            /*!< MMC card State                       */
00153   
00154   __IO uint32_t                ErrorCode;        /*!< MMC Card Error codes                 */  
00155  
00156   DMA_HandleTypeDef            *hdmarx;          /*!< MMC Rx DMA handle parameters         */
00157   
00158   DMA_HandleTypeDef            *hdmatx;          /*!< MMC Tx DMA handle parameters         */
00159   
00160   HAL_MMC_CardInfoTypeDef      MmcCard;          /*!< MMC Card information                 */
00161   
00162   uint32_t                     CSD[4U];          /*!< MMC card specific data table         */
00163   
00164   uint32_t                     CID[4U];          /*!< MMC card identification number table */
00165   
00166 }MMC_HandleTypeDef;
00167 
00168 /** 
00169   * @}
00170   */
00171 
00172 /** @defgroup MMC_Exported_Types_Group4 Card Specific Data: CSD Register 
00173   * @{
00174   */
00175 typedef struct
00176 {
00177   __IO uint8_t  CSDStruct;            /*!< CSD structure                         */
00178   __IO uint8_t  SysSpecVersion;       /*!< System specification version          */
00179   __IO uint8_t  Reserved1;            /*!< Reserved                              */
00180   __IO uint8_t  TAAC;                 /*!< Data read access time 1               */
00181   __IO uint8_t  NSAC;                 /*!< Data read access time 2 in CLK cycles */
00182   __IO uint8_t  MaxBusClkFrec;        /*!< Max. bus clock frequency              */
00183   __IO uint16_t CardComdClasses;      /*!< Card command classes                  */
00184   __IO uint8_t  RdBlockLen;           /*!< Max. read data block length           */
00185   __IO uint8_t  PartBlockRead;        /*!< Partial blocks for read allowed       */
00186   __IO uint8_t  WrBlockMisalign;      /*!< Write block misalignment              */
00187   __IO uint8_t  RdBlockMisalign;      /*!< Read block misalignment               */
00188   __IO uint8_t  DSRImpl;              /*!< DSR implemented                       */
00189   __IO uint8_t  Reserved2;            /*!< Reserved                              */
00190   __IO uint32_t DeviceSize;           /*!< Device Size                           */
00191   __IO uint8_t  MaxRdCurrentVDDMin;   /*!< Max. read current @ VDD min           */
00192   __IO uint8_t  MaxRdCurrentVDDMax;   /*!< Max. read current @ VDD max           */
00193   __IO uint8_t  MaxWrCurrentVDDMin;   /*!< Max. write current @ VDD min          */
00194   __IO uint8_t  MaxWrCurrentVDDMax;   /*!< Max. write current @ VDD max          */
00195   __IO uint8_t  DeviceSizeMul;        /*!< Device size multiplier                */
00196   __IO uint8_t  EraseGrSize;          /*!< Erase group size                      */
00197   __IO uint8_t  EraseGrMul;           /*!< Erase group size multiplier           */
00198   __IO uint8_t  WrProtectGrSize;      /*!< Write protect group size              */
00199   __IO uint8_t  WrProtectGrEnable;    /*!< Write protect group enable            */
00200   __IO uint8_t  ManDeflECC;           /*!< Manufacturer default ECC              */
00201   __IO uint8_t  WrSpeedFact;          /*!< Write speed factor                    */
00202   __IO uint8_t  MaxWrBlockLen;        /*!< Max. write data block length          */
00203   __IO uint8_t  WriteBlockPaPartial;  /*!< Partial blocks for write allowed      */
00204   __IO uint8_t  Reserved3;            /*!< Reserved                              */
00205   __IO uint8_t  ContentProtectAppli;  /*!< Content protection application        */
00206   __IO uint8_t  FileFormatGrouop;     /*!< File format group                     */
00207   __IO uint8_t  CopyFlag;             /*!< Copy flag (OTP)                       */
00208   __IO uint8_t  PermWrProtect;        /*!< Permanent write protection            */
00209   __IO uint8_t  TempWrProtect;        /*!< Temporary write protection            */
00210   __IO uint8_t  FileFormat;           /*!< File format                           */
00211   __IO uint8_t  ECC;                  /*!< ECC code                              */
00212   __IO uint8_t  CSD_CRC;              /*!< CSD CRC                               */
00213   __IO uint8_t  Reserved4;            /*!< Always 1                              */
00214   
00215 }HAL_MMC_CardCSDTypeDef;
00216 /** 
00217   * @}
00218   */
00219 
00220 /** @defgroup MMC_Exported_Types_Group5 Card Identification Data: CID Register
00221   * @{
00222   */
00223 typedef struct
00224 {
00225   __IO uint8_t  ManufacturerID;  /*!< Manufacturer ID       */
00226   __IO uint16_t OEM_AppliID;     /*!< OEM/Application ID    */
00227   __IO uint32_t ProdName1;       /*!< Product Name part1    */
00228   __IO uint8_t  ProdName2;       /*!< Product Name part2    */
00229   __IO uint8_t  ProdRev;         /*!< Product Revision      */
00230   __IO uint32_t ProdSN;          /*!< Product Serial Number */
00231   __IO uint8_t  Reserved1;       /*!< Reserved1             */
00232   __IO uint16_t ManufactDate;    /*!< Manufacturing Date    */
00233   __IO uint8_t  CID_CRC;         /*!< CID CRC               */
00234   __IO uint8_t  Reserved2;       /*!< Always 1              */
00235 
00236 }HAL_MMC_CardCIDTypeDef;
00237 /** 
00238   * @}
00239   */
00240 
00241 /** @defgroup MMC_Exported_Types_Group6 MMC Card Status returned by ACMD13 
00242   * @{
00243   */
00244 typedef struct
00245 {
00246   __IO uint8_t  DataBusWidth;           /*!< Shows the currently defined data bus width                 */
00247   __IO uint8_t  SecuredMode;            /*!< Card is in secured mode of operation                       */
00248   __IO uint16_t CardType;               /*!< Carries information about card type                        */
00249   __IO uint32_t ProtectedAreaSize;      /*!< Carries information about the capacity of protected area   */
00250   __IO uint8_t  SpeedClass;             /*!< Carries information about the speed class of the card      */
00251   __IO uint8_t  PerformanceMove;        /*!< Carries information about the card's performance move      */
00252   __IO uint8_t  AllocationUnitSize;     /*!< Carries information about the card's allocation unit size  */
00253   __IO uint16_t EraseSize;              /*!< Determines the number of AUs to be erased in one operation */
00254   __IO uint8_t  EraseTimeout;           /*!< Determines the timeout for any number of AU erase          */
00255   __IO uint8_t  EraseOffset;            /*!< Carries information about the erase offset                 */
00256 
00257 }HAL_MMC_CardStatusTypeDef;
00258 /** 
00259   * @}
00260   */
00261 
00262 /** 
00263   * @}
00264   */
00265 
00266 /* Exported constants --------------------------------------------------------*/
00267 /** @defgroup MMC_Exported_Constants Exported Constants
00268   * @{
00269   */
00270 
00271 #define BLOCKSIZE   512U        /*!< Block size is 512 bytes */
00272     
00273 #define CAPACITY    0x400000U   /*!< Log Block Nuumber for 2 G bytes Cards */
00274 
00275 /** @defgroup MMC_Exported_Constansts_Group1 MMC Error status enumeration Structure definition 
00276   * @{
00277   */  
00278 #define HAL_MMC_ERROR_NONE                     SDMMC_ERROR_NONE                    /*!< No error                                                      */
00279 #define HAL_MMC_ERROR_CMD_CRC_FAIL             SDMMC_ERROR_CMD_CRC_FAIL            /*!< Command response received (but CRC check failed)              */
00280 #define HAL_MMC_ERROR_DATA_CRC_FAIL            SDMMC_ERROR_DATA_CRC_FAIL           /*!< Data block sent/received (CRC check failed)                   */
00281 #define HAL_MMC_ERROR_CMD_RSP_TIMEOUT          SDMMC_ERROR_CMD_RSP_TIMEOUT         /*!< Command response timeout                                      */
00282 #define HAL_MMC_ERROR_DATA_TIMEOUT             SDMMC_ERROR_DATA_TIMEOUT            /*!< Data timeout                                                  */
00283 #define HAL_MMC_ERROR_TX_UNDERRUN              SDMMC_ERROR_TX_UNDERRUN             /*!< Transmit FIFO underrun                                        */
00284 #define HAL_MMC_ERROR_RX_OVERRUN               SDMMC_ERROR_RX_OVERRUN              /*!< Receive FIFO overrun                                          */
00285 #define HAL_MMC_ERROR_ADDR_MISALIGNED          SDMMC_ERROR_ADDR_MISALIGNED         /*!< Misaligned address                                            */
00286 #define HAL_MMC_ERROR_BLOCK_LEN_ERR            SDMMC_ERROR_BLOCK_LEN_ERR           /*!< Transferred block length is not allowed for the card or the 
00287                                                                                        number of transferred bytes does not match the block length   */
00288 #define HAL_MMC_ERROR_ERASE_SEQ_ERR            SDMMC_ERROR_ERASE_SEQ_ERR           /*!< An error in the sequence of erase command occurs              */
00289 #define HAL_MMC_ERROR_BAD_ERASE_PARAM          SDMMC_ERROR_BAD_ERASE_PARAM         /*!< An invalid selection for erase groups                         */
00290 #define HAL_MMC_ERROR_WRITE_PROT_VIOLATION     SDMMC_ERROR_WRITE_PROT_VIOLATION    /*!< Attempt to program a write protect block                      */
00291 #define HAL_MMC_ERROR_LOCK_UNLOCK_FAILED       SDMMC_ERROR_LOCK_UNLOCK_FAILED      /*!< Sequence or password error has been detected in unlock 
00292                                                                                        command or if there was an attempt to access a locked card    */
00293 #define HAL_MMC_ERROR_COM_CRC_FAILED           SDMMC_ERROR_COM_CRC_FAILED          /*!< CRC check of the previous command failed                      */
00294 #define HAL_MMC_ERROR_ILLEGAL_CMD              SDMMC_ERROR_ILLEGAL_CMD             /*!< Command is not legal for the card state                       */
00295 #define HAL_MMC_ERROR_CARD_ECC_FAILED          SDMMC_ERROR_CARD_ECC_FAILED         /*!< Card internal ECC was applied but failed to correct the data  */
00296 #define HAL_MMC_ERROR_CC_ERR                   SDMMC_ERROR_CC_ERR                  /*!< Internal card controller error                                */
00297 #define HAL_MMC_ERROR_GENERAL_UNKNOWN_ERR      SDMMC_ERROR_GENERAL_UNKNOWN_ERR     /*!< General or unknown error                                      */
00298 #define HAL_MMC_ERROR_STREAM_READ_UNDERRUN     SDMMC_ERROR_STREAM_READ_UNDERRUN    /*!< The card could not sustain data reading in stream rmode       */
00299 #define HAL_MMC_ERROR_STREAM_WRITE_OVERRUN     SDMMC_ERROR_STREAM_WRITE_OVERRUN    /*!< The card could not sustain data programming in stream mode    */
00300 #define HAL_MMC_ERROR_CID_CSD_OVERWRITE        SDMMC_ERROR_CID_CSD_OVERWRITE       /*!< CID/CSD overwrite error                                       */
00301 #define HAL_MMC_ERROR_WP_ERASE_SKIP            SDMMC_ERROR_WP_ERASE_SKIP           /*!< Only partial address space was erased                         */
00302 #define HAL_MMC_ERROR_CARD_ECC_DISABLED        SDMMC_ERROR_CARD_ECC_DISABLED       /*!< Command has been executed without using internal ECC          */
00303 #define HAL_MMC_ERROR_ERASE_RESET              SDMMC_ERROR_ERASE_RESET             /*!< Erase sequence was cleared before executing because an out 
00304                                                                                        of erase sequence command was received                        */
00305 #define HAL_MMC_ERROR_AKE_SEQ_ERR              SDMMC_ERROR_AKE_SEQ_ERR             /*!< Error in sequence of authentication                           */
00306 #define HAL_MMC_ERROR_INVALID_VOLTRANGE        SDMMC_ERROR_INVALID_VOLTRANGE       /*!< Error in case of invalid voltage range                        */        
00307 #define HAL_MMC_ERROR_ADDR_OUT_OF_RANGE        SDMMC_ERROR_ADDR_OUT_OF_RANGE       /*!< Error when addressed block is out of range                    */        
00308 #define HAL_MMC_ERROR_REQUEST_NOT_APPLICABLE   SDMMC_ERROR_REQUEST_NOT_APPLICABLE  /*!< Error when command request is not applicable                  */  
00309 #define HAL_MMC_ERROR_PARAM                    SDMMC_ERROR_INVALID_PARAMETER       /*!< the used parameter is not valid                               */  
00310 #define HAL_MMC_ERROR_UNSUPPORTED_FEATURE      SDMMC_ERROR_UNSUPPORTED_FEATURE     /*!< Error when feature is not insupported                         */
00311 #define HAL_MMC_ERROR_BUSY                     SDMMC_ERROR_BUSY                    /*!< Error when transfer process is busy                           */ 
00312 #define HAL_MMC_ERROR_DMA                      SDMMC_ERROR_DMA                     /*!< Error while DMA transfer                                      */
00313 #define HAL_MMC_ERROR_TIMEOUT                  SDMMC_ERROR_TIMEOUT                 /*!< Timeout error                                                 */
00314                                                 
00315 /** 
00316   * @}
00317   */
00318  
00319 /** @defgroup MMC_Exported_Constansts_Group2 MMC context enumeration structure
00320   * @{
00321   */ 
00322 #define   MMC_CONTEXT_NONE                 0x00000000U  /*!< None                             */
00323 #define   MMC_CONTEXT_READ_SINGLE_BLOCK    0x00000001U  /*!< Read single block operation      */
00324 #define   MMC_CONTEXT_READ_MULTIPLE_BLOCK  0x00000002U  /*!< Read multiple blocks operation   */
00325 #define   MMC_CONTEXT_WRITE_SINGLE_BLOCK   0x00000010U  /*!< Write single block operation     */
00326 #define   MMC_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U  /*!< Write multiple blocks operation  */
00327 #define   MMC_CONTEXT_IT                   0x00000008U  /*!< Process in Interrupt mode        */
00328 #define   MMC_CONTEXT_DMA                  0x00000080U  /*!< Process in DMA mode              */  
00329 
00330 /**
00331   * @}
00332   */
00333 
00334 /** @defgroup MMC_Exported_Constansts_Group3 MMC Voltage mode
00335   * @{
00336   */
00337 /** 
00338   * @brief 
00339   */
00340 #define MMC_HIGH_VOLTAGE_RANGE         0x80FF8000U  /*!< VALUE OF ARGUMENT            */
00341 #define MMC_DUAL_VOLTAGE_RANGE         0x80FF8080U  /*!< VALUE OF ARGUMENT            */
00342 #define eMMC_HIGH_VOLTAGE_RANGE        0xC0FF8000U  /*!< for eMMC > 2Gb sector mode   */
00343 #define eMMC_DUAL_VOLTAGE_RANGE        0xC0FF8080U  /*!< for eMMC > 2Gb sector mode   */
00344 #define MMC_INVALID_VOLTAGE_RANGE      0x0001FF01U 
00345 /**
00346   * @}
00347   */
00348 
00349 /** @defgroup MMC_Exported_Constansts_Group4 MMC Memory Cards
00350   * @{
00351   */
00352 #define  MMC_HIGH_VOLTAGE_CARD     0x00000000U
00353 #define  MMC_DUAL_VOLTAGE_CARD     0x00000001U
00354 /**
00355   * @}
00356   */
00357       
00358 /**
00359   * @}
00360   */
00361   
00362 /* Exported macro ------------------------------------------------------------*/
00363 /** @defgroup MMC_Exported_macros MMC Exported Macros
00364  *  @brief macros to handle interrupts and specific clock configurations
00365  * @{
00366  */
00367  
00368 /**
00369   * @brief  Enable the MMC device.
00370   * @retval None
00371   */ 
00372 #define __HAL_MMC_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance)
00373 
00374 /**
00375   * @brief  Disable the MMC device.
00376   * @retval None
00377   */
00378 #define __HAL_MMC_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance)
00379 
00380 /**
00381   * @brief  Enable the SDMMC DMA transfer.
00382   * @retval None
00383   */ 
00384 #define __HAL_MMC_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance)
00385 
00386 /**
00387   * @brief  Disable the SDMMC DMA transfer.
00388   * @retval None
00389   */
00390 #define __HAL_MMC_DMA_DISABLE(__HANDLE__)  __SDIO_DMA_DISABLE((__HANDLE__)->Instance)
00391  
00392 /**
00393   * @brief  Enable the MMC device interrupt.
00394   * @param  __HANDLE__ MMC Handle  
00395   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be enabled.
00396   *         This parameter can be one or a combination of the following values:
00397   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00398   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00399   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00400   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00401   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00402   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00403   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00404   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00405   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00406   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00407   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00408   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00409   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00410   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00411   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00412   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00413   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00414   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00415   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00416   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00417   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00418   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00419   * @retval None
00420   */
00421 #define __HAL_MMC_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00422 
00423 /**
00424   * @brief  Disable the MMC device interrupt.
00425   * @param  __HANDLE__ MMC Handle   
00426   * @param  __INTERRUPT__ specifies the SDMMC interrupt sources to be disabled.
00427   *          This parameter can be one or a combination of the following values:
00428   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00429   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00430   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00431   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00432   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00433   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00434   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00435   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00436   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00437   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00438   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00439   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00440   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00441   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00442   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00443   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00444   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00445   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00446   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00447   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00448   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00449   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt   
00450   * @retval None
00451   */
00452 #define __HAL_MMC_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00453 
00454 /**
00455   * @brief  Check whether the specified MMC flag is set or not. 
00456   * @param  __HANDLE__ MMC Handle   
00457   * @param  __FLAG__ specifies the flag to check. 
00458   *          This parameter can be one of the following values:
00459   *            @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
00460   *            @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00461   *            @arg SDIO_FLAG_CTIMEOUT: Command response timeout
00462   *            @arg SDIO_FLAG_DTIMEOUT: Data timeout
00463   *            @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
00464   *            @arg SDIO_FLAG_RXOVERR:  Received FIFO overrun error
00465   *            @arg SDIO_FLAG_CMDREND:  Command response received (CRC check passed)
00466   *            @arg SDIO_FLAG_CMDSENT:  Command sent (no response required)
00467   *            @arg SDIO_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00468   *            @arg SDIO_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00469   *            @arg SDIO_FLAG_CMDACT:   Command transfer in progress
00470   *            @arg SDIO_FLAG_TXACT:    Data transmit in progress
00471   *            @arg SDIO_FLAG_RXACT:    Data receive in progress
00472   *            @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
00473   *            @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
00474   *            @arg SDIO_FLAG_TXFIFOF:  Transmit FIFO full
00475   *            @arg SDIO_FLAG_RXFIFOF:  Receive FIFO full
00476   *            @arg SDIO_FLAG_TXFIFOE:  Transmit FIFO empty
00477   *            @arg SDIO_FLAG_RXFIFOE:  Receive FIFO empty
00478   *            @arg SDIO_FLAG_TXDAVL:   Data available in transmit FIFO
00479   *            @arg SDIO_FLAG_RXDAVL:   Data available in receive FIFO
00480   *            @arg SDIO_FLAG_SDIOIT:   SD I/O interrupt received
00481   * @retval The new state of MMC FLAG (SET or RESET).
00482   */
00483 #define __HAL_MMC_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__))
00484 
00485 /**
00486   * @brief  Clear the MMC's pending flags.
00487   * @param  __HANDLE__ MMC Handle  
00488   * @param  __FLAG__ specifies the flag to clear.  
00489   *          This parameter can be one or a combination of the following values:
00490   *            @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
00491   *            @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
00492   *            @arg SDIO_FLAG_CTIMEOUT: Command response timeout
00493   *            @arg SDIO_FLAG_DTIMEOUT: Data timeout
00494   *            @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
00495   *            @arg SDIO_FLAG_RXOVERR:  Received FIFO overrun error
00496   *            @arg SDIO_FLAG_CMDREND:  Command response received (CRC check passed)
00497   *            @arg SDIO_FLAG_CMDSENT:  Command sent (no response required)
00498   *            @arg SDIO_FLAG_DATAEND:  Data end (data counter, SDIDCOUNT, is zero)
00499   *            @arg SDIO_FLAG_DBCKEND:  Data block sent/received (CRC check passed)
00500   *            @arg SDIO_FLAG_SDIOIT:   SD I/O interrupt received
00501   * @retval None
00502   */
00503 #define __HAL_MMC_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__))
00504 
00505 /**
00506   * @brief  Check whether the specified MMC interrupt has occurred or not.
00507   * @param  __HANDLE__ MMC Handle   
00508   * @param  __INTERRUPT__ specifies the SDMMC interrupt source to check. 
00509   *          This parameter can be one of the following values:
00510   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00511   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00512   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00513   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00514   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00515   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00516   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00517   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00518   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDIDCOUNT, is zero) interrupt
00519   *            @arg SDIO_IT_DBCKEND:  Data block sent/received (CRC check passed) interrupt
00520   *            @arg SDIO_IT_CMDACT:   Command transfer in progress interrupt
00521   *            @arg SDIO_IT_TXACT:    Data transmit in progress interrupt
00522   *            @arg SDIO_IT_RXACT:    Data receive in progress interrupt
00523   *            @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
00524   *            @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
00525   *            @arg SDIO_IT_TXFIFOF:  Transmit FIFO full interrupt
00526   *            @arg SDIO_IT_RXFIFOF:  Receive FIFO full interrupt
00527   *            @arg SDIO_IT_TXFIFOE:  Transmit FIFO empty interrupt
00528   *            @arg SDIO_IT_RXFIFOE:  Receive FIFO empty interrupt
00529   *            @arg SDIO_IT_TXDAVL:   Data available in transmit FIFO interrupt
00530   *            @arg SDIO_IT_RXDAVL:   Data available in receive FIFO interrupt
00531   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00532   * @retval The new state of MMC IT (SET or RESET).
00533   */
00534 #define __HAL_MMC_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00535 
00536 /**
00537   * @brief  Clear the MMC's interrupt pending bits.
00538   * @param  __HANDLE__ MMC Handle
00539   * @param  __INTERRUPT__ specifies the interrupt pending bit to clear. 
00540   *          This parameter can be one or a combination of the following values:
00541   *            @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
00542   *            @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
00543   *            @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt
00544   *            @arg SDIO_IT_DTIMEOUT: Data timeout interrupt
00545   *            @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
00546   *            @arg SDIO_IT_RXOVERR:  Received FIFO overrun error interrupt
00547   *            @arg SDIO_IT_CMDREND:  Command response received (CRC check passed) interrupt
00548   *            @arg SDIO_IT_CMDSENT:  Command sent (no response required) interrupt
00549   *            @arg SDIO_IT_DATAEND:  Data end (data counter, SDMMC_DCOUNT, is zero) interrupt
00550   *            @arg SDIO_IT_SDIOIT:   SD I/O interrupt received interrupt
00551   * @retval None
00552   */
00553 #define __HAL_MMC_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__))
00554 
00555 /**
00556   * @}
00557   */
00558   
00559 /* Exported functions --------------------------------------------------------*/
00560 /** @defgroup MMC_Exported_Functions MMC Exported Functions
00561   * @{
00562   */
00563   
00564 /** @defgroup MMC_Exported_Functions_Group1 Initialization and de-initialization functions
00565   * @{
00566   */
00567 HAL_StatusTypeDef HAL_MMC_Init(MMC_HandleTypeDef *hmmc);
00568 HAL_StatusTypeDef HAL_MMC_InitCard(MMC_HandleTypeDef *hmmc);
00569 HAL_StatusTypeDef HAL_MMC_DeInit (MMC_HandleTypeDef *hmmc);
00570 void HAL_MMC_MspInit(MMC_HandleTypeDef *hmmc);
00571 void HAL_MMC_MspDeInit(MMC_HandleTypeDef *hmmc);
00572 /**
00573   * @}
00574   */
00575   
00576 /** @defgroup MMC_Exported_Functions_Group2 Input and Output operation functions
00577   * @{
00578   */
00579 /* Blocking mode: Polling */
00580 HAL_StatusTypeDef HAL_MMC_ReadBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00581 HAL_StatusTypeDef HAL_MMC_WriteBlocks(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout);
00582 HAL_StatusTypeDef HAL_MMC_Erase(MMC_HandleTypeDef *hmmc, uint32_t BlockStartAdd, uint32_t BlockEndAdd);
00583 /* Non-Blocking mode: IT */
00584 HAL_StatusTypeDef HAL_MMC_ReadBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00585 HAL_StatusTypeDef HAL_MMC_WriteBlocks_IT(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00586 /* Non-Blocking mode: DMA */
00587 HAL_StatusTypeDef HAL_MMC_ReadBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00588 HAL_StatusTypeDef HAL_MMC_WriteBlocks_DMA(MMC_HandleTypeDef *hmmc, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks);
00589 
00590 void HAL_MMC_IRQHandler(MMC_HandleTypeDef *hmmc);
00591 
00592 /* Callback in non blocking modes (DMA) */
00593 void HAL_MMC_TxCpltCallback(MMC_HandleTypeDef *hmmc);
00594 void HAL_MMC_RxCpltCallback(MMC_HandleTypeDef *hmmc);
00595 void HAL_MMC_ErrorCallback(MMC_HandleTypeDef *hmmc);
00596 void HAL_MMC_AbortCallback(MMC_HandleTypeDef *hmmc);
00597 /**
00598   * @}
00599   */
00600   
00601 /** @defgroup MMC_Exported_Functions_Group3 Peripheral Control functions
00602   * @{
00603   */
00604 HAL_StatusTypeDef HAL_MMC_ConfigWideBusOperation(MMC_HandleTypeDef *hmmc, uint32_t WideMode);
00605 /**
00606   * @}
00607   */
00608 
00609 /** @defgroup MMC_Exported_Functions_Group4 MMC card related functions
00610   * @{
00611   */
00612 HAL_MMC_CardStateTypeDef HAL_MMC_GetCardState(MMC_HandleTypeDef *hmmc);
00613 HAL_StatusTypeDef        HAL_MMC_GetCardCID(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCIDTypeDef *pCID);
00614 HAL_StatusTypeDef        HAL_MMC_GetCardCSD(MMC_HandleTypeDef *hmmc, HAL_MMC_CardCSDTypeDef *pCSD);
00615 HAL_StatusTypeDef        HAL_MMC_GetCardInfo(MMC_HandleTypeDef *hmmc, HAL_MMC_CardInfoTypeDef *pCardInfo);
00616 /**
00617   * @}
00618   */
00619 
00620 /** @defgroup MMC_Exported_Functions_Group5 Peripheral State and Errors functions
00621   * @{
00622   */
00623 HAL_MMC_StateTypeDef HAL_MMC_GetState(MMC_HandleTypeDef *hmmc);
00624 uint32_t HAL_MMC_GetError(MMC_HandleTypeDef *hmmc);
00625 /**
00626   * @}
00627   */
00628 
00629 /** @defgroup MMC_Exported_Functions_Group6 Perioheral Abort management
00630   * @{
00631   */
00632 HAL_StatusTypeDef HAL_MMC_Abort(MMC_HandleTypeDef *hmmc);
00633 HAL_StatusTypeDef HAL_MMC_Abort_IT(MMC_HandleTypeDef *hmmc);
00634 /**
00635   * @}
00636   */
00637     
00638 /* Private types -------------------------------------------------------------*/
00639 /** @defgroup MMC_Private_Types MMC Private Types
00640   * @{
00641   */
00642 
00643 /**
00644   * @}
00645   */ 
00646 
00647 /* Private defines -----------------------------------------------------------*/
00648 /** @defgroup MMC_Private_Defines MMC Private Defines
00649   * @{
00650   */
00651 
00652 /**
00653   * @}
00654   */ 
00655           
00656 /* Private variables ---------------------------------------------------------*/
00657 /** @defgroup MMC_Private_Variables MMC Private Variables
00658   * @{
00659   */
00660 
00661 /**
00662   * @}
00663   */ 
00664 
00665 /* Private constants ---------------------------------------------------------*/
00666 /** @defgroup MMC_Private_Constants MMC Private Constants
00667   * @{
00668   */
00669 
00670 /**
00671   * @}
00672   */ 
00673 
00674 /* Private macros ------------------------------------------------------------*/
00675 /** @defgroup MMC_Private_Macros MMC Private Macros
00676   * @{
00677   */
00678 
00679 /**
00680   * @}
00681   */
00682 
00683 /* Private functions prototypes ----------------------------------------------*/
00684 /** @defgroup MMC_Private_Functions_Prototypes MMC Private Functions Prototypes
00685   * @{
00686   */
00687 
00688 /**
00689   * @}
00690   */
00691 
00692 /* Private functions ---------------------------------------------------------*/
00693 /** @defgroup MMC_Private_Functions MMC Private Functions
00694   * @{
00695   */
00696 
00697 /**
00698   * @}
00699   */
00700 
00701 /**
00702   * @}
00703   */ 
00704 
00705 /**
00706   * @}
00707   */
00708 
00709 /**
00710   * @}
00711   */
00712 
00713 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
00714           STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx ||
00715           STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
00716 
00717 #ifdef __cplusplus
00718 }
00719 #endif
00720 
00721 
00722 #endif /* __STM32F4xx_HAL_MMC_H */ 
00723 
00724 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/