SAMV71 Xplained Ultra Software Package 1.5

main.c

Go to the documentation of this file.
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  * \page hsmci_sdcard Basic SD/MMC Card Example
00032  *
00033  * \section Purpose
00034  *
00035  *  The hsmci_sdcard will help you to get familiar with HSMCI interface on
00036  *  SAM Microcontrollers. It can also help you to get familiar with the SD
00037  *  operation flow which can be used for fast implementation of your own SD
00038  *  drivers and other applications related.
00039  *
00040  *  \section Requirements
00041  *
00042  *  This package can be used with SAMV71 Xplained Ultra board or SAME70 Xplained board.
00043  *
00044  *  \section Description
00045  *
00046  *  The demonstration program detects, initialize the SD/MMC memory card
00047  *  inserted, and performs R/W test on it.
00048  *
00049  *  Open HyperTerminal before running this program, use SAM-BA to download
00050  *  this program to SRAM or Flash, make the program run, the HyperTerminal
00051  *  will give out the test results.
00052  *
00053  *  \section Usage
00054  *
00055  *  -# Build the program and download it inside the board.
00056  *     Please refer to the Getting Started with SAM V71/E70 Microcontrollers.pdf
00057  *  -# On the computer, open and configure a terminal application
00058  *     (e.g. HyperTerminal on Microsoft Windows) with these settings:
00059  *    - 115200 bauds
00060  *    - 8 bits of data
00061  *    - No parity
00062  *    - 1 stop bit
00063  *    - No flow control
00064  *  -# Start the application
00065  *  -# In HyperTerminal, it will show something like
00066  *      \code
00067  *      -- HSMCI SD/MMC Example xxx --
00068  *      -- SAMxxxxx-xx
00069  *      -- Compiled: xxx xx xxxx xx:xx:xx --
00070  *      -I- Please connect a SD card ...
00071  *      -I- SD card connection detected
00072  *      -I- Cannot check if SD card is write-protected
00073  *      -I- SD/MMC card initialization successful
00074  *      -I- Card size: *** MB
00075  *      -I- Block size: *** Bytes
00076  *      -I- Testing block [  *** -   ***] ..."
00077  *      \endcode
00078  *
00079  *  \section References
00080  *  - hsmci_sdcard/main.c
00081  *  - hsmci.h
00082  *  - pio.h
00083  *
00084  */
00085 
00086 /**
00087  *  \file
00088  *
00089  *  \section Purpose
00090  *
00091  *  This file contains all the specific code for the hsmci_sdcard example.
00092  *
00093  *  \section Contents
00094  *  The hsmci_sdcard application can be roughly broken down as follows:
00095  *     - Optional functions
00096  *        - CheckProtection
00097  *        - WaitSdConn
00098  *     - Interrupt handlers
00099  *        - ISR_Mci0
00100  *     - The main function, which implements the program behaviour
00101  *        - I/O configuration
00102  *        - SD card auto-detect and check whether SD card is write-protected
00103  *          (if supported)
00104  *        - Initialize MCI interface and installing an isr relating to MCI
00105  *        - Initialize sdcard, get necessary sdcard's parameters
00106  *        - write/read sdcard at max available SD clock
00107  */
00108 /*----------------------------------------------------------------------------
00109  *         Headers
00110  *----------------------------------------------------------------------------*/
00111 
00112 #include "board.h"
00113 
00114 #include "libsdmmc.h"
00115 #include "Media.h"
00116 #include <stdint.h>
00117 #include <stdio.h>
00118 #include <string.h>
00119 #include <assert.h>
00120 
00121 /*----------------------------------------------------------------------------
00122  *         Local definitions
00123  *----------------------------------------------------------------------------*/
00124 
00125 /** Maximum number of blocks read once */
00126 #define NB_MULTI_BLOCKS     5
00127 
00128 /** Split R/W to 2, first R/W 4 blocks then remaining */
00129 #define NB_SPLIT_MULTI      4
00130 
00131 /** Test settings: start block address (0) */
00132 #define TEST_BLOCK_START    (0)
00133 
00134 /** Test settings: end block address (total SD/MMC) */
00135 #define TEST_BLOCK_END      SD_GetNumberBlocks(&sdDrv[bMciID])
00136 
00137 /** Test settings: skip size when "skip" key pressed */
00138 #define TEST_BLOCK_SKIP     (100 * 1024 * 2)    // 100M
00139 
00140 /**  Number of errors displayed */
00141 #define NB_ERRORS           5
00142 
00143 /*----------------------------------------------------------------------------
00144  *         Local variables
00145  *----------------------------------------------------------------------------*/
00146 
00147 /** DMA driver instance */
00148 
00149 static sXdmad dmaDrv;
00150 
00151 /** MCI driver instance. */
00152 static sMcid mciDrv[BOARD_NUM_MCI];
00153 
00154 /** SDCard driver instance. */
00155 
00156 COMPILER_ALIGNED(32) static sSdCard sdDrv[BOARD_NUM_MCI];
00157 
00158 /** Current selected MCI interface */
00159 static uint8_t bMciID = 0;
00160 
00161 /** SD card pins instance. */
00162 static const Pin pinsSd[] = {BOARD_MCI_PINS_SLOTA, BOARD_MCI_PIN_CK};
00163 
00164 /** SD card detection pin instance. */
00165 static const Pin pinsCd[] = {BOARD_MCI_PIN_CD};
00166 
00167 COMPILER_ALIGNED(32) static uint8_t pBuffer[SDMMC_BLOCK_SIZE * NB_MULTI_BLOCKS];
00168 
00169 /** Number of errors found */
00170 static uint32_t nbErrors;
00171 /*----------------------------------------------------------------------------
00172  *         Local macros
00173  *----------------------------------------------------------------------------*/
00174 
00175 /* Defined to test Multi-Block functions */
00176 
00177 /** \def READ_MULTI
00178  *  \brief Define to test multi-read (SD_Read())
00179  *         or
00180  *         single-read is used (SD_ReadBlocks()) */
00181 #define READ_MULTI
00182 /** \def WRITE_MULTI
00183  *  \brief Define to test multi-write (SD_Write())
00184  *         or
00185  *         single-write is used (SD_WriteBlocks()) */
00186 #define WRITE_MULTI
00187 
00188 /** \macro SDT_ReadFun
00189  * Function used for SD card test reading.
00190  * \param pSd  Pointer to a SD card driver instance.
00191  * \param address  Address of the block to read.
00192  * \param nbBlocks Number of blocks to be read.
00193  * \param pData    Data buffer whose size is at least the block size.
00194  */
00195 #ifdef  READ_MULTI
00196 #define MMCT_ReadFun(pSd, blk, nbBlk, pData) \
00197     SD_Read(pSd, blk, pData, nbBlk, NULL, NULL)
00198 #else
00199 #define MMCT_ReadFun(pSd, blk, nbBlk, pData) \
00200     SD_ReadBlocks(pSd, blk, pData, nbBlk)
00201 #endif
00202 
00203 /** \macro SDT_WriteFun
00204  * Function used for SD card test writing.
00205  * \param pSd  Pointer to a SD card driver instance.
00206  * \param address  Address of the block to read.
00207  * \param nbBlocks Number of blocks to be read.
00208  * \param pData    Data buffer whose size is at least the block size.
00209  */
00210 #ifdef  WRITE_MULTI
00211 #define MMCT_WriteFun(pSd, blk, nbBlk, pData) \
00212     SD_Write(pSd, blk, pData, nbBlk, NULL, NULL)
00213 #else
00214 #define MMCT_WriteFun(pSd, blk, nbBlk, pData) \
00215     SD_WriteBlocks(pSd, blk, pData, nbBlk)
00216 #endif
00217 
00218 /*----------------------------------------------------------------------------
00219  *         Local functions
00220  *----------------------------------------------------------------------------*/
00221 
00222 /**
00223  * DMA interrupt handler.
00224  */
00225 void XDMAC_Handler(void)
00226 {
00227     XDMAD_Handler(&dmaDrv);
00228 }
00229 
00230 /**
00231  * MCI interrupt handler. Forwards the event to the MCI driver handlers.
00232  */
00233 void HSMCI_Handler(void)
00234 {
00235     MCID_Handler(&mciDrv[0]);
00236 }
00237 
00238 /*----------------------------------------------------------------------------
00239  *         Optional: SD card detection (connection, protection)
00240  *----------------------------------------------------------------------------*/
00241 
00242 /**
00243  * Configure for SD detect pin
00244  */
00245 static void CardDetectConfigure(void)
00246 {
00247     PIO_Configure(pinsCd, PIO_LISTSIZE(pinsCd));
00248     /* No protection detect pin */
00249 }
00250 
00251 /**
00252  * Return 1 if card is inserted.
00253  */
00254 static uint8_t CardIsConnected(uint8_t iMci)
00255 {
00256     return PIO_Get(&pinsCd[iMci]) ? 0 : 1;
00257 }
00258 
00259 /**
00260  * Return 1 if any card is inserted.
00261  */
00262 static uint8_t AnyCardIsConnected(void)
00263 {
00264     uint32_t i;
00265 
00266     for (i = 0; i < BOARD_NUM_MCI; i ++) {
00267         if (CardIsConnected(i))
00268             return 1;
00269     }
00270 
00271     return 0;
00272 }
00273 
00274 /**
00275  * Return 1 if card is protected.
00276  */
00277 static uint8_t CardIsProtected(void)
00278 {
00279     printf("-I- Cannot check if SD card is write-protected\n\r");
00280     return 0;
00281 }
00282 
00283 /**
00284  * Delay some loop
00285  */
00286 static void LoopDelay(volatile unsigned int loop)
00287 {
00288     for (; loop > 0; loop --);
00289 }
00290 
00291 /**
00292  * \brief Max Error Break
00293  * Check if max number of error achieved.
00294  * \param halt Whether halt the device if error number achieved.
00295  */
00296 static uint8_t MaxErrorBreak(uint8_t halt)
00297 {
00298     if (NB_ERRORS) {
00299         if (nbErrors ++ > NB_ERRORS) {
00300             while (halt);
00301 
00302             nbErrors = 0;
00303             return 1;
00304         }
00305     }
00306 
00307     return 0;
00308 }
00309 
00310 /**
00311  * Display: Dump Splitting row
00312  */
00313 static void DumpSeperator(void)
00314 {
00315     printf("\n\r==========================================\n\r");
00316 }
00317 
00318 /**
00319  * Dump card registers
00320  * \param slot Card slot (not used now).
00321  */
00322 static void DumpCardInfo(uint8_t iMci)
00323 {
00324     sSdCard *pSd = &sdDrv[iMci];
00325 
00326     if (SD_GetCardType(pSd) & CARD_TYPE_bmSDIO)
00327         SDIO_DumpCardInformation(pSd);
00328 
00329     if (SD_GetCardType(pSd) & CARD_TYPE_bmSDMMC) {
00330         SD_DumpCID(pSd->CID);
00331         SD_DumpCSD(pSd->CSD);
00332     }
00333 }
00334 
00335 /**
00336  * Run tests on the inserted card
00337  * \param slot Card slot (not used now).
00338  */
00339 static uint8_t CardInit(uint8_t iMci)
00340 {
00341     sSdCard *pSd = &sdDrv[iMci];
00342     uint8_t error;
00343     uint8_t retry = 2;
00344 
00345     DumpSeperator();
00346 
00347     while (retry --) {
00348         error = SD_Init(pSd);
00349 
00350         if (error == SDMMC_OK) break;
00351     }
00352 
00353     if (error) {
00354         printf("-E- SD/MMC card initialization failed: %d\n\r", error);
00355         return 1;
00356     }
00357 
00358     printf("-I- SD/MMC card initialization successful\n\r");
00359     printf("-I- Card size: %d MB", (int)SD_GetTotalSizeKB(pSd) / 1000);
00360     printf(", %d * %dB\n\r",
00361            (int)SD_GetNumberBlocks(pSd), (int)SD_GetBlockSize(pSd));
00362     DumpCardInfo(iMci);
00363     return 0;
00364 }
00365 
00366 /**
00367  * Disk test
00368  * \param slot Card slot (not used now).
00369  * \param clr  Do block clear.
00370  * \param wr   Do block write.
00371  * \param rd   Do block read.
00372  */
00373 static void DiskTest(uint8_t iMci,
00374                      uint8_t clr,
00375                      uint8_t wr,
00376                      uint8_t rd)
00377 {
00378     sSdCard *pSd = &sdDrv[iMci];
00379     uint8_t error = 0;
00380     uint32_t i, errcnt = 0;
00381     uint32_t multiBlock, block, splitMulti;
00382 
00383     DumpSeperator();
00384 
00385     if (pSd->bCardType == CARD_SDIO) {
00386         printf("-!- SDIO only card, please run SDIO example\n\r");
00387         return;
00388     }
00389 
00390     printf("-!- MCI %d, code: 1.clr, 2.wr, 3.rd\n\r", iMci);
00391 
00392     /* Perform tests on each block */
00393     multiBlock = 0;
00394 
00395     for (block = TEST_BLOCK_START;
00396          block < TEST_BLOCK_END;
00397          block += multiBlock) {
00398 
00399         /* Perform different single or multiple bloc operations */
00400         if (multiBlock >= 16)   multiBlock <<= 1;
00401         else                    multiBlock ++;
00402 
00403         if (multiBlock > NB_MULTI_BLOCKS)
00404             multiBlock = 1;
00405 
00406         /* Multi-block adjustment */
00407         if (block + multiBlock > TEST_BLOCK_END)
00408             multiBlock = TEST_BLOCK_END - block;
00409 
00410         /* ** Perform single block or multi block transfer */
00411         printf("\r-I- Testing block [%6u - %6u] ...",
00412                (unsigned int)block, (unsigned int)(block + multiBlock - 1));
00413 
00414         if (clr) {
00415             /* - Clear the block */
00416             memset(pBuffer, 0, SDMMC_BLOCK_SIZE * multiBlock);
00417             SCB_CleanDCache_by_Addr((uint32_t *)pBuffer, SDMMC_BLOCK_SIZE * multiBlock);
00418 
00419             for (i = 0; i < SDMMC_BLOCK_SIZE * multiBlock; i++) {
00420                 if (pBuffer[i] != 0) {
00421                     /* Fatal error */
00422                     printf("\n\r-F- Data @ %u for write : 0x00 <> 0x%02x\n\r",
00423                            (unsigned int)i, pBuffer[i]);
00424                     return;
00425                 }
00426             }
00427 
00428             error = MMCT_WriteFun(pSd, block, multiBlock, pBuffer);
00429 
00430             if (error) {
00431                 printf("\n\r-E- 1. Write block (%d) #%u\n\r", error,
00432                        (unsigned int)block);
00433 
00434                 if (MaxErrorBreak(0)) return;
00435 
00436                 /* Skip following test */
00437                 continue;
00438             }
00439 
00440             __DMB();
00441             /* - Read back the data to check the write operation */
00442             memset(pBuffer, 0xFF, SDMMC_BLOCK_SIZE * multiBlock);
00443             SCB_CleanDCache_by_Addr((uint32_t *)pBuffer, SDMMC_BLOCK_SIZE * multiBlock);
00444 
00445             error = MMCT_ReadFun(pSd, block, multiBlock, pBuffer);
00446 
00447             if (error) {
00448                 printf("\n\r-E- 1. Read block (%d) #%u\n\r",
00449                        error, (unsigned int)block);
00450 
00451                 if (MaxErrorBreak(0)) return;
00452 
00453                 /* Skip following test */
00454                 continue;
00455             }
00456 
00457             __DMB();
00458 
00459             for (i = 0; i < SDMMC_BLOCK_SIZE * multiBlock; i++) {
00460                 if (pBuffer[i] != 0) {
00461                     printf("\n\r-E- 1. B%u.D[%u] : 0 <> 0x%02X\n\r",
00462                            (unsigned int)block, (unsigned int)i, (int)pBuffer[i]);
00463 
00464                     if (MaxErrorBreak(0)) return;
00465 
00466                     /* Only find first verify error. */
00467                     break;
00468                 }
00469             }
00470         }
00471 
00472         if (wr) {
00473             /* - Write a checkerboard pattern on the block */
00474             for (i = 0; i < SDMMC_BLOCK_SIZE * multiBlock; i++) {
00475                 if ((i & 1) == 0)  pBuffer[i] = (i & 0x55);
00476                 else               pBuffer[i] = (i & 0xAA);
00477             }
00478 
00479             SCB_CleanDCache_by_Addr((uint32_t *)pBuffer, SDMMC_BLOCK_SIZE * multiBlock);
00480 
00481             for (i = 0; i < multiBlock; ) {
00482                 splitMulti = ((multiBlock - i) > NB_SPLIT_MULTI) ?
00483                              NB_SPLIT_MULTI : (multiBlock - i);
00484                 error = MMCT_WriteFun(pSd,
00485                                       block + i,
00486                                       splitMulti,
00487                                       &pBuffer[i * SDMMC_BLOCK_SIZE]);
00488 
00489                 if (error) break;
00490 
00491                 i += splitMulti;
00492             }
00493 
00494             __DMB();
00495 
00496             if (error) {
00497                 printf("\n\r-E- 2. Write block #%u(%u+%u): %d\n\r",
00498                        (unsigned int)(block + i),
00499                        (unsigned int)block,
00500                        (unsigned int)i, error);
00501 
00502                 if (MaxErrorBreak(0)) return;
00503 
00504                 /* Skip Following Test */
00505                 continue;
00506             }
00507         }
00508 
00509         if (rd) {
00510             /* - Read back the data to check the write operation */
00511             memset(pBuffer, 0, SDMMC_BLOCK_SIZE * multiBlock);
00512             SCB_CleanDCache_by_Addr((uint32_t *)pBuffer, SDMMC_BLOCK_SIZE * multiBlock);
00513 
00514             for (i = 0; i < multiBlock; ) {
00515                 splitMulti = ((multiBlock - i) > NB_SPLIT_MULTI) ?
00516                              NB_SPLIT_MULTI : (multiBlock - i);
00517                 error = MMCT_ReadFun(pSd,
00518                                      block + i,
00519                                      splitMulti,
00520                                      &pBuffer[i * SDMMC_BLOCK_SIZE]);
00521 
00522                 if (error) break;
00523 
00524                 i += splitMulti;
00525             }
00526 
00527             if (error) {
00528                 printf("\n\r-E- 2. Read block #%u(%u+%u): %d\n\r",
00529                        (unsigned int)(block + i),
00530                        (unsigned int)block,
00531                        (unsigned int)i, error);
00532 
00533                 if (MaxErrorBreak(0)) return;
00534 
00535                 /* Skip Following Test */
00536                 continue;
00537             }
00538 
00539             __DMB();
00540             errcnt = 0;
00541 
00542             for (i = 0; i < SDMMC_BLOCK_SIZE * multiBlock; i++) {
00543 
00544                 if (!(((i & 1) == 0) && (pBuffer[i] == (i & 0x55))) &&
00545                     !(((i & 1) != 0) && (pBuffer[i] == (i & 0xAA))) ) {
00546                     uint32_t j, js;
00547                     printf("\n\r-E- 2.%d. Data @ %u (0x%x)\n\r",
00548                            (int)errcnt, (unsigned int)i, (unsigned int)i);
00549                     printf("  -Src:");
00550                     js = (i > 8) ? (i - 8) : 0;
00551 
00552                     for (j = js; j < i + 8; j ++)
00553                         printf(" %02x",
00554                                (unsigned int)(((j & 1) != 0) ? (j & 0xAA) : (j & 0x55)));
00555 
00556                     printf("\n\r  -Dat:");
00557 
00558                     for (j = js; j < i + 8; j ++)
00559                         printf("%c%02x", (i == j) ? '!' : ' ', pBuffer[j]);
00560 
00561                     printf("\n\r");
00562 
00563                     if (MaxErrorBreak(0)) return;
00564 
00565                     // Only find first 3 verify error.
00566                     if (errcnt ++ >= 3)
00567                         break;
00568                 }
00569             }
00570         }
00571 
00572         if (DBG_IsRxReady()) {
00573             switch (DBG_GetChar()) {
00574             /* Skip 100M */
00575             case 'k':
00576                 block += TEST_BLOCK_SKIP;
00577 
00578                 if (block > TEST_BLOCK_END)
00579                     block -= 5 + multiBlock;
00580 
00581                 printf("\n\r");
00582                 break;
00583 
00584             /* Cancel */
00585             case 'c':
00586                 return;
00587             }
00588         }
00589     }
00590 
00591     printf("All block tested!\n\r");
00592 }
00593 
00594 /**
00595  * Initialize PIOs
00596  */
00597 static void _ConfigurePIOs(void)
00598 {
00599     /* Configure SDcard pins */
00600     PIO_Configure(pinsSd, PIO_LISTSIZE(pinsSd));
00601     /* Configure SD card detection */
00602     CardDetectConfigure();
00603     /* Check if card is write-protected (if supported) */
00604     CardIsProtected();
00605 }
00606 
00607 /**
00608  * Initialize driver instances.
00609  */
00610 static void _ConfigureDrivers(void)
00611 {
00612     uint32_t i;
00613     /* Initialize the DMA driver */
00614     XDMAD_Initialize(&dmaDrv, 0);
00615 
00616     /* Enable XDMA interrupt and give it priority over any other peripheral interrupt */
00617     NVIC_ClearPendingIRQ(XDMAC_IRQn);
00618     NVIC_SetPriority(XDMAC_IRQn, 1);
00619     NVIC_EnableIRQ(XDMAC_IRQn);
00620 
00621     /* Initialize the HSMCI driver */
00622     MCID_Init(&mciDrv[0], HSMCI, ID_HSMCI, BOARD_MCK, &dmaDrv, 0 );
00623 
00624     /* Enable MCI interrupt and give it priority lower than DMA*/
00625     NVIC_ClearPendingIRQ(HSMCI_IRQn);
00626     NVIC_SetPriority(HSMCI_IRQn, 3);
00627     NVIC_EnableIRQ(HSMCI_IRQn);
00628 
00629     /* Initialize SD driver */
00630     for (i = 0; i < BOARD_NUM_MCI; i ++)
00631         SDD_InitializeSdmmcMode(&sdDrv[i], &mciDrv[i], 0);
00632 }
00633 
00634 /*----------------------------------------------------------------------------
00635  *         Global functions
00636  *----------------------------------------------------------------------------*/
00637 
00638 /**
00639  *  \brief hsmci_sdcard Application entry point.
00640  *
00641  *  \return Unused (ANSI-C compatibility).
00642  */
00643 int main(void)
00644 {
00645     uint32_t i;
00646     uint8_t connected[BOARD_NUM_MCI];
00647 
00648     /* Disable watchdog */
00649     WDT_Disable(WDT);
00650 
00651     SCB_EnableICache();
00652     SCB_EnableDCache();
00653 
00654     /* Output example information */
00655     printf("-- HSMCI SD/MMC Example %s --\n\r", SOFTPACK_VERSION);
00656     printf("-- %s\n\r", BOARD_NAME);
00657     printf("-- Compiled: %s %s  With %s--\n\r", __DATE__, __TIME__ , COMPILER_NAME);
00658 
00659 
00660     /* Initialize PIO pins */
00661     _ConfigurePIOs();
00662 
00663     /* Initialize drivers */
00664     _ConfigureDrivers();
00665 
00666     /* Initialize connections */
00667     for (i = 0; i < BOARD_NUM_MCI; i++)
00668         connected[i] = 0;
00669 
00670     /* Check if any card is inserted */
00671     if (!AnyCardIsConnected()) {
00672         printf("-- Please insert a card\n\r");
00673 
00674         while (!AnyCardIsConnected());
00675     }
00676 
00677     /* Test all cards */
00678     for (i = 0; i < BOARD_NUM_MCI; i++) {
00679         if (connected[i] == 0 && CardIsConnected(i)) {
00680             connected[i] = 1;
00681             LoopDelay(BOARD_MCK / 1000 / 200);
00682 
00683             if (!CardInit(i))
00684                 DiskTest(i, 1, 1, 1);
00685         }
00686     }
00687 
00688     while (1);
00689 }
00690 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines