shubham c / Mbed 2 deprecated SBC_TEST_CDMS_CODE

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE by shubham c

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Flash.h Source File

Flash.h

00001 #include "FreescaleIAP.h"
00002 
00003 int strt_add_thres = flash_size() - (11*SECTOR_SIZE);
00004 uint32_t flasharray_thres[32] = {0};
00005 
00006 void FCTN_CDMS_WR_FLASH(uint16_t , uint32_t);
00007 int strt_add = flash_size() - (2*SECTOR_SIZE);
00008 uint32_t flasharray[32];    //256+(3*1024)
00009 uint32_t INITIAL_FLASH[32];
00010 /*corrected*/
00011 int *nativeflash = (int*)strt_add;
00012 
00013 void FLASH_INI()
00014 {
00015     uint32_t read[32]; 
00016     for(int i=0;i<32;i++)
00017         {  
00018             read[i] = nativeflash[i];
00019         }
00020             
00021     if(read[0] == -1)
00022         for(int j=0;j<32;j++)
00023             {   
00024                 FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); 
00025             } 
00026     else
00027        {
00028         for(int j=0;j<32;j++)
00029             {   
00030                 read[j] = nativeflash[j];
00031             }
00032             EPS_V_A_EN_STATUS = read[0];
00033             BAE_SW_STATUS   = read[1]; 
00034             CDMS_SD_SW_STATUS = read[2];
00035             PL_BEE_SW_STATUS = read[3];
00036             PL_EPS_LATCH_SW_EN = read[4];
00037             RTC_INIT_STATUS = read[5];
00038             CDMS_RTC_DISABLE = read[6];
00039             CDMS_RESET_COUNTER = read[7];
00040             TIME_LATEST_CDSMS_RESET = read[8];
00041             COM_TC_BYTES_LIMIT = read[9];
00042             COM_RX_CURRENT_MAX = read[10];
00043             COM_RX_DISABLE_TIMEOUT = read[11];
00044             COM_PA_TMP_HIGH = read[12];
00045             COM_PA_RECOVERY_TIMEOUT = read[13];
00046             COM_SESSION_TIMEOUT = read[14];
00047             COM_RSSI_MIN = read[15];
00048             SD_LIB_BLK_CURRENT = read[16];
00049         }
00050     
00051 }
00052 
00053 /*Writing to the Flash*/
00054 void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t datablock)  //j-position to write address  ; fdata - flash data to be written
00055 {
00056     for(int i=0;i<17;i++)
00057     {
00058         flasharray[i]=nativeflash[i];
00059     }
00060     flasharray[j]=datablock;
00061     erase_sector(strt_add);
00062     program_flash(strt_add, (char*)flasharray,32);
00063 }
00064 /*End*/
00065 
00066 /*===================================================MMS Functions=================================================*/
00067 
00068 void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock);
00069 
00070 void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock)
00071 {
00072     if(mid == 0x0100)
00073     {
00074         FCTN_CDMS_WR_FLASH(11,(datablock>>16) & 0x000000FF);
00075         FCTN_CDMS_WR_FLASH(13,(datablock>>8) & 0x000000FF);
00076         FCTN_CDMS_WR_FLASH(14,datablock & 0x000000FF);
00077     }
00078     else if(mid == 0x0101)
00079     {
00080         FCTN_CDMS_WR_FLASH(12,(datablock>>16) & 0x000000FF);
00081         FCTN_CDMS_WR_FLASH(10,(datablock>>8) & 0x000000FF);
00082         FCTN_CDMS_WR_FLASH(15,datablock & 0x000000FF);
00083     }
00084     else if(mid == 0x0102)
00085     {
00086         FCTN_CDMS_WR_FLASH(9,datablock & 0x0000FFFF);
00087     }
00088     else if(mid == 0x0103)
00089     {
00090         FCTN_CDMS_WR_FLASH(6,datablock & 0x00000001);
00091     } 
00092 }