Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Flash.h
- Committer:
- chaithanyarss
- Date:
- 2016-07-04
- Revision:
- 220:2aeab83212e6
- Parent:
- 218:c63cdba0550f
File content as of revision 220:2aeab83212e6:
#include "FreescaleIAP.h"
int strt_add = flash_size() - SECTOR_SIZE; // Using the last sector of flash memory
char *nativeflash = (char*)strt_add;
void FCTN_CDMS_WR_FLASH(uint16_t ,uint32_t );
uint32_t* FCTN_CDMS_RD_FLASH();
uint32_t flasharray[5];
uint32_t INITIAL_FLASH_VALUES[5] = {0};
void FLASH_INIT()
{
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_VALUES[j]);
}
else
{
for(int j=0;j<5;j++)
read[j] = nativeflash[j];
EPS_V_A_EN_STATUS = read[0]&0x00000001;
BAE_SW_STATUS = read[0]&0x00000006;
CDMS_SD_SW_STATUS = read[0]&0x00000018;
PL_BEE_SW_STATUS = read[0]&0x00000060;
PL_EPS_LATCH_SW_EN = read[0]&0x00000080;
RTC_INIT_STATUS = read[0]&0x00000300;
CDMS_RTC_DISABLE = read[0]&0x00000400;
CDMS_RESET_COUNTER = read[0]&0xFFFF0000;
TIME_LATEST_CDSMS_RESET = read[1]&0xFFFFFFFF;
COM_TC_BYTES_LIMIT = read[2]&0x0000FFFF;
COM_RX_CURRENT_MAX = read[2]&0x00FF0000;
COM_RX_DISABLE_TIMEOUT = read[2]&0xFF000000;
COM_PA_TMP_HIGH = read[3]&0x000000FF;
COM_PA_RECOVERY_TIMEOUT = read[3]&0x0000FF00;
COM_SESSION_TIMEOUT = read[3]&0x00FF0000;
COM_RSSI_MIN = read[3]&0xFF000000;
SD_LIB_BLK_CURRENT_NMBR = read[4]&0x0000FFFF;
}
}
void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t data) // Function to write into flash
{
for(int64_t i=0;i<5;i++)
{
flasharray[i]=nativeflash[i];
}
flasharray[j]=data;
erase_sector(strt_add);
program_flash(strt_add, (char*)flasharray,32);
}
uint32_t* FCTN_CDMS_RD_FLASH() // Function to read from flash
{
for(int64_t i=0;i<5;i++)
flasharray[i]=nativeflash[i];
return flasharray;
}
