SD card functionality
Dependents: ELEC350_Project2 SDcard
Diff: SDCard.cpp
- Revision:
- 13:5f786448e883
- Parent:
- 12:3198f0b7b36f
- Child:
- 14:8e92eb9fc088
diff -r 3198f0b7b36f -r 5f786448e883 SDCard.cpp --- a/SDCard.cpp Sat Dec 22 21:14:56 2018 +0000 +++ b/SDCard.cpp Fri Dec 28 10:03:52 2018 +0000 @@ -3,6 +3,8 @@ void SDcard(void) { + SD_tout.attach(SD_toutISR,TOUT_TIME); + static time_t seconds; //static reqiured? //Initialise the SD card @@ -20,7 +22,7 @@ //Create a filing system for SD Card fs = new FATFileSystem("sd", &sd); printlock.lock(); - pc->printf("SD CARD INITIALISED\n\r"); + pc->printf("\nSD CARD INITIALISED\n\r"); printlock.unlock(); //Open to WRITE @@ -51,10 +53,12 @@ } fclose(fp); } + SD_tout.detach(); } void SDread(int n) { + SD_tout.attach(SD_toutISR,TOUT_TIME); //Read n samples from the SD card unsigned int i=0; unsigned int j = newestIndex; @@ -71,10 +75,12 @@ bufferLock.unlock(); printf("%d records read\r\n\n", i); printlock.unlock(); + SD_tout.detach(); } void SDdelete(int n) //MUST RELEASE SPACE AVAILABLE { + SD_tout.attach(SD_toutISR,TOUT_TIME); //Delete n samples from the SD card unsigned int i = 0; if (n==-1) {n = (BUFFERSIZE-Nspaces);} @@ -89,6 +95,7 @@ printlock.lock(); pc->printf("Deleted %d records\r\n\n\n", i); printlock.unlock(); + SD_tout.detach(); } @@ -114,7 +121,9 @@ while(true) { Thread::signal_wait(SIGNAL_SD); - + + SD_tout.attach(SD_toutISR,TOUT_TIME); + if (sd_init) { fclose(fp); @@ -148,7 +157,7 @@ Thread::wait(5000); LCDlock.unlock(); } - + SD_tout.detach(); } }