Pengujian Battery
Dependencies: SDFileSystem TextLCD mbed
Fork of Seeed_SDCard_Shield by
main.cpp@3:5edc67dee8b7, 2014-07-25 (annotated)
- Committer:
- screamer
- Date:
- Fri Jul 25 12:26:55 2014 +0000
- Revision:
- 3:5edc67dee8b7
- Parent:
- 2:f2f5e2324ad4
- Child:
- 5:47c9375675bb
Add Apache2 license compatible header
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
screamer | 3:5edc67dee8b7 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
screamer | 3:5edc67dee8b7 | 2 | * |
screamer | 3:5edc67dee8b7 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
screamer | 3:5edc67dee8b7 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
screamer | 3:5edc67dee8b7 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
screamer | 3:5edc67dee8b7 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
screamer | 3:5edc67dee8b7 | 7 | * Software is furnished to do so, subject to the following conditions: |
screamer | 3:5edc67dee8b7 | 8 | * |
screamer | 3:5edc67dee8b7 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
screamer | 3:5edc67dee8b7 | 10 | * substantial portions of the Software. |
screamer | 3:5edc67dee8b7 | 11 | * |
screamer | 3:5edc67dee8b7 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
screamer | 3:5edc67dee8b7 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
screamer | 3:5edc67dee8b7 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
screamer | 3:5edc67dee8b7 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
screamer | 3:5edc67dee8b7 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
screamer | 3:5edc67dee8b7 | 17 | */ |
screamer | 3:5edc67dee8b7 | 18 | |
screamer | 0:525c842a3c89 | 19 | #include "mbed.h" |
screamer | 0:525c842a3c89 | 20 | #include "SDFileSystem.h" |
screamer | 0:525c842a3c89 | 21 | |
screamer | 2:f2f5e2324ad4 | 22 | Serial pc(USBTX, USBRX); |
screamer | 0:525c842a3c89 | 23 | SDFileSystem sd(D11, D12, D13, D10, "sd"); // MOSI, MISO, SCK, CS |
screamer | 0:525c842a3c89 | 24 | FILE *fp; |
screamer | 0:525c842a3c89 | 25 | |
screamer | 0:525c842a3c89 | 26 | int main() { |
screamer | 1:93d41c73ac7d | 27 | wait(2); |
screamer | 1:93d41c73ac7d | 28 | pc.printf("Initializing\r\n"); |
screamer | 0:525c842a3c89 | 29 | |
screamer | 0:525c842a3c89 | 30 | fp = fopen("/sd/hello.txt", "r"); |
screamer | 0:525c842a3c89 | 31 | if (fp != NULL) { |
screamer | 0:525c842a3c89 | 32 | fclose(fp); |
screamer | 0:525c842a3c89 | 33 | remove("/sd/hello.txt"); |
screamer | 1:93d41c73ac7d | 34 | pc.printf("Remove an existing file with the same name\r\n"); |
screamer | 0:525c842a3c89 | 35 | } |
screamer | 0:525c842a3c89 | 36 | |
screamer | 0:525c842a3c89 | 37 | fp = fopen("/sd/hello.txt", "w"); |
screamer | 0:525c842a3c89 | 38 | if (fp == NULL) { |
screamer | 1:93d41c73ac7d | 39 | pc.printf("Unable to write the file\r\n"); |
screamer | 0:525c842a3c89 | 40 | } else { |
screamer | 0:525c842a3c89 | 41 | fprintf(fp, "mbed SDCard application!"); |
screamer | 0:525c842a3c89 | 42 | fclose(fp); |
screamer | 1:93d41c73ac7d | 43 | pc.printf("File successfully written!\r\n"); |
screamer | 0:525c842a3c89 | 44 | } |
screamer | 0:525c842a3c89 | 45 | } |