Pengujian Battery
Dependencies: SDFileSystem TextLCD mbed
Fork of Seeed_SDCard_Shield by
main.cpp@1:93d41c73ac7d, 2014-03-25 (annotated)
- Committer:
- screamer
- Date:
- Tue Mar 25 17:39:19 2014 +0000
- Revision:
- 1:93d41c73ac7d
- Parent:
- 0:525c842a3c89
- Child:
- 2:f2f5e2324ad4
Remove LEDs utilization due to incompatibility with some boards (e.g. SPI pins are also LED pins)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 0:525c842a3c89 | 1 | #include "mbed.h" |
screamer | 0:525c842a3c89 | 2 | #include "SDFileSystem.h" |
screamer | 0:525c842a3c89 | 3 | |
screamer | 0:525c842a3c89 | 4 | SDFileSystem sd(D11, D12, D13, D10, "sd"); // MOSI, MISO, SCK, CS |
screamer | 1:93d41c73ac7d | 5 | Serial pc(USBTX, USBRX); |
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 | } |