File manager

Dependencies:   SDFileSystem

Dependents:   RwSDCard_Xml_GPS

Revision:
22:2fc64ad66e35
Parent:
21:0c52dbc23f52
Child:
23:7ffd9724e105
diff -r 0c52dbc23f52 -r 2fc64ad66e35 FileManager.cpp
--- a/FileManager.cpp	Wed May 25 10:21:50 2016 +0000
+++ b/FileManager.cpp	Wed May 25 11:43:45 2016 +0000
@@ -28,7 +28,7 @@
 
 /** Connect pin for SD Card Switch  */ 
 #ifdef SDCARD_SWITCH
-InterruptIn sdSwitch(SDCARD_SWITCH);
+//InterruptIn sdSwitch(SDCARD_SWITCH);
 #else
 InterruptIn sdSwitch(NC);
 #endif
@@ -295,7 +295,7 @@
         printf("\r\n Writing to Log File (%s)....",file_name);
 
         /* Write timestamp */
-        fprintf(fp, "%d,%d",timestamp,0); 
+        fprintf(fp, "%d,%d",timestamp,(msec.read_ms()%MSEC_SCALE)); 
 
         /* Write variable data */
         for(int i = 0; i < size; i++)
@@ -570,10 +570,18 @@
 static void FILEMANAGER_SetLedStatus(bool on)
 {
     /* Check LED Connection  */
-    if (ledStatus.is_connected() && m_sdCardIsPresent)
+    if (ledStatus.is_connected())
     {
         /* Set LED regarding to given argment */
-        ledStatus = on;
+        if (m_sdCardIsPresent)
+        {
+            ledStatus = on;
+        }
+        else
+        {
+            ledStatus = false;
+        }
+        
     }
     #if DEBUG
     else
@@ -582,7 +590,7 @@
     }
     #endif
 }
-#ifdef SDCARD_SWITCH
+#if 0
 /**
  * @brief Function to init File Manager 
  * @note  
@@ -596,7 +604,9 @@
         m_sdCardIsPresent = true;
     }
     FILEMANAGER_SetLedStatus(true);
-    sdSwitch.fall(&FILEMANAGER_SDDisconnect);
+    
+    printf("\r\n  ===== SDCard Init !!");
+    sdSwitch.rise(&FILEMANAGER_SDConnect);
 }
 /**
  * @brief Interrupt function for sd card disconnect
@@ -606,9 +616,11 @@
  */
 void FILEMANAGER_SDDisconnect()
 {
+    printf("\r\n  ===== SDCard Disconnect !!");
+    wait_ms(20);
     m_sdCardIsPresent = false;
     FILEMANAGER_SetLedStatus(false);
-    sdSwitch.rise(&FILEMANAGER_SDConnect);
+    //sdSwitch.rise(&FILEMANAGER_SDConnect);
     
 
 }
@@ -620,9 +632,10 @@
  */
 void FILEMANAGER_SDConnect()
 {
+    printf("\r\n  ===== SDCard Connect !!");
     m_sdCardIsPresent = true;
     FILEMANAGER_SetLedStatus(true);
-    sdSwitch.fall(&FILEMANAGER_SDDisconnect);    
+    //sdSwitch.fall(&FILEMANAGER_SDDisconnect);    
      NVIC_SystemReset();
 }
 #endif