Exemplo n.º 1
0
void initialize_mmcsd() {

    /* Configure EDMA to service the MMCSD events. */
    MMCSDEdmaInit();

#if 0 // TODO: Check if these steps are necessary? -- ertl-liyixiao
    /* Perform pin-mux for MMCSD pins. */
    MMCSDPinMuxSetup();

    /* Enable module clock for MMCSD. */
    MMCSDModuleClkConfig();

    DelayTimerSetup();
#endif

    /* Basic controller initializations */
    MMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    MMCSDCtrlInit(&ctrlInfo);

    MMCSDIntEnable(&ctrlInfo);

    /* Check SD card status */
    while(1) {
    	if((MMCSDCardPresent(&ctrlInfo)) == 1) {
    		syslog(LOG_DEBUG, "Card is present");
    		break;
    	}
    	syslog(LOG_ERROR, "Card is not present");
    	tslp_tsk(1000);
    }

    /* Initialize device control interface for FatFS */
    diskio_initialize(&sdCard);

//    static char tmpBuf[1024] __attribute__ ((aligned (SOC_EDMA3_ALIGN_SIZE)));
//    MMCSDReadCmdSend(&ctrlInfo, tmpBuf, 0, 1);
//    MMCSDReadCmdSend(&ctrlInfo, tmpBuf, 0, 1);
//    MMCSDWriteCmdSend(&ctrlInfo, tmpBuf, 0, 1);
//    MMCSDWriteCmdSend(&ctrlInfo, tmpBuf, 0, 1);
//    dump_mmc(&MMCSD0);
//    while(1) tslp_tsk(1000);
}
Exemplo n.º 2
0
int main(void)
{
    volatile unsigned int i = 0;
    volatile unsigned int initFlg = 1;

#ifdef ARM_SUPPORTED
    /* Setup the MMU and do necessary MMU configurations. */
    MMUConfigAndEnable();
#endif

#ifdef CACHE_SUPPORTED
    /* Enable all levels of CACHE. */
    CacheEnable(CACHE_ALL);
#endif

    /* Initialize UART. */
    UARTStdioInit();

    /* Configure the EDMA clocks. */
    EDMAModuleClkConfig();

    /* Configure EDMA to service the MMCSD events. */
    MMCSDEdmaInit();

    /* Perform pin-mux for MMCSD pins. */
    MMCSDPinMuxSetup();

    /* Enable module clock for MMCSD. */
    MMCSDModuleClkConfig();

    DelayTimerSetup();

#ifdef MMCSD_PERF
    PerfTimerSetup();
#endif

    /* Basic controller initializations */
    MMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    MMCSDCtrlInit(&ctrlInfo);

    MMCSDIntEnable(&ctrlInfo);

#if 0
    UARTPuts("Test timer:wait 5s\r\n", -1);
    delay(5000);
    UARTPuts("Test timer:Done\r\n", -1);
#endif

    for(;;)
    {
        if((MMCSDCardPresent(&ctrlInfo)) == 1)
        {
#if DEBUG_PRINT
            UARTPuts("Card is present\r\n", -1);
#endif
            if(initFlg)
            {
                UARTPuts("Call MMCSDFsMount\r\n", -1);
                MMCSDFsMount(0, &sdCard);
                UARTPuts("Back MMCSDFsMount\r\n", -1);
                initFlg = 0;
                UARTPuts("Call Cmd_help\r\n", -1);
                Cmd_help(0, NULL);
            }
            MMCSDFsProcessCmdLine();
        }
        else
        {
UARTPuts("Card is not present\r\n", -1);
delay(1000);
//          delay(1);

            i = (i + 1) & 0xFFF;

            if(i == 1)
            {
                 UARTPuts("Please insert the card \r\n", -1);
            }

            if(initFlg != 1)
            {
                 /* Reinitialize all the state variables */
                 dmaIsRunning = 0;
                 xferCompFlag = 0;
                 dataTimeout  = 0;
                 dataCRCError = 0;
                 cmdCompFlag  = 0;
                 cmdTimeout   = 0;

                 /* Initialize the MMCSD controller */
                 MMCSDCtrlInit(&ctrlInfo);

                 MMCSDIntEnable(&ctrlInfo);
            }

            initFlg = 1;
        }
    }
}
Exemplo n.º 3
0
void initialize_mmcsd() {

    /* Configure EDMA to service the MMCSD events. */
    MMCSDEdmaInit();

#if 0 // TODO: Check if these steps are necessary? -- ertl-liyixiao
    /* Perform pin-mux for MMCSD pins. */
    MMCSDPinMuxSetup();

    /* Enable module clock for MMCSD. */
    MMCSDModuleClkConfig();

    DelayTimerSetup();
#endif

    /* Basic controller initializations */
    MMCSDControllerSetup();

    /* Initialize the MMCSD controller */
    MMCSDCtrlInit(&ctrlInfo);

    // MMCSDIntEnable(&ctrlInfo);


    /* Check SD card status */
    while(1) {
    	if((MMCSDCardPresent(&ctrlInfo)) == 1) {
    		syslog(LOG_DEBUG, "Card is present");
    		break;
    	}
    	syslog(LOG_ERROR, "Card is not present");
    	tslp_tsk(1000);
    }

    /* Initialize device control interface for FatFS */
    diskio_initialize(&sdCard);

#if 0 // Test code for MMCSD IO operations
    MMCSDCardInit(&ctrlInfo);
    static char tmpBuf1[512 * 4] __attribute__ ((aligned (SOC_EDMA3_ALIGN_SIZE)));
    static char tmpBuf2[512 * 4] __attribute__ ((aligned (SOC_EDMA3_ALIGN_SIZE)));

    syslog(LOG_NOTICE, "Test READ_SINGLE_BLOCK (CMD17)");
    MMCSDReadCmdSend(&ctrlInfo, tmpBuf1, 0, 1);

    syslog(LOG_NOTICE, "Test READ_MULTIPLE_BLOCK (CMD18)");
    MMCSDReadCmdSend(&ctrlInfo, tmpBuf1, 0, 3);

#if 0 // Test code for READ_MULTIPLE_BLOCK
    syslog(LOG_NOTICE, "Test READ_MULTIPLE_BLOCK (CMD18)");

    for (int i = 0; i < 10000; ++i) {
        MMCSDReadCmdSend(&ctrlInfo, tmpBuf1,  i, 1);
        MMCSDReadCmdSend(&ctrlInfo, tmpBuf1,  i + 1, 1);
        MMCSDReadCmdSend(&ctrlInfo, tmpBuf2, i, 2);
        for (int j = 0; j < 1024; ++j) {
            if (tmpBuf1[j] != tmpBuf2[j]) {
                syslog(LOG_NOTICE, "Different block %d", i);
                break;
            }
        }
        if (i % 100 == 0) syslog(LOG_NOTICE, "Compared blocks %d / 10000", i);
    }
    while(1) tslp_tsk(1000);
#endif

    syslog(LOG_NOTICE, "Test WRITE_SINGLE_BLOCK (CMD24)");
    MMCSDWriteCmdSend(&ctrlInfo, tmpBuf1, 7626740, 1);

    syslog(LOG_NOTICE, "Test WRITE_MULTIPLE_BLOCK (CMD25)");
    MMCSDWriteCmdSend(&ctrlInfo, tmpBuf1, 7626740, 3);

    syslog(LOG_NOTICE, "Test done");
    while(1) tslp_tsk(1000);
#endif
}