SD Card Interface class. Log raw data bytes to memory addresses of your choice, or format the card and use the FAT file system to write files.
Diff: main.cpp
- Revision:
- 2:716abfa4a4d0
- Parent:
- 1:94c648931f84
- Child:
- 3:210eb67b260c
--- a/main.cpp Sat Aug 07 18:32:30 2010 +0000 +++ b/main.cpp Mon Aug 23 01:31:50 2010 +0000 @@ -2,7 +2,9 @@ #include "stdint.h" #include "DirHandle.h" #include "SDCard.h" - +////////////////////////////////////////////////////////////////////////// +//fix timeout and destructor +////////////////////////////////////////////////////////////////////////// SDCard Logger(p5, p6, p7, p8, "SDCard"); DigitalOut led1(LED1); @@ -11,42 +13,17 @@ DigitalOut led4(LED4); Serial Computer(USBTX, USBRX); -Timer Clock; int main() { -Computer.baud(9600); -Clock.start(); -/*///////////////////////////// - unsigned char wdata[5120]; - unsigned char rdata[5120]; -*////////////////////////////// -float workspace[16]; - - /*for (int i = 0; i < 300; i++) - { wdata[i] = 0x03; } - for (int i = 300; i < 550; i++) - { wdata[i] = 0xD5; } - for (int i = 550; i < 5120; i++) - { wdata[i] = 0x0A; }*/ - - Logger.SelectCRCMode(1); + Computer.baud(9600); + Logger.SelectCRCMode(1); + //mkdir("/SDCard/testdir", 1023); - workspace[0] = Clock.read(); - FILE *fp = fopen("/SDCard/Log.txt", "a"); - workspace[1] = Clock.read(); - fprintf(fp, "Start"); - workspace[2] = Clock.read(); - for (int i = 0; i < 1000; i++) - { fprintf(fp, "A"); } - workspace[3] = Clock.read(); + FILE *fp = fopen("/SDCard/message.txt", "w"); + fprintf(fp, "Hello, World!"); fclose(fp); - - Computer.printf("Time 1 = %f \n", workspace[0]); - Computer.printf("Time 2 = %f \n", workspace[1]); - Computer.printf("Time 3 = %f \n", workspace[2]); - Computer.printf("Time 4 = %f \n", workspace[3]); - + /*DIR *d = opendir("/SDCard/testdir"); struct dirent *p; while ((p = readdir(d)) != NULL) @@ -56,21 +33,11 @@ closedir(d); remove("/SDCard/testdir/TEST.txt");*/ //rename("/SDCard/testdir/TEST.txt", "/SDCard/testdir/TEST2.txt"); - - /*for (int i = 0; i < 700; i++) - { Computer.putc(rdata[i]); } - Computer.putc(0xCC); - Logger.Write(7, wdata); - Logger.Read(7, rdata); - for (int i = 0; i < 512; i++) - { - Computer.putc(rdata[i]); - }*/ ///////////////////// if (1) { - while(1) + while (1) { led1 = !led1; wait_ms(250); @@ -84,9 +51,9 @@ }//victory dance else { - while(1) + while (1) { - + led1 = !led1; led2 = !led2; led3 = !led3; @@ -94,6 +61,6 @@ wait_ms(250); } }//failure - //for testing + //for testing ///////////////////// } \ No newline at end of file