mariangela mone / Mbed 2 deprecated sdcard

Dependencies:   mbed SDFileSystem

Committer:
tubemerc
Date:
Tue Oct 08 11:32:02 2019 +0000
Revision:
0:6337f8cfdd73
Child:
2:8e4ad4ac6425
sdcard test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tubemerc 0:6337f8cfdd73 1 /*
tubemerc 0:6337f8cfdd73 2 SDカードに文字列を書き込む.
tubemerc 0:6337f8cfdd73 3 <pin接続>
tubemerc 0:6337f8cfdd73 4 NSS: pin25 --- pin2 CD/DAT3
tubemerc 0:6337f8cfdd73 5 SCK: pin26 --- pin5 CLK
tubemerc 0:6337f8cfdd73 6 MISO:pin27 --- pin7 DAT0
tubemerc 0:6337f8cfdd73 7 MOSI:pin28 --- pin3 CMD
tubemerc 0:6337f8cfdd73 8 */
tubemerc 0:6337f8cfdd73 9 #include "mbed.h"
tubemerc 0:6337f8cfdd73 10 #include "SDFileSystem.h"
tubemerc 0:6337f8cfdd73 11
tubemerc 0:6337f8cfdd73 12 DigitalOut myled(PB_1);
tubemerc 0:6337f8cfdd73 13 Serial pc(PA_9, PA_10, 115200); //pin 19, 20
tubemerc 0:6337f8cfdd73 14
tubemerc 0:6337f8cfdd73 15 SDFileSystem sd = SDFileSystem(PB_5, PB_4, PB_3, PA_15, "sd"); //pin 28, 27, 26, 25
tubemerc 0:6337f8cfdd73 16
tubemerc 0:6337f8cfdd73 17 int main(){
tubemerc 0:6337f8cfdd73 18 wait(1.0); //気持ち
tubemerc 0:6337f8cfdd73 19 pc.printf("Start.\n\r");
tubemerc 0:6337f8cfdd73 20 myled = 1;
tubemerc 0:6337f8cfdd73 21
tubemerc 0:6337f8cfdd73 22 FILE *fp = fopen("/sd/test.csv", "w");
tubemerc 0:6337f8cfdd73 23 //FILE *fp = fopen("/sd/test.txt", "w");
tubemerc 0:6337f8cfdd73 24 if(fp != NULL){
tubemerc 0:6337f8cfdd73 25 pc.printf("Writing to SDcard......\n\r");
tubemerc 0:6337f8cfdd73 26 for(int i=1;i<10;i++){
tubemerc 0:6337f8cfdd73 27 fprintf(fp, "%d\n", i);
tubemerc 0:6337f8cfdd73 28 }
tubemerc 0:6337f8cfdd73 29 fclose(fp);
tubemerc 0:6337f8cfdd73 30 }
tubemerc 0:6337f8cfdd73 31 else{
tubemerc 0:6337f8cfdd73 32 pc.printf("Failed.\n\r");
tubemerc 0:6337f8cfdd73 33 }
tubemerc 0:6337f8cfdd73 34 pc.printf("End.\n\r");
tubemerc 0:6337f8cfdd73 35 }