00001 /* ---------------------------------------------------------------------------- */ 00002 /* Atmel Microcontroller Software Support */ 00003 /* SAM Software Package License */ 00004 /* ---------------------------------------------------------------------------- */ 00005 /* Copyright (c) 2015, Atmel Corporation */ 00006 /* */ 00007 /* All rights reserved. */ 00008 /* */ 00009 /* Redistribution and use in source and binary forms, with or without */ 00010 /* modification, are permitted provided that the following condition is met: */ 00011 /* */ 00012 /* - Redistributions of source code must retain the above copyright notice, */ 00013 /* this list of conditions and the disclaimer below. */ 00014 /* */ 00015 /* Atmel's name may not be used to endorse or promote products derived from */ 00016 /* this software without specific prior written permission. */ 00017 /* */ 00018 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */ 00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */ 00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */ 00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */ 00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */ 00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */ 00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */ 00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */ 00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */ 00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ 00028 /* ---------------------------------------------------------------------------- */ 00029 00030 /** 00031 * \dir sdmmc 00032 * 00033 * This directory contains sdmmc drivers 00034 */ 00035 00036 /** 00037 * \page sdmmc_lib SD/MMC Library 00038 * 00039 * \section Purpose 00040 * 00041 * This page describes the library to support SD/MMC card. 00042 * 00043 * \section Contents 00044 * - Scope 00045 * - \subpage sdmmc_identify 00046 * - SD/MMC Data Transfer 00047 * - \subpage sdmmc_write_op 00048 * - \subpage sdmmc_read_op 00049 * - SD/MMC Card Types 00050 * - \subpage sdmmc_sdhc 00051 * - \subpage sdmmc_sdio 00052 * - Hardware access layer 00053 * - \subpage sdmmc_cmd 00054 * - \subpage sdmmc_drv 00055 */ 00056 00057 /** 00058 * \page sdmmc_identify SD/MMC Initialization and Identification 00059 * 00060 * \section Purpose 00061 * 00062 * sdcard sd mode initialization and identification sequence 00063 * 00064 * \section Description 00065 * - Host write bit 3 of function 0, register 6 to reset SDIO card (if there is, using Cmd52). 00066 * - Host sends Cmd0 to do card reset, card is in "idle state". 00067 * - Host sends Cmd8 and checks the response of the card, only sdcard supports physical 00068 * layer version 2.00 will response correctly to Cmd8, and this command is mandatory to be 00069 * sent before ACmd41 for sdcard which support physical layer version 2.00, to enable new 00070 * functions or to validate a dual-voltage card. 00071 * - The response result is saved for future branch after "Host sends Cmd5..". 00072 * - refer to "If Cmd8 response ok" branch for the initialize of sdcard 2.0. 00073 * - refer to "If Cmd8 response fail" branch for the initialize of sdcard 1.x, mmc card, sdcard2.0 00074 * with invalid voltage. 00075 * - Host sends Cmd5 with argument 0 and checks the response of the card, only SDIO card supports this command. 00076 * It starts SDIO initialize. The card returns number of functions in response. 00077 * - refer to "If Cmd5 response ok" branch for the initialize of SDIO card. 00078 * - If Cmd5 response ok 00079 * - Host sends Cmd5 with argument "voltage range" to power up the SDIO card. 00080 * - If the response failed, it means the card does not match the voltage desired 00081 * by the host, SDIO type saved as false. 00082 * - If the response ok, SDIO type saved as true, continue to next step. 00083 * - If Cmd8 response ok 00084 * - Host sends ACmd41* with argument "HCS" equal to "1". 00085 * - If the response to ACmd41 failed, it means the card does not match the voltage 00086 * desired by the host, SD card type saved as true. 00087 * - If the response with "CCS" equal to "1", the card is a version 2.0 high capacity sdcard, 00088 * refer to "Card Initialize" for the succeeding initialize sequence. 00089 * - If the response with "CCS" equal to "0", the card is a version 2.0 standard capacity sdcard. 00090 * refer to "Card Initialize" for the succeeding initialize sequence. 00091 * - If Cmd8 response fail 00092 * - Host sends ACmd41* argument "HCS" equal to "0". 00093 * - If the response to ACmd41 ok, the card is a version 1.x sdcard, refer to "Card Initialize" for 00094 * the succeeding initialize sequence. 00095 * - If the response to ACmd41 fails 00096 * - If SDIO type is true, refer to "Card Initialize". 00097 * - Host sends Cmd0 to reset card. 00098 * - Host sends Cmd1 with argument "hdSupport" equal to "1" to card. 00099 * - If card has response to Cmd1, the card is a MMC card, refer to "Card Initialize" for the 00100 * succeeding initialize sequence. Furthermore, if the response with bit[30:29] equal to 00101 * "00" or "11", the card is a High Density MMC, else the card is a standard MMC. 00102 * - If card has no response to Cmd1, the card is either an unknown card or a card does 00103 * not match host's voltage, the initialize ends. 00104 * - Card Initialize 00105 * - If SD or MMC type is true, Host sends Cmd2 to get the its unique card identification number (CID). 00106 * - Host sends Cmd3 to ask the card to publish a new relative card address (RCA), once the 00107 * RCA is received the card state changes to the "stand-by state". 00108 * - If SD or MMC type is true, Host sends Cmd9 to get the Card Specific Data (CSD). 00109 * - At this stage, the initialization and identification process is over, the following steps are done 00110 * for the sdcard's succeeding operation. 00111 * - SD(HC) or MMC(HD) memory cards 00112 * - Host sends Cmd13 to obtain the card status, make sure the card is "ready-for-data". 00113 * - Host sends Cmd7 to transit card in "transfer state". 00114 * - If card is a sdcard*, hosts send ACmd6 to set bus to 4-wire mode. 00115 * - If card is a mmc card, the bus is set as 1-wire mode. 00116 * - SDIO card 00117 * - the bus is set as 1-wire mode. 00118 * 00119 * \note Send Cmd55 before send ACmd41. 00120 * \note sdcard include ver 1.x sdcard, ver2.0 standard capacity sdcard, ver2.0 high capacity sdcard 00121 */ 00122 00123 /** 00124 * \page sdmmc_write_op SD/MMC Write 00125 * 00126 * \section Purpose 00127 * 00128 * sdcard sd mode write process 00129 * 00130 * \section Description 00131 * - Make sure sdcard is under "transfer state", if the sdcard is under other state, host will send 00132 * Cmd12 to stop the current operation and to transit sdcard to "stand-by state". 00133 * - Host sends Cmd13 to check sdcard's status, to make sure sdcard is "ready-for-data". 00134 * - Host sends Cmd25 to do multiple blocks write, the address here is different between high capacity 00135 * sdcard and normal sdcard, the address of SDHC is equal to the block number, while normal sdcard's 00136 * address is equal to block number times 512. 00137 * 00138 * \section wr_optimize Write Optimization 00139 * - To optimize the write multiple blocks, try to keep the sdcard in the "rcv state" as long as possible. 00140 * after send WRITE_MULTIPLE_BLOCK command, set the block number in the MCI_BLKR as 0, each time a 00141 * new write start, do not re-send the WRITE_MULTIPLE_BLOCK command, just re-configure the PDC. In 00142 * this case, host does not have to send STOP_TRANSMISSION to transfer the sdcard's state and the 00143 * performance is optimized. 00144 * - MoveToTransferState will check the state of the sdcard, and send STOP_TRANSMISSION if need 00145 * to transfer state. Normally this function is called between the state tranfer. 00146 * - ContinuousWrite will be called if WRITE_MULTIPLE_BLOCK already been sent and this function 00147 * will not re-send the write command, but will re-configure PDC accordingly. 00148 */ 00149 00150 /** 00151 * \page sdmmc_read_op SD/MMC Read 00152 * 00153 * \section Purpose 00154 * 00155 * sdcard sd mode read process 00156 * 00157 * \section Description 00158 * - Make sure sdcard is under "transfer state", if the sdcard is under other state, host will send 00159 * Cmd12 to stop the current operation and to transit sdcard to "stand-by state". 00160 * - Host sends Cmd13 to check sdcard's status, to make sure sdcard is "ready-for-data". 00161 * - Host sends Cmd18 to do multiple blocks read, the address here is different between high capacity 00162 * sdcard and normal sdcard, the address of SDHC is equal to the block number, while normal sdcard's 00163 * address is equal to block number times 512. 00164 * 00165 * \section rd_optimize Read Optimization 00166 * - To optimize the read multiple blocks, try to keep the sdcard in the "data state" as long as possible. 00167 * after send READ_MULTIPLE_BLOCK command, set the block number in the MCI_BLKR as 0, each time a 00168 * new read start, do not re-send the READ_MULTIPLE_BLOCK command, just re-configure the PDC. In this 00169 * case, host does not have to send STOP_TRANSMISSION to transfer the sdcard's state and the 00170 * performance is optimized. 00171 * - MoveToTransferState will check the state of the sdcard, and send STOP_TRANSMISSION if need 00172 * to transfer state. Normally this function is called between the state tranfer. 00173 * - ContinuousRead will be called if READ_MULTIPLE_BLOCK already been sent and this function 00174 * will not re-send the read command, but will re-configure PDC accordingly. 00175 */ 00176 00177 /** 00178 * \page sdmmc_sdhc SDHC 00179 * 00180 * \section Purpose 00181 * 00182 * highlight of sdhc 00183 * 00184 * \section sdhc_identify Sdhc initialization and identification 00185 * 00186 * - Refer to page "sdcard sd mode initialization and identification" for the initialization and identification 00187 * sequence of a sdhc. 00188 * 00189 * \section sdhc_diff Functional difference between sdhc and standard capacity sdcard 00190 * 00191 * - Command argument is different: 00192 * - Sdhc uses block address format in memory access commands*, block length is fixed to 512 bytes. 00193 * - Standard capacity sdcard uses byte address format in memory access commands, block length 00194 * is defined in Cmd16. 00195 * - Partial access and misalign access are disabled in sdhc as the block address is used. 00196 * - Sdhc does not support write-protected commands (Cmd28, Cmd29, Cmd30). 00197 * 00198 * \note Memory access commands means block read commands (CMD17, CMD18), block write commands 00199 * (CMD24, CMD25), and block erase commands (CMD32, CMD33). 00200 * 00201 */ 00202 00203 /** \page sdmmc_sdio SDIO 00204 \section Purpose 00205 00206 Highlight of SDIO 00207 00208 \section sdio_init_identiy SDIO initialization and identification 00209 00210 - Refer to page "sdcard sd mode identification and identification" for the initialization and identification 00211 sequence of a SDIO. 00212 00213 00214 */