Compression code changed and RLY_TMTC pointers managed

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:
Fri Jul 08 14:47:00 2016 +0000
Parent:
248:407ab7e337cd
Child:
250:12de1b155715
Commit message:
flash is done. MMS needs to be completed;

Changed in this revision

DefinitionsAndGlobals.h Show annotated file Show diff for this revision Revisions of this file
FMS_all.h Show annotated file Show diff for this revision Revisions of this file
Flash.h Show annotated file Show diff for this revision Revisions of this file
--- a/DefinitionsAndGlobals.h	Fri Jul 08 12:53:24 2016 +0000
+++ b/DefinitionsAndGlobals.h	Fri Jul 08 14:47:00 2016 +0000
@@ -266,8 +266,10 @@
 DigitalIn SD_OC_FAULT (PIN90);
 DigitalOut SD_SW_EN_DS (PIN97);
 DigitalOut BAE_SW_EN_DS (PIN47);
-DigitalOut TRXY_PWR_CNTRL (PIN84);
-DigitalOut TRZ_PWR_CNTRL (PIN88);
+DigitalOut TRXY_EN (PIN84);
+DigitalOut TRZ_EN (PIN88);
+DigitalOut V_A_EN (PIN99);
+DigitalOut Sys_pwr_rst (PIN96);
 
 DigitalOut PYLD_DFF (PIN73);
 DigitalOut PYLD_DFF_CLK (PIN65);
@@ -319,3 +321,22 @@
 uint8_t CDMS_HK_STATUS;
 uint8_t COM_RX_STATUS;
 uint8_t CDMS_RTC_BL;
+
+//CDMS FLASH parameters
+uint8_t EPS_V_A_EN_STATUS;
+uint8_t BAE_SW_STATUS;
+uint8_t CDMS_SD_SW_STATUS;
+uint8_t PL_BEE_SW_STATUS;
+uint8_t PL_EPS_LATCH_SW_EN;
+uint8_t RTC_INIT_STATUS;
+uint8_t CDMS_RTC_DISABLE;
+uint16_t CDMS_RESET_COUNTER;
+uint32_t TIME_LATEST_CDSMS_RESET;
+uint16_t COM_TC_BYTES_LIMIT;
+uint8_t COM_RX_CURRENT_MAX;
+uint8_t COM_RX_DISABLE_TIMEOUT;
+uint8_t COM_PA_TMP_HIGH;
+uint8_t COM_PA_RECOVERY_TIMEOUT;
+uint8_t COM_SESSION_TIMEOUT;
+uint8_t COM_RSSI_MIN;
+uint16_t SD_LIB_BLK_CURRENT;
--- a/FMS_all.h	Fri Jul 08 12:53:24 2016 +0000
+++ b/FMS_all.h	Fri Jul 08 14:47:00 2016 +0000
@@ -157,14 +157,12 @@
 
 void SW_ON_V_A_EN()
 {
-    TRXY_PWR_CNTRL = 1;
-    TRZ_PWR_CNTRL = 1;
+    V_A_EN = 1;
 }
 
 void SW_OFF_V_A_EN()
 {
-    TRXY_PWR_CNTRL = 0;
-    TRZ_PWR_CNTRL = 0;    
+    V_A_EN = 0;
 }
 
 void RST_SD()
@@ -209,16 +207,16 @@
 
 void SYS_PWR_RESET()  // Have to be decided with EPS team.
 {
-    
+    /*sys_pwr_rst = 0;
+    wait_ms(10);
+    sys_pwr_rst = 1;*/
 }
 
 void EPS_V_A_EN()     // This is a reset function
 {
-    TRXY_PWR_CNTRL = 0;
-    TRZ_PWR_CNTRL = 0;
+    V_A_EN = 0;
     wait_ms(10);
-    TRXY_PWR_CNTRL = 1;
-    TRZ_PWR_CNTRL = 1;
+    V_A_EN = 1;
 }
 
 void EPS_V_C_EN()     // This is a reset function
@@ -279,11 +277,16 @@
 
 /*===================================================MMS Functions=================================================*/
 
-void READ_RAM(uint8_t *);
-void WRITE_TO_FLASH();
-void READ_FLASH();
+void WRITE_TO_FLASH(uint8_t *);
 
-void READ_RAM(uint8_t *RAM)
+void WRITE_TO_FLASH(uint8_t *flash)
 {
-    
-}
\ No newline at end of file
+    uint32_t FLASH[5];
+    FLASH[0] = ((uint32_t)flash[0] << 24) | ((uint32_t)flash[1] << 16) | ((uint32_t)flash[2] << 8) | ((uint32_t)flash[3]); 
+    FLASH[1] = ((uint32_t)flash[4] << 24) | ((uint32_t)flash[5] << 16) | ((uint32_t)flash[6] << 8) | ((uint32_t)flash[7]);
+    FLASH[2] = ((uint32_t)flash[8] << 24) | ((uint32_t)flash[9] << 16) | ((uint32_t)flash[10] << 8) | ((uint32_t)flash[11]);
+    FLASH[3] = ((uint32_t)flash[12] << 24) | ((uint32_t)flash[13] << 16) | ((uint32_t)flash[14] << 8) | ((uint32_t)flash[15]);
+    FLASH[4] = ((uint32_t)flash[16] << 24) | ((uint32_t)flash[17] << 16) | ((uint32_t)flash[18] << 8) | ((uint32_t)flash[19]);
+    erase_sector(strt_add);
+    program_flash(strt_add, (char*)FLASH,160);
+}
--- a/Flash.h	Fri Jul 08 12:53:24 2016 +0000
+++ b/Flash.h	Fri Jul 08 14:47:00 2016 +0000
@@ -1,33 +1,60 @@
 #include "FreescaleIAP.h"
 
 int strt_add = flash_size() - (2*SECTOR_SIZE);
-uint32_t flasharray[8];    //256+(3*1024)
+uint32_t flasharray[5];    //256+(3*1024)
+uint32_t INITIAL_FLASH[5];
 /*corrected*/
 int *nativeflash = (int*)strt_add;
 
+void FLASH_INI()
+{
+    uint32_t read[5]; 
+    for(int i=0;i<5;i++)
+        {  
+            read[i] = nativeflash[i];
+        }
+            
+    if(read[0] == -1)
+        for(int j=0;j<5;j++)
+            {   
+                FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); 
+            } 
+    else
+       {
+        for(int j=0;j<5;j++)
+            {   
+                read[j] = nativeflash[j];
+            }
+            EPS_V_A_EN_STATUS = read[0] >> 31;
+            BAE_SW_STATUS   = (read[0] << 1) >> 30; 
+            CDMS_SD_SW_STATUS = (read[0] << 3) >> 30;
+            PL_BEE_SW_STATUS = (read[0] << 5) >> 30;
+            PL_EPS_LATCH_SW_EN = (read[0] << 7) >> 31;
+            RTC_INIT_STATUS = (read[0] << 8) >> 30;
+            CDMS_RTC_DISABLE = (read[0] << 10) >> 31;
+            CDMS_RESET_COUNTER = read[0];
+            TIME_LATEST_CDSMS_RESET = read[1];
+            COM_TC_BYTES_LIMIT = read[2] >> 16;
+            COM_RX_CURRENT_MAX = (read[2] << 16) >> 24;
+            COM_RX_DISABLE_TIMEOUT = read[2];
+            COM_PA_TMP_HIGH = read[3] >> 24;
+            COM_PA_RECOVERY_TIMEOUT = (read[3] << 8) >> 24;
+            COM_SESSION_TIMEOUT = (read[3] << 16) << 24;
+            COM_RSSI_MIN = read[3];
+            SD_LIB_BLK_CURRENT = read[4] >> 16;
+        }
+    
+}
+
 /*Writing to the Flash*/
-void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t fdata)  //j-position to write address  ; fdata - flash data to be written
+void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t datablock)  //j-position to write address  ; fdata - flash data to be written
 {
-    for(int i=0;i<8;i++)
+    for(int i=0;i<5;i++)
     {
         flasharray[i]=nativeflash[i];
     }
-    flasharray[j]=fdata;
+    flasharray[j]=datablock;
     erase_sector(strt_add);
     program_flash(strt_add, (char*)flasharray,32);
 }
-
 /*End*/
-
-/*Reading from Flash*/
-
-uint32_t* FCTN_BAE_RD_FLASH()
-{
-    for(int i=0;i<8;i++)
-    {
-        flasharray[i]=nativeflash[i];
-    }
-    return flasharray;
-}
-
-/*End*/