![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
sdcard
Dependencies: SDFileSystem mbed
Fork of rtcfinalcodeyuppie by
Revision 6:31a33cbe6cdb, committed 2015-06-04
- Comitter:
- cholletisaik777
- Date:
- Thu Jun 04 10:46:25 2015 +0000
- Parent:
- 5:3979ca24777a
- Commit message:
- sd card
Changed in this revision
rtsc.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 3979ca24777a -r 31a33cbe6cdb rtsc.cpp --- a/rtsc.cpp Tue Feb 03 17:10:21 2015 +0000 +++ b/rtsc.cpp Thu Jun 04 10:46:25 2015 +0000 @@ -1,10 +1,10 @@ #include "rtsc.h" SPI spi(PTD6, PTD7, PTD5); -DigitalOut cs(PTD2); +//DigitalOut cs(PTD2); -SDFileSystem sd(PTD6, PTD7, PTD5, D10,"sd"); +SDFileSystem sd(PTD6, PTD7, PTD5, PTD2,"sd"); - void spiwrite(int a) + /*void spiwrite(int a) { cs=1; cs=0; @@ -33,7 +33,7 @@ return(time); -} +}*/ int hexint(int a) { @@ -43,7 +43,7 @@ //storedata stores the dummy structure in the file with timestamp as the filename in HK directory void storedata(void) { - spi.format(8,3); + /*spi.format(8,3); spi.frequency(1000000); spiwrite(0x80); //write seconds to 01 spiwrite(0x81); //write minutes t0 01 @@ -60,10 +60,18 @@ int date =spiread(0x04); //read day of the month int month =spiread(0x05); //read month int year =spiread(0x06); //read year - cs = 1; + cs = 1; */ + + + mkdir("/sd/TIME", 0777); + FILE*fp1= fopen("/sd/TIME/timer.txt", "w"); + if(fp1 == NULL) { + error("Could not open file for write\n"); + } + fclose(fp1); //Assigning dummy values to the structure - + for(int i=0;i<1000000;i++){ SensorData Sensor; printf("Writing dummy values\n"); @@ -83,16 +91,24 @@ printf("Done writing dummy values\n"); mkdir("/sd/hk", 0777); char date2[100]="/sd/hk/"; - strcat(date2,getname(year,month,date,day,hours,minutes,seconds)); + char str[15]; +sprintf(str, "%d", i); +strcat(date2,str); strcat(date2,".txt"); - FILE *fp ; + + if(i%20==0) + {FILE *fp ; + Timer t1; + t1.start(); fp= fopen(date2, "w"); if(fp == NULL) { error("Could not open file for write\n"); } else { - fprintf(fp, "%s -", Sensor.Voltage); + int p; + for(p=0;p<20;p++) + {fprintf(fp, "%s -", Sensor.Voltage); fprintf(fp,"%s -",Sensor.Current); fprintf(fp,"%c -",Sensor.Temperature); fprintf(fp,"%s -",Sensor.PanelTemperature); @@ -104,11 +120,24 @@ fprintf(fp,"%c -",Sensor.faultir); fprintf(fp,"%c -",Sensor.power_mode); fprintf(fp,"%s -",Sensor.AngularSpeed); - fprintf(fp,"%s",Sensor.Bnewvalue); + fprintf(fp,"%s\n",Sensor.Bnewvalue);} fclose(fp); - printf("%s",getname(year,month,date,day,hours,minutes,seconds)); - wait(10); + t1.stop(); + float timesd=t1.read(); + printf("The time taken for writing 5 hk data was %f seconds\n", timesd); + //printf("%s",getname(year,month,date,day,hours,minutes,seconds)); + FILE *fp2=fopen("/sd/TIME/timer.txt", "a"); + if(fp2 == NULL) { + error("Could not open file for write\n"); + } + else + { + fprintf(fp2,"%f \n",timesd); + + } + fclose(fp2); + wait(3); - } + }} }} \ No newline at end of file