SDC. Additional checks in testhal.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4127 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
barthess 2012-04-22 19:36:46 +00:00
parent af1d75c7d6
commit cdabdb4631
1 changed files with 37 additions and 4 deletions

View File

@ -217,7 +217,9 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
FATFS *fsp; FATFS *fsp;
FIL FileObject; FIL FileObject;
uint32_t bytes_written; uint32_t bytes_written;
uint32_t bytes_read;
FILINFO filinfo;
uint8_t teststring[] = {"This is test file\r\n"};
chprintf(chp, "Register working area for filesystem... "); chprintf(chp, "Register working area for filesystem... ");
chThdSleepMilliseconds(100); chThdSleepMilliseconds(100);
@ -266,14 +268,13 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
chprintf(chp, "OK\r\n"); chprintf(chp, "OK\r\n");
chprintf(chp, "Write some data in it... "); chprintf(chp, "Write some data in it... ");
chThdSleepMilliseconds(100); chThdSleepMilliseconds(100);
err = f_write(&FileObject, "This is test file", 17, (void *)&bytes_written); err = f_write(&FileObject, teststring, sizeof(teststring), (void *)&bytes_written);
if (err != FR_OK) { if (err != FR_OK) {
chSysHalt(); chSysHalt();
} }
else else
chprintf(chp, "OK\r\n"); chprintf(chp, "OK\r\n");
chprintf(chp, "Close file \"chtest.txt\"... "); chprintf(chp, "Close file \"chtest.txt\"... ");
err = f_close(&FileObject); err = f_close(&FileObject);
if (err != FR_OK) { if (err != FR_OK) {
@ -282,11 +283,43 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
else else
chprintf(chp, "OK\r\n"); chprintf(chp, "OK\r\n");
chprintf(chp, "Check file size \"chtest.txt\"... ");
err = f_stat("0:chtest.txt", &filinfo);
chThdSleepMilliseconds(100);
if (err != FR_OK) {
chSysHalt();
}
else{
if (filinfo.fsize == sizeof(teststring))
chprintf(chp, "OK\r\n");
else
chSysHalt();
}
chprintf(chp, "Check file content \"chtest.txt\"... ");
err = f_open(&FileObject, "0:chtest.txt", FA_READ | FA_OPEN_EXISTING);
chThdSleepMilliseconds(100);
if (err != FR_OK) {
chSysHalt();
}
uint8_t buf[sizeof(teststring)];
err = f_read(&FileObject, buf, sizeof(teststring), (void *)&bytes_read);
if (err != FR_OK) {
chSysHalt();
}
else{
if (memcmp(teststring, buf, sizeof(teststring)) != 0){
chSysHalt();
}
else{
chprintf(chp, "OK\r\n");
}
}
chprintf(chp, "Umount filesystem... "); chprintf(chp, "Umount filesystem... ");
f_mount(0, NULL); f_mount(0, NULL);
chprintf(chp, "OK\r\n"); chprintf(chp, "OK\r\n");
chprintf(chp, "Disconnecting from SDIO..."); chprintf(chp, "Disconnecting from SDIO...");
chThdSleepMilliseconds(100); chThdSleepMilliseconds(100);
if (sdcDisconnect(&SDCD1)) if (sdcDisconnect(&SDCD1))