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); }
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 }