Read/Write the SD card(using SSP)

Dependencies:   SDFileSystem mbed

Fork of SSP_SDcard_Helloworld_WIZwiki-W7500 by eunkyoung kim

Files at this revision

API Documentation at this revision

Comitter:
IOP
Date:
Wed Feb 03 07:34:43 2016 +0000
Parent:
6:f5c52e8a96ef
Commit message:
update mbed lib

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r f5c52e8a96ef -r daaefdca1f78 main.cpp
--- a/main.cpp	Thu Jan 07 00:01:14 2016 +0000
+++ b/main.cpp	Wed Feb 03 07:34:43 2016 +0000
@@ -1,5 +1,6 @@
 #include "mbed.h"
 #include "SDFileSystem.h"
+
 #if defined(TARGET_WIZwiki_W7500)
 #define MOSI                  PB_3
 #define MISO                  PB_2
@@ -7,36 +8,48 @@
 #define SEL                   PB_0
 #endif
 
-#define MAX_SIZE 100 
+#define MAX_SIZE 100
+
 SDFileSystem sd(MOSI, MISO, CLK, SEL, "sd"); // the pinout on the mbed Cool Components workshop board
 
 
 int main() {
 
         char str[MAX_SIZE];
+        
         mkdir("/sd/mydir", 0777);
         //"w" : {Write) - Create an empty file for output operations. If a file with the same name already exists, its contents are discarded and the file is treated as a new empty file.
         //"a+" :(append/update) -  open (or create if the file does not exist) for update at the end of the file
+        
         FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); 
-        if(fp == NULL) {
+        
+        if(fp == NULL)
+        {
             error("Could not open file for write\n");
         }
+        
         //fprintf(fp, "Hello fun SD Card World!");
         printf("Insert data:");
         scanf("%s",str);
         printf("\r\n");
+        
         fflush(stdin);
         fprintf(fp,"%s", str);
         fclose(fp); 
         
         printf("Reading from SD card...\r\n");
+        
         fp = fopen("/sd/mydir/sdtest.txt", "r");
-        if (fp != NULL) {
+        
+        if (fp != NULL)
+        {
              fgets(str,MAX_SIZE,fp);
              printf("%s", str);
              printf("\r\n");
             fclose(fp);
-        } else {
+        } 
+        else 
+        {
             printf("failed!\n");
         }
         
diff -r f5c52e8a96ef -r daaefdca1f78 mbed.bld
--- a/mbed.bld	Thu Jan 07 00:01:14 2016 +0000
+++ b/mbed.bld	Wed Feb 03 07:34:43 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file