Sd card

Dependencies:   mbed SDFileSystem

Committer:
mariangelamone
Date:
Sun Feb 06 20:30:37 2022 +0000
Revision:
4:33450cfd53f3
Parent:
3:f281a7095433
scrittura su sd card

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mariangelamone 4:33450cfd53f3 1
tubemerc 0:6337f8cfdd73 2 #include "mbed.h"
tubemerc 0:6337f8cfdd73 3 #include "SDFileSystem.h"
tubemerc 0:6337f8cfdd73 4
mariangelamone 4:33450cfd53f3 5 DigitalOut myled(PB_1);
mariangelamone 3:f281a7095433 6 Serial pc(SERIAL_TX, SERIAL_RX);
tubemerc 0:6337f8cfdd73 7
mariangelamone 4:33450cfd53f3 8 SDFileSystem sd(D11, D12, D13, D4, "sd");
tubemerc 0:6337f8cfdd73 9
tubemerc 0:6337f8cfdd73 10 int main(){
mariangelamone 4:33450cfd53f3 11 wait(1.0);
tubemerc 0:6337f8cfdd73 12 pc.printf("Start.\n\r");
tubemerc 0:6337f8cfdd73 13
tubemerc 0:6337f8cfdd73 14 FILE *fp = fopen("/sd/test.csv", "w");
tubemerc 0:6337f8cfdd73 15 //FILE *fp = fopen("/sd/test.txt", "w");
tubemerc 0:6337f8cfdd73 16 if(fp != NULL){
tubemerc 2:8e4ad4ac6425 17 myled = 1;
tubemerc 0:6337f8cfdd73 18 pc.printf("Writing to SDcard......\n\r");
tubemerc 0:6337f8cfdd73 19 for(int i=1;i<10;i++){
tubemerc 0:6337f8cfdd73 20 fprintf(fp, "%d\n", i);
tubemerc 0:6337f8cfdd73 21 }
tubemerc 0:6337f8cfdd73 22 fclose(fp);
tubemerc 2:8e4ad4ac6425 23 myled = 0;
tubemerc 0:6337f8cfdd73 24 }
tubemerc 0:6337f8cfdd73 25 else{
tubemerc 0:6337f8cfdd73 26 pc.printf("Failed.\n\r");
tubemerc 0:6337f8cfdd73 27 }
tubemerc 0:6337f8cfdd73 28 pc.printf("End.\n\r");
tubemerc 0:6337f8cfdd73 29 }