aboutsummaryrefslogtreecommitdiffstats
path: root/testhal/STM32F4xx/SDC
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-04-22 19:36:46 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-04-22 19:36:46 +0000
commitcdabdb46317e967dc0fa79e8c23cde3c2ffd0b10 (patch)
tree01f96bd5e0620b5bcedccaa4c4255966e23e9ec7 /testhal/STM32F4xx/SDC
parentaf1d75c7d6dcae3b190d6d8ff920c1c0b4641686 (diff)
downloadChibiOS-cdabdb46317e967dc0fa79e8c23cde3c2ffd0b10.tar.gz
ChibiOS-cdabdb46317e967dc0fa79e8c23cde3c2ffd0b10.tar.bz2
ChibiOS-cdabdb46317e967dc0fa79e8c23cde3c2ffd0b10.zip
SDC. Additional checks in testhal.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4127 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal/STM32F4xx/SDC')
-rwxr-xr-xtesthal/STM32F4xx/SDC/main.c41
1 files changed, 37 insertions, 4 deletions
diff --git a/testhal/STM32F4xx/SDC/main.c b/testhal/STM32F4xx/SDC/main.c
index 48fb131fb..c1f1c3802 100755
--- a/testhal/STM32F4xx/SDC/main.c
+++ b/testhal/STM32F4xx/SDC/main.c
@@ -217,7 +217,9 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
FATFS *fsp;
FIL FileObject;
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... ");
chThdSleepMilliseconds(100);
@@ -266,14 +268,13 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
chprintf(chp, "OK\r\n");
chprintf(chp, "Write some data in it... ");
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) {
chSysHalt();
}
else
chprintf(chp, "OK\r\n");
-
chprintf(chp, "Close file \"chtest.txt\"... ");
err = f_close(&FileObject);
if (err != FR_OK) {
@@ -282,11 +283,43 @@ void cmd_sdiotest(BaseChannel *chp, int argc, char *argv[]){
else
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... ");
f_mount(0, NULL);
chprintf(chp, "OK\r\n");
-
chprintf(chp, "Disconnecting from SDIO...");
chThdSleepMilliseconds(100);
if (sdcDisconnect(&SDCD1))