mbed studio

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
rainerraul
Date:
Wed May 18 14:43:41 2022 +0000
Commit message:
mbed studio

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
mbed.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 6444a20e1a0e SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Wed May 18 14:43:41 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/rainerraul/code/SDFileSystem/#c04836714316
diff -r 000000000000 -r 6444a20e1a0e main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 18 14:43:41 2022 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "stdio.h"
+#include "stdint.h"
+#include "stdlib.h"
+#include "SPI.h"
+#include "SDFileSystem.h"
+
+Serial terminal(USBTX, USBRX);
+
+//Create an SDFileSystem object
+SDFileSystem sd(PA_7, PA_6, PA_5, PB_6, "sd"); // mosi, miso, sclk, cs
+
+int main()
+{
+   wait(0.5);
+    terminal.baud(115200);
+    //Mount the filesystem
+   sd.mount();
+    //Perform a write test
+    printf("\nWriting to SD card...");
+    FILE *fp = fopen("/sd/sdtest.txt", "w");
+    if (fp != NULL) {
+        fprintf(fp, "We're writing to an SD card!");
+        fclose(fp);
+        printf("success!\n");
+    } else {
+        printf("failed!\n");
+    }
+
+    //Perform a read test
+    printf("Reading from SD card...");
+    fp = fopen("/sd/sdtest.txt", "r");
+    if (fp != NULL) {
+        char c = fgetc(fp);
+        if (c == 'W')
+            printf("success!\n");
+        else
+            printf("incorrect char (%c)!\n", c);
+        fclose(fp);
+    } else {
+        printf("failed!\n");
+    }
+    sd.unmount();
+    //Unmount the filesystem
+ // sd.unmount();
+}
diff -r 000000000000 -r 6444a20e1a0e mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 18 14:43:41 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
diff -r 000000000000 -r 6444a20e1a0e mbed.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Wed May 18 14:43:41 2022 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/rainerraul/code/mbed/#f324e9ab2364