![](/media/cache/profiles/56f9e53c06985234d40a35145c1a919e.jpg.50x50_q85.jpg)
demo code to use the SD card of Seeed Arch GPRS V2.0
Dependencies: SDFileSystem USBDevice mbed
Revision 0:0f3ea0944add, committed 2014-04-29
- Comitter:
- lawliet
- Date:
- Tue Apr 29 12:49:33 2014 +0000
- Commit message:
- Initial Version
Changed in this revision
diff -r 000000000000 -r 0f3ea0944add SDFileSystem.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Tue Apr 29 12:49:33 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
diff -r 000000000000 -r 0f3ea0944add USBDevice.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Tue Apr 29 12:49:33 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/USBDevice/#5b7d31d9d3f3
diff -r 000000000000 -r 0f3ea0944add main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Apr 29 12:49:33 2014 +0000 @@ -0,0 +1,49 @@ +/* + main.cpp + 2014 Copyright (c) Seeed Technology Inc. All right reserved. + + Author:lawliet zou(lawliet.zou@gmail.com) + 2014-4-29 + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +#include "mbed.h" +#include "USBSerial.h" +#include "SDFileSystem.h" + +SDFileSystem sd(P1_22, P1_21, P1_20, P1_23, "sd"); // mosi, miso, sclk, cs +USBSerial pc; +FILE *fp; + +int main() +{ + pc.printf("Initializing\r\n"); + + fp = fopen("/sd/hello.txt", "r"); + if (fp != NULL) { + fclose(fp); + remove("/sd/hello.txt"); + pc.printf("Remove an existing file with the same name\r\n"); + } + + fp = fopen("/sd/hello.txt", "w"); + if (fp == NULL) { + pc.printf("Unable to write the file\r\n"); + } else { + fprintf(fp, "mbed SDCard application!"); + fclose(fp); + pc.printf("File successfully written!\r\n"); + } +} \ No newline at end of file
diff -r 000000000000 -r 0f3ea0944add mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 29 12:49:33 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8a40adfe8776 \ No newline at end of file