SD
Dependencies: SDFileSystem mbed
Fork of SDFileSystem_HelloWorld by
Revision 1:6fc055bdf667, committed 2016-04-16
- Comitter:
- RAMIRORUBIO
- Date:
- Sat Apr 16 17:49:58 2016 +0000
- Parent:
- 0:bdbd3d6fc5d5
- Commit message:
- SD;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Dec 07 11:25:01 2012 +0000 +++ b/main.cpp Sat Apr 16 17:49:58 2016 +0000 @@ -1,19 +1,61 @@ #include "mbed.h" #include "SDFileSystem.h" -SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board - +SDFileSystem sd( PTD2, PTD3, PTD1, PTD0, "sd"); +char arr[160]; +//char str1[]="/sd/sdtest1.txt"; +char str1[]="/sd/"; +char str2[20]; +char str3[20]; +char str4[20]; +char i; +void concatenation(char a[], char b[], char c[]) +{ + unsigned char i; + unsigned char j; + i=0; + j=0; + do + { + c[j++]=a[i++]; + }while (a[i]); + i=0; + do + { + c[j++]=b[i++]; + }while (b[i]); +} + int main() { - printf("Hello World!\n"); - - mkdir("/sd/mydir", 0777); - - FILE *fp = fopen("/sd/mydir/sdtest.txt", "w"); + //Abre la SD + printf("Abriendo SD...\n\r"); + printf("Archivo:"); + scanf("%s",str2); + concatenation(str1,str2,str3); + printf("\n\rAbriendo%s\n\r",str3); + //Abre el archivo seleccionado + FILE *fp = fopen(str3,"w+"); if(fp == NULL) { - error("Could not open file for write\n"); + error("Could not open file for write\n\r"); } - fprintf(fp, "Hello fun SD Card World!"); + printf("Texto:"); + //Escrib el texto en el archivo abierto + scanf("%s",str2); + fprintf(fp, str2); fclose(fp); - - printf("Goodbye World!\n"); + //Abre archivo seleccionado + printf("\n\rAbrir archivo:"); + scanf("%s",str2); + concatenation(str1,str2,str4); + fp = fopen(str4, "r"); + if(fp == NULL) { + error("Could not open file for write\n\r"); + } + fgets(arr,160,fp); + printf("\n\r"); + printf(arr); + fclose(fp); + printf("\n\r"); + printf("Cerrando SD...\n\r"); } +
--- a/mbed.bld Fri Dec 07 11:25:01 2012 +0000 +++ b/mbed.bld Sat Apr 16 17:49:58 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63cdd78b2dc1 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file