Mathew Swabey / SDCard

Dependents:   ELEC350_Project2 SDcard

Files at this revision

API Documentation at this revision

Comitter:
Swabey89
Date:
Fri Dec 28 10:03:52 2018 +0000
Parent:
12:3198f0b7b36f
Child:
14:8e92eb9fc088
Commit message:
Updated

Changed in this revision

SDCard.cpp Show annotated file Show diff for this revision Revisions of this file
SDCard.hpp Show annotated file Show diff for this revision Revisions of this file
--- 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(); 
     }   
 }
 
--- a/SDCard.hpp	Sat Dec 22 21:14:56 2018 +0000
+++ b/SDCard.hpp	Fri Dec 28 10:03:52 2018 +0000
@@ -15,6 +15,8 @@
 extern unsigned int newestIndex;
 extern unsigned int oldestIndex;
 extern sensorData buffer[BUFFERSIZE];
+extern Timeout SD_tout;
+extern void SD_toutISR(void);
 
 //TEST SD
 extern Mutex printlock;