SDCARD test

Dependencies:   SDFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
barti19941
Date:
Tue Nov 06 19:47:08 2018 +0000
Commit message:
Wersja 1

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Tue Nov 06 19:47:08 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/barti19941/code/SDFileSystem/#c041a120aaed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 06 19:47:08 2018 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+
+SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // MOSI, MISO, SCK, CS
+Serial pc(USBTX, USBRX);
+FILE *fp;
+char buffer[1024];
+
+int main() {
+    pc.printf("Initializing \n");
+    wait(2);
+    /*
+    fp = fopen("/sd/hello.txt", "r");
+    if (fp != NULL) {
+        fclose(fp);
+        remove("/sd/hello.txt");
+        pc.printf("Remove an existing file with the same name \n");
+    }
+
+    printf("\nWriting data to the sd card \n");
+    fp = fopen("/sd/hello.txt", "w");
+    if (fp == NULL) {
+        pc.printf("Unable to write the file \n");
+    } else {
+        fprintf(fp, "mbed SDCard application!");
+        fclose(fp);
+        pc.printf("File successfully written! \n");
+    }
+
+    printf("\nReading data from the SD card. \n");
+    fp = fopen("/sd/hello.txt", "r");
+    if (fp != NULL) {
+        int size = fread(buffer, sizeof(char), 1024, fp);
+        printf("Number of data read: %d, text from hello.txt file: %s \n", size, buffer);
+        fclose(fp);
+    }
+    printf("End of Lab 4. \n");
+    */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 06 19:47:08 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e
\ No newline at end of file