Repository for CDMS code

Dependencies:   SimpleDMA mbed-rtos mbed eeprom

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Flash.h

Committer:
ee12b079
Date:
2016-07-12
Revision:
259:066a7abd2a5f
Parent:
257:7d404e9dc9e2
Child:
261:1e54415b34d3

File content as of revision 259:066a7abd2a5f:

#include "FreescaleIAP.h"

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()
{
    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_SW_STATUS   = read[1]; 
            CDMS_SD_SW_STATUS = read[2];
            PL_BEE_SW_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];
        }
    
}

/*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<5;i++)
    {
        flasharray[i]=nativeflash[i];
    }
    flasharray[j]=datablock;
    erase_sector(strt_add);
    program_flash(strt_add, (char*)flasharray,32);
}
/*End*/

/*===================================================MMS Functions=================================================*/