Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Files at this revision

API Documentation at this revision

Comitter:
chaithanyarss
Date:
Sun Jan 22 04:47:11 2017 +0000
Parent:
350:961baed4572d
Commit message:
EERPOM and BCN done

Changed in this revision

CDMS_HK.h Show annotated file Show diff for this revision Revisions of this file
COM_MNG_TMTC.h Show annotated file Show diff for this revision Revisions of this file
EEPROM.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 diff for this revision Revisions of this file
FreescaleIAP.lib Show diff for this revision Revisions of this file
cdms_rtc.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
eeprom.lib 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
diff -r 961baed4572d -r a89a46894ec0 CDMS_HK.h
--- a/CDMS_HK.h	Sun Jan 22 03:48:18 2017 +0000
+++ b/CDMS_HK.h	Sun Jan 22 04:47:11 2017 +0000
@@ -492,13 +492,13 @@
             SD_FAULTCOUNT++;
             SD_STATUS = (SD_FAULTCOUNT == 3) ? DEVICE_DISABLED :DEVICE_OC_FAULT;
             if(SD_FAULTCOUNT == 3) {
-                FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
+                WRITE_TO_EEPROM(2,DEVICE_DISABLED);
                 gPC.printf("Declaring SD card permanantly Disabled");
             }
         } else {
             SD_STATUS = DEVICE_POWERED;
             if(SD_STATUS != DEVICE_POWERED)
-                FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
+                WRITE_TO_EEPROM(2,DEVICE_POWERED);
             SD_FAULTCOUNT = 0;
         }
     }
@@ -519,13 +519,13 @@
             BAE_FAULTCOUNT++;
             BAE_STATUS = (BAE_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
             if(BAE_FAULTCOUNT == 3) {
-                FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
+                WRITE_TO_EEPROM(1,DEVICE_DISABLED);
                 gPC.printf("Declaring BAE permanantly Disabled");
             }
         } else {
             BAE_STATUS = DEVICE_POWERED;
             if(SD_STATUS != DEVICE_POWERED);
-            FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
+            WRITE_TO_EEPROM(1,DEVICE_POWERED);
             BAE_FAULTCOUNT = 0;
         }
     }
@@ -556,7 +556,7 @@
             PL_FAULTCOUNT++;
             PL_STATUS = (PL_FAULTCOUNT == 3)?DEVICE_DISABLED:DEVICE_OC_FAULT;
             if(PL_FAULTCOUNT == 3) {
-                FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
+                WRITE_TO_EEPROM(3,DEVICE_DISABLED);
                 gPC.printf("Declaring PL_BEE permanantly Disabled");
             }
         } else {
@@ -572,7 +572,7 @@
             }
             PL_STATUS = DEVICE_ENABLED;
             if(PL_STATUS != DEVICE_ENABLED)
-                FCTN_CDMS_WR_FLASH(3,DEVICE_ENABLED);
+                WRITE_TO_EEPROM(3,DEVICE_ENABLED);
             PL_FAULTCOUNT = 0;
         }
     }
diff -r 961baed4572d -r a89a46894ec0 COM_MNG_TMTC.h
--- a/COM_MNG_TMTC.h	Sun Jan 22 03:48:18 2017 +0000
+++ b/COM_MNG_TMTC.h	Sun Jan 22 04:47:11 2017 +0000
@@ -465,7 +465,7 @@
                                 return tm_ptr_short;
                             }                                                        
 
-                            FCTN_CDMS_WR_S_FLASH(mid,(uint32_t)(tc_ptr->TC_string[5]<<24)+(uint32_t)(tc_ptr->TC_string[6]<<16)+(uint32_t)(tc_ptr->TC_string[7]<<8)+(uint32_t)(tc_ptr->TC_string[8]));                                                     
+                            //FCTN_CDMS_WR_S_FLASH(mid,(uint32_t)(tc_ptr->TC_string[5]<<24)+(uint32_t)(tc_ptr->TC_string[6]<<16)+(uint32_t)(tc_ptr->TC_string[7]<<8)+(uint32_t)(tc_ptr->TC_string[8]));                                                     
 
                             ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));              
 
@@ -480,14 +480,12 @@
                                     scp_threshold_m0[z] = tc_ptr->TC_string[z+5];
                                 for(uint8_t z=24;z<32;z++)
                                     scp_threshold_m0[z+8] = tc_ptr->TC_string[z+5];                            
-                                //int strt_add = flash_size() - (11*SECTOR_SIZE);
-                                //uint32_t flasharray[32] = {0};
                                 for(uint8_t z=0;z<24;z++)
                                     flasharray_thres[z] = scp_threshold_m0[z];
                                 for(uint8_t z=24;z<32;z++)
                                     flasharray_thres[z] = scp_threshold_m0[z+8];
-                                erase_sector(strt_add_thres);
-                                program_flash(strt_add_thres, (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
                                 
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
@@ -497,12 +495,11 @@
                             {
                                 for(uint8_t z=0;z<12;z++)
                                     scp_threshold_m0[z+40] = tc_ptr->TC_string[z+5];
-                                //int strt_add = flash_size() - (10*SECTOR_SIZE);
-                                //uint32_t flasharray[32] = {0};
                                 for(uint8_t z=0;z<12;z++)
                                     flasharray_thres[z] = scp_threshold_m0[z+40];
-                                erase_sector(strt_add_thres+SECTOR_SIZE);
-                                program_flash(strt_add_thres+SECTOR_SIZE, (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -511,12 +508,11 @@
                             {
                                 for(uint8_t z=0;z<32;z++)
                                     scp_threshold_m1[z] = tc_ptr->TC_string[z+5];
-                                //int strt_add = flash_size() - (9*SECTOR_SIZE);
-                                //uint32_t flasharray[32] = {0};
                                 for(uint8_t z=0;z<32;z++)
                                     flasharray_thres[z] = scp_threshold_m1[z];
-                                erase_sector(strt_add_thres+(2*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(2*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -525,12 +521,11 @@
                             {
                                 for(uint8_t z=0;z<20;z++)
                                     scp_threshold_m1[z+32] = tc_ptr->TC_string[z+5];
-                                //int strt_add = flash_size() - (8*SECTOR_SIZE);
-                                //uint32_t flasharray[32] = {0};
                                 for(uint8_t z=0;z<20;z++)
                                     flasharray_thres[z] = scp_threshold_m1[z+32];
-                                erase_sector(strt_add_thres+(3*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(3*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -546,8 +541,6 @@
                                 scp_sfp_threshold_m0_2[0] = tc_ptr->TC_string[14];
                                 scp_sfp_threshold_m0_2[1] = tc_ptr->TC_string[15];
                                 scp_sfp_threshold_m0_2[2] = tc_ptr->TC_string[16];
-                                //int strt_add = flash_size() - (7*SECTOR_SIZE);
-                                //uint32_t flasharray[32] = {0};
                                 flasharray_thres[0] = scp_threshold_m0_1[7];
                                 flasharray_thres[1] = scp_threshold_m0_1[5];
                                 flasharray_thres[2] = scp_threshold_m0_1[8];
@@ -557,8 +550,9 @@
                                 flasharray_thres[9]  = scp_sfp_threshold_m0_2[0];
                                 flasharray_thres[10] = scp_sfp_threshold_m0_2[1];
                                 flasharray_thres[11] = scp_sfp_threshold_m0_2[2];
-                                erase_sector(strt_add_thres+(4*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(4*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -569,14 +563,13 @@
                                     sfp_threshold_m0[z] = tc_ptr->TC_string[z+5];
                                 for(uint8_t z=24;z<32;z++)
                                     sfp_threshold_m0[z+8] = tc_ptr->TC_string[z+5];
-                                //int strt_add_thres = flash_size() - (6*SECTOR_SIZE);
-                                //uint32_t flasharray_thres[32] = {0};
                                 for(uint8_t z=0;z<24;z++)
                                     flasharray_thres[z] = sfp_threshold_m0[z];
                                 for(uint8_t z=24;z<32;z++)
                                     flasharray_thres[z] = sfp_threshold_m0[z+8];
-                                erase_sector(strt_add_thres+(5*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(5*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -585,12 +578,11 @@
                             {
                                 for(uint8_t z=0;z<12;z++)
                                     sfp_threshold_m0[z+40] = tc_ptr->TC_string[z+5];
-                                //int strt_add_thres = flash_size() - (5*SECTOR_SIZE);
-                                //uint32_t flasharray_thres[32] = {0};
                                 for(uint8_t z=0;z<12;z++)
                                     flasharray_thres[z] = sfp_threshold_m0[z+40];
-                                erase_sector(strt_add_thres+(6*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(6*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -599,12 +591,11 @@
                             {
                                 for(uint8_t z=0;z<32;z++)
                                     sfp_threshold_m1[z] = tc_ptr->TC_string[z+5];
-                                //int strt_add_thres = flash_size() - (4*SECTOR_SIZE);
-                                //uint32_t flasharray_thres[32] = {0};
                                 for(uint8_t z=0;z<32;z++)
                                     flasharray_thres[z] = sfp_threshold_m1[z];
-                                erase_sector(strt_add_thres+(7*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(7*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
@@ -613,12 +604,11 @@
                             {
                                 for(uint8_t z=0;z<20;z++)
                                     sfp_threshold_m1[z+32] = tc_ptr->TC_string[z+5];
-                                //int strt_add_thres = flash_size() - (3*SECTOR_SIZE);
-                                //uint32_t flasharray_thres[32] = {0};
                                 for(uint8_t z=0;z<20;z++)
                                     flasharray_thres[z] = sfp_threshold_m1[z+32];
-                                erase_sector(strt_add_thres+(8*SECTOR_SIZE));
-                                program_flash(strt_add_thres+(8*SECTOR_SIZE), (char*)flasharray_thres,32);
+                                
+                                THRES_WRITE_TO_EEPROM(mid,flasharray_thres);
+                                
                                 Base_tm *tm_ptr_short = new Short_tm;
                                 ACK_L234(tm_ptr_short,0xA0,GETpacket_seq_count(tc_ptr));
                                 return tm_ptr_short;
diff -r 961baed4572d -r a89a46894ec0 EEPROM.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EEPROM.h	Sun Jan 22 04:47:11 2017 +0000
@@ -0,0 +1,69 @@
+#ifndef EEPROM_H
+#define EEPROM_H
+
+#define ee_scl PIN86
+#define ee_sda PIN87
+#define check 10
+
+EEPROM e2prom(ee_sda, ee_scl, 0, EEPROM::T24C512);
+int32_t INITIAL_EEPROM[32] = {1,1,1,1,1,0,0,0,0,35001,0xff,300,85,20,20,3,80000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+uint32_t flasharray_thres[32];
+
+void WRITE_TO_EEPROM(uint32_t address, int32_t data_block)
+{
+    e2prom.write(address*4+10,data_block);
+}
+
+void THRES_WRITE_TO_EEPROM(uint16_t mid, uint32_t* thres_data)
+{
+    int8_t data[128];
+    memcpy(data,&thres_data,128);
+    
+    if(mid <11 & mid >1)
+    {
+        e2prom.write((uint32_t)(mid-1)*128,data,128);
+    }    
+}
+
+uint32_t READ_FROM_EERPOM(uint32_t address)
+{
+    int32_t data;
+    e2prom.read(address*4+10, data);
+    return (uint32_t)data;
+}
+
+void INIT_EEPROM()
+{
+    int32_t test_buffer;
+    e2prom.ready();
+    e2prom.read(2,test_buffer);
+    if(test_buffer == 0)
+    {
+        for(int i=0;i<32;i++)
+            WRITE_TO_EEPROM( i, INITIAL_EEPROM[i]);
+        
+        e2prom.write(2,1);
+        gPC.printf("starting flash");
+    }
+    
+    gPC.printf("Reading intial parametrs from flash\n");
+    EPS_V_A_EN_STATUS         = READ_FROM_EERPOM(0);
+    BAE_STATUS                = READ_FROM_EERPOM(1);
+    SD_STATUS                 = READ_FROM_EERPOM(2);
+    PL_STATUS                 = READ_FROM_EERPOM(3);
+    PL_EPS_LATCH_SW_EN        = READ_FROM_EERPOM(4);
+    RTC_INIT_STATUS           = READ_FROM_EERPOM(5);
+    CDMS_RTC_DISABLE          = READ_FROM_EERPOM(6);
+    CDMS_RESET_COUNTER        = READ_FROM_EERPOM(7);
+    TIME_LATEST_CDSMS_RESET   = READ_FROM_EERPOM(8);
+    COM_TC_BYTES_LIMIT        = READ_FROM_EERPOM(9);
+    COM_RX_CURRENT_MAX        = READ_FROM_EERPOM(10);
+    COM_RX_DISABLE_TIMEOUT    = READ_FROM_EERPOM(11);
+    COM_PA_TMP_HIGH           = READ_FROM_EERPOM(12);
+    COM_PA_RECOVERY_TIMEOUT   = READ_FROM_EERPOM(13);
+    COM_SESSION_TIMEOUT       = READ_FROM_EERPOM(14);
+    COM_RSSI_MIN              = READ_FROM_EERPOM(15);
+    SD_LIB_BLK_CURRENT        = READ_FROM_EERPOM(16);
+}
+
+#endif
\ No newline at end of file
diff -r 961baed4572d -r a89a46894ec0 FMS_all.h
--- a/FMS_all.h	Sun Jan 22 03:48:18 2017 +0000
+++ b/FMS_all.h	Sun Jan 22 04:47:11 2017 +0000
@@ -83,7 +83,7 @@
 {
     SD_SW_EN_DS = 1;
     SD_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
+    WRITE_TO_EEPROM(2,DEVICE_POWERED);
     gPC.printf("sw on sd\n");
 }
 
@@ -91,7 +91,7 @@
 {
     SD_SW_EN_DS = 0;
     SD_STATUS = DEVICE_DISABLED;
-    FCTN_CDMS_WR_FLASH(2,DEVICE_DISABLED);
+    WRITE_TO_EEPROM(2,DEVICE_DISABLED);
     gPC.printf("sw off sd\n");
 }
 
@@ -122,7 +122,7 @@
 {
     BAE_SW_EN_DS = 1;
     BAE_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
+    WRITE_TO_EEPROM(1,DEVICE_POWERED);
     gPC.printf("sw on bae\n");
 }
 
@@ -130,7 +130,7 @@
 {
     BAE_SW_EN_DS = 0;
     BAE_STATUS = DEVICE_DISABLED;
-    FCTN_CDMS_WR_FLASH(1,DEVICE_DISABLED);
+    WRITE_TO_EEPROM(1,DEVICE_DISABLED);
     gPC.printf("sw off bae\n");
 }
 
@@ -144,7 +144,7 @@
     PYLD_DFF_CLK = 0;
     wait_us(1);
     PL_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
+    WRITE_TO_EEPROM(3,DEVICE_POWERED);
 }
 
 void SW_OFF_PL_BEE()
@@ -157,7 +157,7 @@
     PYLD_DFF_CLK = 0;
     wait_us(1);
     PL_STATUS = DEVICE_DISABLED;
-    FCTN_CDMS_WR_FLASH(3,DEVICE_DISABLED);
+    WRITE_TO_EEPROM(3,DEVICE_DISABLED);
 }
 
 void SW_ON_PL_EPS()
@@ -170,7 +170,7 @@
     PYLD_EPS_DFF_PWR_CLK = 0;
     wait_us(1);
     PL_EPS_LATCH_SW_EN = 1;
-    FCTN_CDMS_WR_FLASH(4,1);
+    WRITE_TO_EEPROM(4,1);
 }
 
 void SW_OFF_PL_EPS()
@@ -183,21 +183,21 @@
     PYLD_EPS_DFF_PWR_CLK = 0;
     wait_us(1);
     PL_EPS_LATCH_SW_EN = 0;
-    FCTN_CDMS_WR_FLASH(4,0);
+    WRITE_TO_EEPROM(4,0);
 }
 
 void SW_ON_V_A_EN()
 {
     V_A_EN = 1;
     EPS_V_A_EN_STATUS = 1;
-    FCTN_CDMS_WR_FLASH(0,1);
+    WRITE_TO_EEPROM(0,1);
 }
 
 void SW_OFF_V_A_EN()
 {
     V_A_EN = 0;
     EPS_V_A_EN_STATUS = 0;
-    FCTN_CDMS_WR_FLASH(0,0);
+    WRITE_TO_EEPROM(0,0);
 }
 
 void RST_SD()
@@ -206,7 +206,7 @@
     wait_ms(10);
     SD_SW_EN_DS = 1;
     SD_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(2,DEVICE_POWERED);
+    WRITE_TO_EEPROM(2,DEVICE_POWERED);
     gPC.printf("rst sd\n");
 }
 
@@ -217,7 +217,7 @@
     BAE_SW_EN_DS = 1;
     wait_ms(100);
     BAE_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(1,DEVICE_POWERED);
+    WRITE_TO_EEPROM(1,DEVICE_POWERED);
     gPC.printf("rst bae\n");
 }
 
@@ -227,7 +227,7 @@
     wait_ms(10);
     PYLD_DFF = 1;
     PL_STATUS = DEVICE_POWERED;
-    FCTN_CDMS_WR_FLASH(3,DEVICE_POWERED);
+    WRITE_TO_EEPROM(3,DEVICE_POWERED);
 }
 
 void RST_BAE()
diff -r 961baed4572d -r a89a46894ec0 Flash.h
--- a/Flash.h	Sun Jan 22 03:48:18 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,113 +0,0 @@
-#include "FreescaleIAP.h"
-
-int strt_add_thres = flash_size() - (11*SECTOR_SIZE);
-uint32_t flasharray_thres[32] = {0};
-
-void FCTN_CDMS_WR_FLASH(uint16_t , uint32_t);
-int strt_add = flash_size() - (2*SECTOR_SIZE);
-uint32_t flasharray[32];    //256+(3*1024)
-uint32_t INITIAL_FLASH[32];
-
-/*corrected*/
-int *nativeflash = (int*)strt_add;
-
-void FLASH_INI()
-{
-    INITIAL_FLASH[16] = 80000;
-    uint32_t read[32]; 
-    for(int i=0;i<32;i++)
-    {  
-        read[i] = nativeflash[i];
-    }
-            
-    if(read[0] == -1)
-    {
-        for(int j=0;j<32;j++)
-        {   
-            FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); 
-        } 
-    }
-    else
-    {
-        for(int j=0;j<32;j++)
-        {   
-            read[j] = nativeflash[j];
-        }
-    }
-    EPS_V_A_EN_STATUS = read[0];
-    BAE_STATUS = read[1]; 
-    SD_STATUS = read[2];
-    PL_STATUS = read[3];
-    PL_EPS_LATCH_SW_EN = read[4];
-    RTC_INIT_STATUS = read[5];
-    CDMS_RTC_DISABLE = read[6];
-    CDMS_RESET_COUNTER = read[7];
-    TIME_LATEST_CDSMS_RESET = read[8];
-    COM_TC_BYTES_LIMIT = read[9];
-    COM_RX_CURRENT_MAX = read[10];
-    COM_RX_DISABLE_TIMEOUT = read[11];
-    COM_PA_TMP_HIGH = read[12];
-    COM_PA_RECOVERY_TIMEOUT = read[13];
-    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*/
-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<17;i++)
-    {
-        flasharray[i]=nativeflash[i];
-    }
-    flasharray[j]=datablock;
-    erase_sector(strt_add);
-    program_flash(strt_add, (char*)flasharray,32);
-}
-/*End*/
-
-/*===================================================MMS Functions=================================================*/
-
-void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock);
-
-void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock)
-{
-    if(mid == 0x0100)
-    {
-        FCTN_CDMS_WR_FLASH(11,(datablock>>16) & 0x000000FF);
-        FCTN_CDMS_WR_FLASH(13,(datablock>>8) & 0x000000FF);
-        FCTN_CDMS_WR_FLASH(14,datablock & 0x000000FF);
-    }
-    else if(mid == 0x0101)
-    {
-        FCTN_CDMS_WR_FLASH(12,(datablock>>16) & 0x000000FF);
-        FCTN_CDMS_WR_FLASH(10,(datablock>>8) & 0x000000FF);
-        FCTN_CDMS_WR_FLASH(15,datablock & 0x000000FF);
-    }
-    else if(mid == 0x0102)
-    {
-        FCTN_CDMS_WR_FLASH(9,datablock & 0x0000FFFF);
-    }
-    else if(mid == 0x0103)
-    {
-        FCTN_CDMS_WR_FLASH(6,datablock & 0x00000001);
-    } 
-}
-
-int verify_flash_sector(int mid,uint32_t* flasharray_thres)
-{
-    int add = strt_add_thres + ((mid-1)*SECTOR_SIZE);
-    int result = 0;
-    int* testflash = (int*)add;
-    for(int i=0;i<32;i++)
-    {  
-        if(testflash[i] == flasharray_thres[i])
-            continue;
-        else
-        {
-            return 1;
-        }
-    }
-    return 0;
-}
\ No newline at end of file
diff -r 961baed4572d -r a89a46894ec0 FreescaleIAP.lib
--- a/FreescaleIAP.lib	Sun Jan 22 03:48:18 2017 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/Sissors/code/FreescaleIAP/#6749f7702fa5
diff -r 961baed4572d -r a89a46894ec0 cdms_rtc.h
--- a/cdms_rtc.h	Sun Jan 22 03:48:18 2017 +0000
+++ b/cdms_rtc.h	Sun Jan 22 04:47:11 2017 +0000
@@ -80,7 +80,7 @@
     gCS_RTC=1;
     gPC.puts("\n\r rtc initalised \n");
     RTC_INIT_STATUS = 1;
-    FCTN_CDMS_WR_FLASH(5,1);
+    WRITE_TO_EEPROM(5,1);
     SPI_mutex.unlock();
 }
  
diff -r 961baed4572d -r a89a46894ec0 cdms_sd.h
--- a/cdms_sd.h	Sun Jan 22 03:48:18 2017 +0000
+++ b/cdms_sd.h	Sun Jan 22 04:47:11 2017 +0000
@@ -133,7 +133,7 @@
     if(SD_MNG_SECT != SD_LIB_BLK_CURRENT)
     {
         SD_LIB_BLK_CURRENT = SD_MNG_SECT;
-        FCTN_CDMS_WR_FLASH(16,SD_LIB_BLK_CURRENT);    
+        WRITE_TO_EEPROM(16,SD_LIB_BLK_CURRENT);    
     }
     SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF;
     disk_write(buffer,SD_MNG_SECT);
diff -r 961baed4572d -r a89a46894ec0 eeprom.lib
--- a/eeprom.lib	Sun Jan 22 03:48:18 2017 +0000
+++ b/eeprom.lib	Sun Jan 22 04:47:11 2017 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/bborredon/code/eeprom/#b65b74065b7f
+https://developer.mbed.org/users/chaithanyarss/code/eeprom/#b65b74065b7f
diff -r 961baed4572d -r a89a46894ec0 main.cpp
--- a/main.cpp	Sun Jan 22 03:48:18 2017 +0000
+++ b/main.cpp	Sun Jan 22 04:47:11 2017 +0000
@@ -1,6 +1,7 @@
 // TESTING PUSH PULL IN MAIN CPP
 
 #include "mbed.h"
+#include "eeprom.h"
 
 #define DEBUG 1
 
@@ -14,8 +15,8 @@
 #include "DefinitionsAndGlobals.h"
 #include "crc.h"
 #include "i2c.h"
+#include "EEPROM.h"
 #include "COM_SND_TM_functions.h"
-#include "Flash.h"
 #include "cdms_rtc.h"
 #include "COM_SND_TM.h"
 #include "cdms_sd.h"
@@ -84,9 +85,9 @@
     FCTN_CDMS_SD_INIT();/* sd card initialization*/
     
     CDMS_RESET_COUNTER++;
-    FCTN_CDMS_WR_FLASH(17,CDMS_RESET_COUNTER);
+    WRITE_TO_EEPROM(7,CDMS_RESET_COUNTER);
     TIME_LATEST_CDSMS_RESET = FCTN_CDMS_RD_RTC() >> 7;
-    FCTN_CDMS_WR_FLASH(8,TIME_LATEST_CDSMS_RESET);
+    WRITE_TO_EEPROM(8,TIME_LATEST_CDSMS_RESET);
     
     uint8_t test[512];
     for(int i =0; i<512; i++)