SD card functionality

Dependents:   ELEC350_Project2 SDcard

Revision:
14:8e92eb9fc088
Parent:
13:5f786448e883
Child:
15:e1f62dd17e3c
--- a/SDCard.cpp	Fri Dec 28 10:03:52 2018 +0000
+++ b/SDCard.cpp	Fri Dec 28 12:05:03 2018 +0000
@@ -3,7 +3,7 @@
 
 void SDcard(void)
 {
-    SD_tout.attach(SD_toutISR,TOUT_TIME);
+    SD_tout.attach(SD_toutISR,TOUT_TIME_DEF);
     
     static time_t seconds; //static reqiured?
         
@@ -58,7 +58,7 @@
 
 void SDread(int n)
 {
-    SD_tout.attach(SD_toutISR,TOUT_TIME);
+    SD_tout.attach(SD_toutISR,TOUT_TIME_SDREAD);
     //Read n samples from the SD card   
     unsigned int i=0;
     unsigned int j = newestIndex;
@@ -80,7 +80,7 @@
 
 void SDdelete(int n)  //MUST RELEASE SPACE AVAILABLE
 {
-    SD_tout.attach(SD_toutISR,TOUT_TIME);
+    SD_tout.attach(SD_toutISR,TOUT_TIME_DEF);
     //Delete n samples from the SD card
     unsigned int i = 0;
     if (n==-1) {n = (BUFFERSIZE-Nspaces);}
@@ -122,23 +122,22 @@
     {
         Thread::signal_wait(SIGNAL_SD);
         
-        SD_tout.attach(SD_toutISR,TOUT_TIME);
+        SD_tout.attach(SD_toutISR,TOUT_TIME_SDMOUNT);
            
         if (sd_init)
         {
             fclose(fp);
             sd.deinit();
+            sd_init = false;
             printlock.lock();
             pc->printf("SD CARD UNMOUNTED\n\r");
             printlock.unlock();
             
             LCDlock.lock();
             lcd.cls();
-            lcd.printf("Unmounted..");
-            Thread::wait(5000);
-            LCDlock.unlock();
-            
-            sd_init = false;
+            lcd.printf("SD UNMOUNTED..");
+            Thread::wait(5000); //Dont like this
+            LCDlock.unlock();          
               
         }
         else
@@ -148,13 +147,13 @@
             lcd.cls();
             if (sd_init)
             {
-                lcd.printf("SD mounted..");
+                lcd.printf("SD MOUNTED..");
             }
             else
             {
                 lcd.printf("SD FAILED..");
             }
-            Thread::wait(5000);
+            Thread::wait(5000); //Dont like this
             LCDlock.unlock();        
         } 
         SD_tout.detach();