SAMV71 Xplained Ultra Software Package 1.3

sdmmc_cmd.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         ATMEL Microcontroller Software Support
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2010, Atmel Corporation
00005  *
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions are met:
00010  *
00011  * - Redistributions of source code must retain the above copyright notice,
00012  * this list of conditions and the disclaimer below.
00013  *
00014  * Atmel's name may not be used to endorse or promote products derived from
00015  * this software without specific prior written permission.
00016  *
00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00027  * ----------------------------------------------------------------------------
00028  */
00029 
00030 /** \file */
00031 
00032 /**
00033  * \page sdmmc_lib_cmd SD/MMC Lib Commands
00034  *
00035  * Implementation for SD/MMC low level driver. Supply a set of SD/MMC mode's
00036  * interface.
00037  *
00038  * \section Usage
00039  *
00040  * - Uses following Library definitions in HAL or application:
00041  *   -# \ref sdmmc_cardtype : SD/SDIO/MMC card type definitions.
00042  *   -# \ref sdmmc_rc : Return codes for SD/MMC operation (functions).
00043  *   -# \ref sSdCard : Struct that defined by application for SD/MMC management.
00044  * - Uses following Low Level Definitions in HAL:
00045  *   -# \ref sdmmc_ioctrls : IO control code for HAL implement.
00046  *   -# \ref sdmmc_cmd_op : Command operation code for HAL to implement.
00047  *   -# \ref sSdHalFunctions : HAL functions to implement.
00048  */
00049 
00050  #ifndef _SDMMC_CMD_H
00051  #define _SDMMC_CMD_H
00052 /** \addtogroup sdmmc_cmd
00053  *
00054  *  \copydoc sdmmc_lib_cmd
00055  *
00056  *  See \ref sdmmc_lib_cmd for more details.
00057  *@{
00058  */
00059  
00060 /*------------------------------------------------------------------------------
00061  *      Includes
00062  *----------------------------------------------------------------------------*/
00063 
00064 #include <stdint.h>
00065  
00066 /*------------------------------------------------------------------------------
00067  *      Definitions
00068  *----------------------------------------------------------------------------*/
00069 /** \addtogroup sdmmc_cmd_defines SD/MMC General defines
00070     @{*/
00071 
00072 /**
00073  *  \addtogroup sdmmc_cardtype SD/MMC Card Types
00074  *  Here lists the SD/MMC card types.
00075  *  - Card Type Category Bitmap
00076  *    - \ref CARD_TYPE_bmHC
00077  *    - \ref CARD_TYPE_bmSDMMC
00078  *      - \ref CARD_TYPE_bmUNKNOWN
00079  *      - \ref CARD_TYPE_bmSD
00080  *      - \ref CARD_TYPE_bmMMC
00081  *    - \ref CARD_TYPE_bmSDIO
00082  *  - Card Types
00083  *    - \ref CARD_UNKNOWN
00084  *    - \ref CARD_SD
00085  *    - \ref CARD_SDHC
00086  *    - \ref CARD_MMC
00087  *    - \ref CARD_MMCHD
00088  *    - \ref CARD_SDIO
00089  *    - \ref CARD_SDCOMBO
00090  *    - \ref CARD_SDHCCOMBO
00091  *      @{*/
00092 #define CARD_TYPE_bmHC           (1 << 0)   /**< Bit for High-Capacity(Density) */
00093 #define CARD_TYPE_bmSDMMC        (0x3 << 1) /**< Bits mask for SD/MMC */
00094 #define CARD_TYPE_bmUNKNOWN      (0x0 << 1) /**< Bits for Unknown card */
00095 #define CARD_TYPE_bmSD           (0x1 << 1) /**< Bits for SD */
00096 #define CARD_TYPE_bmMMC          (0x2 << 1) /**< Bits for MMC */
00097 #define CARD_TYPE_bmSDIO         (1 << 3)   /**< Bit for SDIO */
00098 /** Card can not be identified */
00099 #define CARD_UNKNOWN    (0)
00100 /** SD Card (0x2) */
00101 #define CARD_SD         (CARD_TYPE_bmSD)
00102 /** SD High Capacity Card (0x3) */
00103 #define CARD_SDHC       (CARD_TYPE_bmSD|CARD_TYPE_bmHC)
00104 /** MMC Card (0x4) */
00105 #define CARD_MMC        (CARD_TYPE_bmMMC)
00106 /** MMC High-Density Card (0x5) */
00107 #define CARD_MMCHD      (CARD_TYPE_bmMMC|CARD_TYPE_bmHC)
00108 /** SDIO only card (0x8) */
00109 #define CARD_SDIO       (CARD_TYPE_bmSDIO)
00110 /** SDIO Combo, with SD embedded (0xA) */
00111 #define CARD_SDCOMBO    (CARD_TYPE_bmSDIO|CARD_SD)
00112 /** SDIO Combo, with SDHC embedded (0xB) */
00113 #define CARD_SDHCCOMBO  (CARD_TYPE_bmSDIO|CARD_SDHC)
00114 /**     @}*/
00115 
00116 /**
00117  *  \addtogroup sdmmc_rc SD/MMC Return Codes
00118  *  Here lists the SD/MMC driver return codes.
00119  *  - \ref SDMMC_ERROR
00120  *  - \ref SDMMC_ERROR_NORESPONSE
00121  *  - \ref SDMMC_ERROR_NOT_INITIALIZED
00122  *  - \ref SDMMC_ERROR_BUSY
00123  *  - \ref SDMMC_ERROR_PARAM
00124  *  - \ref SDMMC_ERROR_NOT_SUPPORT
00125  *  - \ref SDMMC_OK
00126  *  - \ref SDMMC_ERROR_LOCKED
00127  *      @{*/
00128 
00129 /** SD/MMC Return codes */
00130 typedef enum {
00131     SDMMC_OK = 0,           /**< Operation OK */
00132     SDMMC_LOCKED = 1,       /**< Failed because driver locked */
00133     SDMMC_BUSY = 2,         /**< Failed because driver busy */
00134     SDMMC_NO_RESPONSE = 3,  /**< Failed because card not respond */
00135     SDMMC_CHANGED,          /**< Setting param changed due to limitation */
00136     SDMMC_ERR,              /**< Failed with general error */
00137     SDMMC_ERR_IO,           /**< Failed because of IO error */
00138     SDMMC_ERR_RESP,         /**< Error reported in response code */
00139     SDMMC_NOT_INITIALIZED,  /**< Fail to initialize */
00140     SDMMC_PARAM,            /**< Parameter error */
00141     SDMMC_STATE,            /**< State error */
00142     SDMMC_USER_CANCEL,      /**< Canceled by user */
00143     SDMMC_NOT_SUPPORTED     /**< Command(Operation) not supported */
00144 } eSDMMC_RC;
00145 
00146 /** No error */
00147 #define SDMMC_SUCCESS               SDMMC_OK
00148 /** The driver is locked. */
00149 #define SDMMC_ERROR_LOCKED          SDMMC_LOCKED
00150 /** There was an error with the SD driver. */
00151 #define SDMMC_ERROR                 SDMMC_ERR
00152 /** The SD card did not answer the command. */
00153 #define SDMMC_ERROR_NORESPONSE      SDMMC_NO_RESPONSE
00154 /** The SD card is not initialized. */
00155 #define SDMMC_ERROR_NOT_INITIALIZED SDMMC_NOT_INITIALIZED
00156 /** The SD card is busy. */
00157 #define SDMMC_ERROR_BUSY            SDMMC_BUSY
00158 /** The input parameter error */
00159 #define SDMMC_ERROR_PARAM           SDMMC_PARAM
00160 /** Invalid state */
00161 #define SDMMC_ERROR_STATE           SDMMC_STATE
00162 /** User canceled */
00163 #define SDMMC_ERROR_USER_CANCEL     SDMMC_USER_CANCEL
00164 /** The operation is not supported. */
00165 #define SDMMC_ERROR_NOT_SUPPORT     SDMMC_NOT_SUPPORTED
00166 /**     @}*/
00167 
00168 /**
00169  *  \addtogroup sdmmc_states SD/MMC Card States
00170  *      @{
00171  */
00172 #define SDMMC_STATE_OFF             0x0 /**< Power OFF */
00173 #define SDMMC_STATE_ON              0x1 /**< Power ON */
00174 #define SDMMC_STATE_IDENT           0x2 /**< Card Identification (IDLE,READY,IDENT) */
00175 #define SDMMC_STATE_INACTIVE        0x3 /**< Inactive */
00176 #define SDMMC_STATE_IRQ             0x4 /**< Wait-IRQ, interrupt mode */
00177 #define SDMMC_STATE_STBY            0x5 /**< Addressed */
00178 #define SDMMC_STATE_TRAN            0x6 /**< Ready for transfer */
00179 #define SDMMC_STATE_DATA_WR         0x7 /**< Data TX in progress */
00180 #define SDMMC_STATE_DATA_RD         0x8 /**< Data RX in progress */
00181 /**     @}*/
00182 
00183 /** \ingroup sdmmc_hal_def
00184  *  \addtogroup sdmmc_ioctrls SD/MMC IO Control Codes
00185  *  Here lists the control codes for SD/MMC low level driver to support lib.
00186  *  - \ref SDMMC_IOCTL_POWER: Power ON/OFF control.
00187  *  - \ref SDMMC_IOCTL_SET_CLOCK: Set clock and return actual clock.
00188  *  - \ref SDMMC_IOCTL_GET_BUSMODE: Return max supported bus mode.
00189  *  - \ref SDMMC_IOCTL_GET_HSMODE: Return if HS mode is supported.
00190  *  - \ref SDMMC_IOCTL_GET_BOOTMODE: Return if Boot mode is supported.
00191  *      @{*/
00192 /** SD/MMC Low Level IO Control: Check busy.
00193     Must implement for low level driver busy check.
00194     IOCtrl(pSd, SDMMC_IOCTL_BUSY_CHECK, (uint32_t)pBusyFlag) */
00195 #define SDMMC_IOCTL_BUSY_CHECK    0x0
00196 /** SD/MMC Low Level IO Control: Power control.
00197     Recomended for SD/MMC/SDIO power control.
00198     IOCtrl(pSd, SDMMC_IOCTL_POWER, (uint32_t)ON/OFF) */
00199 #define SDMMC_IOCTL_POWER         0x1
00200 /** SD/MMC Low Level IO Control: Cancel command.
00201     IOCtrl(pSd, SDMMC_IOCTL_CANCEL_CMD, NULL) */
00202 #define SDMMC_IOCTL_CANCEL_CMD    0x2
00203 /** SD/MMC Low Level IO Control: Reset & disable HW.
00204     IOCtrl(pSd, SDMMC_IOCTL_RESET, NULL) */
00205 #define SDMMC_IOCTL_RESET         0x3
00206 /** SD/MMC Low Level IO Control: Set clock frequency, return applied frequency
00207     Recomended for clock selection
00208     IOCtrl(pSd, SDMMC_IOCTL_SET_CLOCK, (uint32_t*)pIoFreq) */
00209 #define SDMMC_IOCTL_SET_CLOCK     0x11
00210 /** SD/MMC Low Level IO Control: Set bus mode, return applied mode
00211     Recomended for bus mode selection
00212     IOCtrl(pSd, SDMMC_IOCTL_SET_BUSMODE, (uint32_t*)pIoBusMode) */
00213 #define SDMMC_IOCTL_SET_BUSMODE   0x12
00214 /** SD/MMC Low Level IO Control: Set HS mode, return applied mode
00215     Recommended for HS mode enable
00216     IOCtrl(pSd, SDMMC_IOCTL_SET_BUSMODE, (uint32_t*)pIoHsMode) */
00217 #define SDMMC_IOCTL_SET_HSMODE    0x13
00218 /** SD/MMC Low Level IO Control: Set Boot mode */
00219 #define SDMMC_IOCTL_SET_BOOTMODE  0x14
00220 /** SD/MMC Low Level IO Control: Get clock frequency */
00221 #define SDMMC_IOCTL_GET_CLOCK     0x21
00222 /** SD/MMC Low Level IO Control: Bus mode */
00223 #define SDMMC_IOCTL_GET_BUSMODE   0x22
00224 /** SD/MMC Low Level IO Control: High-speed mode */
00225 #define SDMMC_IOCTL_GET_HSMODE    0x23
00226 /** SD/MMC Low Level IO Control: Boot mode */
00227 #define SDMMC_IOCTL_GET_BOOTMODE  0x24
00228 /**     @}*/
00229 
00230 /** \ingroup sdmmc_hal_def
00231  *  \addtogroup sdmmc_cmd_op SD/MMC Command Operations
00232  *      @{
00233  */
00234 #define SDMMC_CMD_bmPOWERON     (0x1      ) /**< Do Power ON sequence */
00235 #define SDMMC_CMD_bmCOMMAND     (0x1 <<  1) /**< Send command */
00236 #define SDMMC_CMD_bmDATAMASK    (0x3 <<  2) /**< Data operation mask */
00237 #define SDMMC_CMD_bmNODATA      (0x0 <<  2) /**< No data transfer */
00238 #define SDMMC_CMD_RX             0x1        /**< data RX */
00239 #define SDMMC_CMD_bmDATARX      (0x1 <<  2) /**< Bits for data RX */
00240 #define SDMMC_CMD_TX             0x2        /**< data TX */
00241 #define SDMMC_CMD_bmDATATX      (0x2 <<  2) /**< Bits for data TX */
00242 #define SDMMC_CMD_STOPXFR        0x3        /**< data stop */
00243 #define SDMMC_CMD_bmSTOPXFR     (0x3 <<  2) /**< Bits for transfer stop */
00244 #define SDMMC_CMD_bmRESPMASK    (0x7 <<  4) /**< Bits masks response option */
00245 #define SDMMC_CMD_bmRESP(R)     (((R)&0x7) << 4)    /**< Bits setup response */
00246 
00247 #define SDMMC_CMD_bmCRC         (0x1 <<  7) /**< CRC is enabled (SPI only) */
00248 #define SDMMC_CMD_bmOD          (0x1 <<  8) /**< Open-Drain is enabled (MMC) */
00249 #define SDMMC_CMD_bmIO          (0x1 <<  9) /**< IO function */
00250 #define SDMMC_CMD_bmBUSY        (0x1 << 10) /**< Do busy check */
00251 /** Cmd: Do power on initialize */
00252 #define SDMMC_CMD_POWERONINIT   (SDMMC_CMD_bmPOWERON)
00253 /** Cmd: Data only, read */
00254 #define SDMMC_CMD_DATARX        (SDMMC_CMD_bmDATARX)
00255 /** Cmd: Data only, write */
00256 #define SDMMC_CMD_DATATX        (SDMMC_CMD_bmDATATX)
00257 /** Cmd: Command without data */
00258 #define SDMMC_CMD_CNODATA(R)    ( SDMMC_CMD_bmCOMMAND \
00259                                 | SDMMC_CMD_bmRESP(R) )
00260 /** Cmd: Command with data, read */
00261 #define SDMMC_CMD_CDATARX(R)    ( SDMMC_CMD_bmCOMMAND \
00262                                 | SDMMC_CMD_bmDATARX \
00263                                 | SDMMC_CMD_bmRESP(R) )
00264 /** Cmd: Command with data, write */
00265 #define SDMMC_CMD_CDATATX(R)    ( SDMMC_CMD_bmCOMMAND \
00266                                 | SDMMC_CMD_bmDATATX \
00267                                 | SDMMC_CMD_bmRESP(R) )
00268 /** Cmd: Send Stop command */
00269 #define SDMMC_CMD_CSTOP         ( SDMMC_CMD_bmCOMMAND \
00270                                 | SDMMC_CMD_bmSTOPXFR \
00271                                 | SDMMC_CMD_bmRESP(1) )
00272 /** Cmd: Send Stop token for SPI */
00273 #define SDMMC_CMD_STOPTOKEN     (SDMMC_CMD_bmSTOPXFR)
00274 /**     @}*/
00275 
00276 /** Default block size for SD/MMC access */
00277 #define SDMMC_BLOCK_SIZE        512
00278 
00279 /** @}*/
00280 /*------------------------------------------------------------------------------
00281  *      Types
00282  *----------------------------------------------------------------------------*/
00283 /** \addtogroup sdmmc_cmd_types SD/MMC General Types
00284     @{*/
00285 
00286 /** SD/MMC end-of-command callback function. */
00287 typedef void (*fSdmmcCallback)(uint32_t status, void *pArg);
00288 
00289 /**
00290  * Sdmmc command operation settings union.
00291  */
00292 typedef union _SdmmcCmdOperation {
00293     uint16_t wVal;
00294     struct _SdmmcOpBm {
00295         uint16_t powerON:1, /**< Do power on initialize */
00296                  sendCmd:1, /**< Send SD/MMC command */
00297                  xfrData:2, /**< Send/Stop data transfer */
00298                  respType:3,/**< Response type (1~7) */
00299                  crcON:1,   /**< CRC is used (SPI) */
00300                  odON:1,    /**< Open-Drain is ON (MMC) */
00301                  ioCmd:1,   /**< SDIO command */
00302                  checkBsy:1;/**< Busy check is ON */
00303     } bmBits;
00304 } uSdmmcCmdOp;
00305 
00306 /**
00307  * Sdmmc command instance.
00308  */
00309 typedef struct _SdmmcCommand {
00310 
00311     /** Optional user-provided callback function. */
00312     fSdmmcCallback  fCallback;
00313     /** Optional argument to the callback function. */
00314     void            *pArg;
00315 
00316     /** Data buffer, with MCI_DMA_ENABLE defined 1, the buffer can be
00317      * 1, 2 or 4 bytes aligned. It has to be 4 byte aligned if no DMA.
00318      */
00319     uint8_t     *pData;
00320     /** Size of data block in bytes. */
00321     uint16_t    wBlockSize;
00322     /** Number of blocks to be transfered */
00323     uint16_t    wNbBlocks;
00324     /** Response buffer. */
00325     uint32_t    *pResp;
00326 
00327     /** Command argument. */
00328     uint32_t    dwArg;
00329     /** Command operation settings */
00330     uSdmmcCmdOp cmdOp;
00331     /** Command index */
00332     uint8_t     bCmd;
00333     /** Command return status */
00334     uint8_t     bStatus;
00335 } sSdmmcCommand;
00336 
00337 /**
00338  * \ingroup sdmmc_hal_def
00339  * SD/MMC Lock device function type */
00340 typedef uint32_t (*fSdmmcLock)(void* pDrv, uint8_t bSlot);
00341 /**
00342  * \ingroup sdmmc_hal_def
00343  * SD/MMC Release device function type */
00344 typedef uint32_t (*fSdmmcRelease)(void* pDrv);
00345 /**
00346  * \ingroup sdmmc_hal_def
00347  * SD/MMC Send Command function type */
00348 typedef uint32_t (*fSdmmcSendCommand)(void* pDrv, sSdmmcCommand *pCmd);
00349 /**
00350  * \ingroup sdmmc_hal_def
00351  * SD/MMC IO Control function type */
00352 typedef uint32_t (*fSdmmcIOCtrl)(void* pDrv, uint32_t dwCtrl, uint32_t param);
00353 
00354 /**
00355  * \ingroup sdmmc_hal_def
00356  * \brief SD/MMC card HAL functions.
00357  */
00358 typedef struct _SdHalFunctions {
00359     
00360     fSdmmcLock fLock;           /**< Pointer to lock funtion */
00361     fSdmmcRelease fRelease;     /**< Pointer to release function */
00362     fSdmmcSendCommand fCommand; /**< Pointer to command function */
00363     fSdmmcIOCtrl fIOCtrl;       /**< Pointer to IO control function */
00364 } sSdHalFunctions;
00365 
00366 /**
00367  * \brief SD/MMC card driver structure.
00368  * It holds the current command being processed and the SD/MMC card address.
00369  */
00370 typedef struct _SdCard
00371 {
00372     void *pDrv;             /**< Pointer to unnderlying driver */
00373     sSdHalFunctions *pHalf; /**< Pointer to underlying functions */
00374     void *pExt;             /**< Pointer to extension data for SD/MMC/SDIO */
00375 
00376     sSdmmcCommand sdCmd;    /**< Command instance for underlying driver */
00377 
00378     uint32_t CID[128/8/4];  /**< Card Identification (CID register) */
00379     uint32_t CSD[128/8/4];  /**< Card-specific data (CSD register) */
00380     uint32_t EXT[512/4];    /**< Extended information */
00381 
00382     uint32_t dwTranSpeed;   /**< Max supported transfer speed */
00383     uint32_t dwTotalSize;   /**< Card total size
00384                                 (0xffffffff to see number of blocks */
00385     uint32_t dwNbBlocks;    /**< Card total number of blocks */
00386     uint16_t wBlockSize;    /**< Card block size reported */
00387 
00388     uint16_t wCurrBlockLen; /**< Block length used */
00389     uint32_t dwCurrSpeed;   /**< Transfer speed used */
00390     uint32_t dwPrevBlk;     /**< Previous accessed block for memory */
00391     uint16_t wAddress;      /**< Current card address */
00392     uint8_t  bCardType;     /**< SD/MMC/SDIO card type \sa sdmmc_cardtype */
00393     uint8_t  bBusMode;      /**< 1/4/8 bit bus mode */
00394     uint8_t  bSlot;         /**< Card access slot */
00395     uint8_t  bState;        /**< Card state */
00396     uint8_t  bStatus;       /**< Card status */
00397     uint8_t  reserve;
00398 } sSdCard;
00399 
00400 
00401 /** \addtogroup sdmmc_struct_cmdarg SD/MMC command arguments
00402  *  Here lists the command arguments for SD/MMC.
00403  *  - CMD6 Argument
00404  *    - \ref _MmcCmd6Arg "MMC CMD6"
00405  *    - \ref _SdCmd6Arg  "SD CMD6"
00406  *  - \ref _SdioCmd52Arg CMD52
00407  *  - \ref _SdioCmd53Arg CMD53
00408  *      @{*/
00409 /**
00410  * \typedef MmcCmd6Arg
00411  * Argument for MMC CMD6
00412  */
00413 typedef struct _MmcCmd6Arg
00414 {
00415     uint8_t access;
00416     uint8_t index;
00417     uint8_t value;
00418     uint8_t cmdSet;
00419 } MmcCmd6Arg, MmcSwitchArg;
00420 
00421 /**
00422  * \typedef SdCmd6Arg
00423  * Argument for SD CMD6
00424  */
00425 typedef struct _SdCmd6Arg
00426 {
00427     uint32_t accessMode:4,  /**< [ 3: 0] function group 1, access mode */
00428              command:4,     /**< [ 7: 4] function group 2, command system */
00429              reserveFG3:4,  /**< [11: 8] function group 3, 0xF or 0x0 */
00430              reserveFG4:4,  /**< [15:12] function group 4, 0xF or 0x0 */
00431              reserveFG5:4,  /**< [19:16] function group 5, 0xF or 0x0 */
00432              reserveFG6:4,  /**< [23:20] function group 6, 0xF or 0x0 */
00433              reserved:7,    /**< [30:24] reserved 0 */
00434              mode:1;        /**< [31   ] Mode, 0: Check, 1: Switch */
00435 } SdCmd6Arg, SdSwitchArg;
00436 
00437 /**
00438  * \typedef SdioCmd52Arg
00439  * Argument for SDIO CMD52
00440  */
00441 typedef struct _SdioCmd52Arg
00442 {
00443     uint32_t data:8,        /**< [ 7: 0] data for writing */
00444              stuff0:1,      /**< [    8] reserved */
00445              regAddress:17, /**< [25: 9] register address */
00446              stuff1:1,      /**< [   26] reserved */
00447              rawFlag:1,     /**< [   27] Read after Write flag */
00448              functionNum:3, /**< [30:28] Number of the function */
00449              rwFlag:1;      /**< [   31] Direction, 1:write, 0:read. */
00450 } SdioCmd52Arg, SdioRwDirectArg;
00451 /**
00452  * \typedef SdioCmd53Arg
00453  * Argument for SDIO CMD53
00454  */
00455 typedef struct _SdioCmd53Arg {
00456     uint32_t count:9,       /**< [ 8: 0] Byte mode: number of bytes to transfer,
00457                                                    0 cause 512 bytes transfer.
00458                                          Block mode: number of blocks to transfer,
00459                                                     0 set count to infinite. */
00460              regAddress:17, /**< [25: 9] Start Address I/O register */
00461              opCode:1,      /**< [   26] 1:Incrementing address, 0: fixed */
00462              blockMode:1,   /**< [   27] (Optional) 1:block mode */
00463              functionNum:3, /**< [30:28] Number of the function */
00464              rwFlag:1;      /**< [   31] Direction, 1:WR, 0:RD */
00465 } SdioCmd53Arg, SdioRwExtArg;
00466 /**     @}*/
00467 
00468 
00469 /** \addtogroup sdmmc_resp_struct SD/MMC Responses Structs
00470  *  Here lists the command responses for SD/MMC.
00471  *  - \ref _SdmmcR1 "R1"
00472  *  - \ref _SdmmcR3 "R3"
00473  *  - \ref _MmcR4 "MMC R4", \ref _SdioR4 "SDIO R4"
00474  *  - \ref _SdmmcR5 "R5"
00475  *  - \ref _SdR6 "R6"
00476  *  - \ref _SdR7 "R7"
00477  *      @{*/
00478 /**
00479  * Response R1 (normal response command)
00480  */
00481 typedef struct _SdmmcR1
00482 {
00483     uint32_t cardStatus;    /**< [32: 0] Response card status flags */
00484 } SdmmcR1, SdmmcR1b;
00485 
00486 /**
00487  * Response R3 (OCR)
00488  */
00489 typedef struct _SdmmcR3
00490 {
00491     uint32_t OCR;           /**< [32: 0] OCR register */
00492 } SdmmcR3;
00493 
00494 /**
00495  * Response R4 (MMC Fast I/O CMD39)
00496  */
00497 typedef struct _MmcR4
00498 {
00499     uint32_t regData:8,     /**< [ 7: 0] Read register contents */
00500              regAddr:7,     /**< [14: 8] Register address */
00501              status:1,      /**< [   15] Status */
00502              RCA:16;        /**< [31:16] RCA */
00503 } MmcR4;
00504 
00505 /**
00506  * Response R4 (SDIO), no CRC.
00507  */
00508 typedef struct _SdioR4
00509 {
00510     uint32_t OCR:24,            /**< [23: 0]       Operation Conditions Register */
00511              reserved:3,        /**< [26:24]       Reserved */
00512              memoryPresent:1,   /**< [   27] MP    Set to 1 if contains
00513                                                    SD memory */
00514              nbIoFunction:3,    /**< [30:28] NF    Total number of I/O functions
00515                                                    supported */
00516              C:1;               /**< [   31] IORDY Set to 1 if card is ready */
00517 } SdioR4;
00518 
00519 /**
00520  * Response R5 (MMC Interrupt request CMD40 / SDIO CMD52)
00521  */
00522 typedef struct _SdmmcR5
00523 {
00524     uint32_t data:8,        /**< [ 7: 0] Response data */
00525              response:8,    /**< [15: 8] Response status flags */
00526              RCA:16;        /**< [31:16] (MMC) Winning card RCA */
00527 } SdmmcR5;
00528 
00529 /**
00530  * Response R6 (SD RCA)
00531  */
00532 typedef struct _SdR6
00533 {
00534     uint32_t status:16,     /**< [15: 0] Response status */
00535              RCA:16;        /**< [31:16] New published RCA */
00536 } SdR6;
00537 /**
00538  * Response R7 (Card interface condition)
00539  */
00540 typedef struct _SdR7 {
00541     uint32_t checkPatten:8, /**< [ 7: 0] Echo-back of check pattern */
00542              voltage:4,     /**< [11: 8] Voltage accepted */
00543              reserved:20;   /**< [31:12] reserved bits */
00544 } SdR7;
00545 
00546 /**     @}*/
00547 
00548 /** @}*/
00549 /*----------------------------------------------------------------------------
00550  *         Exported functions
00551  *----------------------------------------------------------------------------*/
00552 
00553 /**@}*/
00554 #endif /* #define _SDMMC_CMD_H */
00555 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines