Pengujian Battery

Dependencies:   SDFileSystem TextLCD mbed

Fork of Seeed_SDCard_Shield by Shields

Committer:
screamer
Date:
Fri Jul 25 10:39:00 2014 +0000
Revision:
2:f2f5e2324ad4
Parent:
1:93d41c73ac7d
Child:
3:5edc67dee8b7
Update mbed library to the latest revision

Who changed what in which revision?

UserRevisionLine numberNew contents of line
screamer 0:525c842a3c89 1 #include "mbed.h"
screamer 0:525c842a3c89 2 #include "SDFileSystem.h"
screamer 0:525c842a3c89 3
screamer 2:f2f5e2324ad4 4 Serial pc(USBTX, USBRX);
screamer 0:525c842a3c89 5 SDFileSystem sd(D11, D12, D13, D10, "sd"); // MOSI, MISO, SCK, CS
screamer 0:525c842a3c89 6 FILE *fp;
screamer 0:525c842a3c89 7
screamer 0:525c842a3c89 8 int main() {
screamer 1:93d41c73ac7d 9 wait(2);
screamer 1:93d41c73ac7d 10 pc.printf("Initializing\r\n");
screamer 0:525c842a3c89 11
screamer 0:525c842a3c89 12 fp = fopen("/sd/hello.txt", "r");
screamer 0:525c842a3c89 13 if (fp != NULL) {
screamer 0:525c842a3c89 14 fclose(fp);
screamer 0:525c842a3c89 15 remove("/sd/hello.txt");
screamer 1:93d41c73ac7d 16 pc.printf("Remove an existing file with the same name\r\n");
screamer 0:525c842a3c89 17 }
screamer 0:525c842a3c89 18
screamer 0:525c842a3c89 19 fp = fopen("/sd/hello.txt", "w");
screamer 0:525c842a3c89 20 if (fp == NULL) {
screamer 1:93d41c73ac7d 21 pc.printf("Unable to write the file\r\n");
screamer 0:525c842a3c89 22 } else {
screamer 0:525c842a3c89 23 fprintf(fp, "mbed SDCard application!");
screamer 0:525c842a3c89 24 fclose(fp);
screamer 1:93d41c73ac7d 25 pc.printf("File successfully written!\r\n");
screamer 0:525c842a3c89 26 }
screamer 0:525c842a3c89 27 }