To fix the hang problem

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Sat Dec 10 13:39:35 2016 +0000
Parent:
323:1f3c756e7b38
Child:
325:d375c11595be
Commit message:
Added sdlib and cdms reset time and counter in flash

Changed in this revision

Flash.h Show annotated file Show diff for this revision Revisions of this file
cdms_sd.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Flash.h	Sat Dec 10 12:41:58 2016 +0000
+++ b/Flash.h	Sat Dec 10 13:39:35 2016 +0000
@@ -13,7 +13,7 @@
 
 void FLASH_INI()
 {
-    INITIAL_FLASH[16] = 8000;
+    INITIAL_FLASH[16] = 80000;
     uint32_t read[32]; 
     for(int i=0;i<32;i++)
     {  
@@ -51,6 +51,7 @@
     COM_SESSION_TIMEOUT = read[14];
     COM_RSSI_MIN = read[15];
     SD_LIB_BLK_CURRENT = read[16];
+    CDMS_RESET_COUNTER = read[17];
 }
 
 /*Writing to the Flash*/
--- a/cdms_sd.h	Sat Dec 10 12:41:58 2016 +0000
+++ b/cdms_sd.h	Sat Dec 10 13:39:35 2016 +0000
@@ -30,7 +30,7 @@
 uint32_t SD_HK_ARCH_LAST= 5000;
 uint32_t LOG_FIRST =5001;
 uint32_t LOG_LAST=6000;
-uint32_t SD_MNG_SECT=8000;
+uint32_t SD_MNG_SECT;
 
 extern uint8_t SD_INIT_FLAGS;
 
@@ -130,6 +130,11 @@
     
     disk_read(buffer,SD_MNG_SECT);
     SD_MNG_SECT += SD_LIB_WRITES/(int)0xFFFF;
+    if(SD_MNG_SECT != SD_LIB_BLK_CURRENT)
+    {
+        SD_LIB_BLK_CURRENT = SD_MNG_SECT;
+        FCTN_CDMS_WR_FLASH(16,SD_LIB_BLK_CURRENT);    
+    }
     SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF;
     disk_write(buffer,SD_MNG_SECT);
  //   gPC.printf("in increment_SD_LIB = %d, %d,%d\n\r", FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3]);
@@ -438,7 +443,6 @@
             gPC.puts("\rv1 initialization successfull\r\n");
             cdv = 512;
             debug_if(SD_DBG, "\n\rInit: SEDCARD_V1\n\r");
-            FCTN_SD_MNGR();
             return SDCARD_V1;
         }
     }
--- a/main.cpp	Sat Dec 10 12:41:58 2016 +0000
+++ b/main.cpp	Sat Dec 10 13:39:35 2016 +0000
@@ -79,13 +79,20 @@
     gCS_RTC = 1;
     gCS_ADF = 1;
     
+    
     FCTN_CDMS_INIT_RTC();/* rtc initialization*/
     FCTN_CDMS_SD_INIT();/* sd card initialization*/
     
+    CDMS_RESET_COUNTER++;
+    FCTN_CDMS_WR_FLASH(17,CDMS_RESET_COUNTER);
+    TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
+    FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET);
     
-    uint8_t test[512] = {0};
-    disk_write(test,8000); //to be used only just before launch
+    SD_MNG_SECT = SD_LIB_BLK_CURRENT;
+    FCTN_SD_MNG();
     
+    
+
     #if DEBUG
     gPC.puts("welcome to mng_tmtc\r\n");
     #endif