Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed SDFileSystem_NUCLEO_32
Revision 0:0f6db11f0aad, committed 2020-12-18
- Comitter:
- hakusan270
- Date:
- Fri Dec 18 02:03:24 2020 +0000
- Commit message:
- sd filre test
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Fri Dec 18 02:03:24 2020 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/I-O-DATA-DEV2/code/SDFileSystem_NUCLEO_32/#88ece4a12d29
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Dec 18 02:03:24 2020 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "SDFileSystem.h"
+
+DigitalIn btn(D2);
+RawSerial pc(PA_2, PA_3);
+//SDFileSystem sd(D11, D12, D13, D10, "sd", NC, SDFileSystem::SWITCH_NONE, 20000000); // mosi, miso, sclk, name, card detect, sw type, freq
+//SDFileSystem sd(PB_15, PB_14, PB_13, D4, "sd", NC, SDFileSystem::SWITCH_NONE, 20000000); // mosi, miso, sclk, CS,name, card detect, sw type, freq
+SDFileSystem sd(D11,D12,D13,A0, "sd", NC, SDFileSystem::SWITCH_NONE,10000000); // mosi, miso, sclk, CS,name, card detect, sw type, freq
+
+// trim '\n'
+void ntrim(char *str)
+{
+ int i;
+ for (i = 0; str[i] != 0; ++i);
+
+ if (i > 0 && str[i - 1] == '\n')
+ str[i - 1] = 0;
+}
+
+
+int main()
+{
+ pc.printf("Hello\r\n");
+ // SD filesystem
+// SDFileSystem *sd = new SDFileSystem(D11, D12, D13, D10, "sd", NC, SDFileSystem::SWITCH_NONE, 20000000); // mosi, miso, sclk, name, card detect, sw type, freq
+
+ while (1)
+ {
+ // if (btn) continue;
+
+ // file open
+ FILE *fp = fopen("/sd/test.txt", "r");
+ if (fp == NULL)
+ {
+ printf("open error!!\r\n");
+ goto neww;
+ //while(1);
+ }
+ // read text file
+ char buf[1024];
+ while (fgets(buf, sizeof(buf), fp) != NULL)
+ {
+ ntrim(buf);
+ printf("%s\r\n", buf);
+ }
+
+ // file close
+ fclose(fp);
+ neww:
+ fp = fopen("/sd/test.txt", "a");
+ fprintf(fp,"test write\n");
+ fclose(fp);
+ while(1);
+
+ wait(1);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Dec 18 02:03:24 2020 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file