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
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 00011 /*corrected*/ 00012 int *nativeflash = (int*)strt_add; 00013 00014 void FLASH_INI() 00015 { 00016 INITIAL_FLASH[16] = 80000; 00017 uint32_t read[32]; 00018 for(int i=0;i<32;i++) 00019 { 00020 read[i] = nativeflash[i]; 00021 } 00022 00023 if(read[0] == -1) 00024 { 00025 for(int j=0;j<32;j++) 00026 { 00027 FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); 00028 } 00029 } 00030 else 00031 { 00032 for(int j=0;j<32;j++) 00033 { 00034 read[j] = nativeflash[j]; 00035 } 00036 } 00037 EPS_V_A_EN_STATUS = read[0]; 00038 BAE_STATUS = read[1]; 00039 SD_STATUS = read[2]; 00040 PL_STATUS = read[3]; 00041 PL_EPS_LATCH_SW_EN = read[4]; 00042 RTC_INIT_STATUS = read[5]; 00043 CDMS_RTC_DISABLE = read[6]; 00044 CDMS_RESET_COUNTER = read[7]; 00045 TIME_LATEST_CDSMS_RESET = read[8]; 00046 COM_TC_BYTES_LIMIT = read[9]; 00047 COM_RX_CURRENT_MAX = read[10]; 00048 COM_RX_DISABLE_TIMEOUT = read[11]; 00049 COM_PA_TMP_HIGH = read[12]; 00050 COM_PA_RECOVERY_TIMEOUT = read[13]; 00051 COM_SESSION_TIMEOUT = read[14]; 00052 COM_RSSI_MIN = read[15]; 00053 SD_LIB_BLK_CURRENT = read[16]; 00054 CDMS_RESET_COUNTER = read[17]; 00055 } 00056 00057 /*Writing to the Flash*/ 00058 void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t datablock) //j-position to write address ; fdata - flash data to be written 00059 { 00060 for(int i=0;i<17;i++) 00061 { 00062 flasharray[i]=nativeflash[i]; 00063 } 00064 flasharray[j]=datablock; 00065 erase_sector(strt_add); 00066 program_flash(strt_add, (char*)flasharray,32); 00067 } 00068 /*End*/ 00069 00070 /*===================================================MMS Functions=================================================*/ 00071 00072 void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock); 00073 00074 void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock) 00075 { 00076 if(mid == 0x0100) 00077 { 00078 FCTN_CDMS_WR_FLASH(11,(datablock>>16) & 0x000000FF); 00079 FCTN_CDMS_WR_FLASH(13,(datablock>>8) & 0x000000FF); 00080 FCTN_CDMS_WR_FLASH(14,datablock & 0x000000FF); 00081 } 00082 else if(mid == 0x0101) 00083 { 00084 FCTN_CDMS_WR_FLASH(12,(datablock>>16) & 0x000000FF); 00085 FCTN_CDMS_WR_FLASH(10,(datablock>>8) & 0x000000FF); 00086 FCTN_CDMS_WR_FLASH(15,datablock & 0x000000FF); 00087 } 00088 else if(mid == 0x0102) 00089 { 00090 FCTN_CDMS_WR_FLASH(9,datablock & 0x0000FFFF); 00091 } 00092 else if(mid == 0x0103) 00093 { 00094 FCTN_CDMS_WR_FLASH(6,datablock & 0x00000001); 00095 } 00096 } 00097 00098 int verify_flash_sector(int mid,uint32_t* flasharray_thres) 00099 { 00100 int add = strt_add_thres + ((mid-1)*SECTOR_SIZE); 00101 int result = 0; 00102 int* testflash = (int*)add; 00103 for(int i=0;i<32;i++) 00104 { 00105 if(testflash[i] == flasharray_thres[i]) 00106 continue; 00107 else 00108 { 00109 return 1; 00110 } 00111 } 00112 return 0; 00113 }
Generated on Tue Jul 26 2022 00:15:16 by
