
publishing to check changes in cdms code
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE_samp_23SEP_DMA_flag by
Flash.h@304:7cc4fe191a54, 2016-09-10 (annotated)
- Committer:
- chaithanyarss
- Date:
- Sat Sep 10 05:10:06 2016 +0000
- Revision:
- 304:7cc4fe191a54
- Parent:
- 289:9bd62b69874c
no SD write and read
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aniruddhv | 52:0bd68655c651 | 1 | #include "FreescaleIAP.h" |
aniruddhv | 52:0bd68655c651 | 2 | |
chaithanyarss | 261:1e54415b34d3 | 3 | int strt_add_thres = flash_size() - (11*SECTOR_SIZE); |
chaithanyarss | 261:1e54415b34d3 | 4 | uint32_t flasharray_thres[32] = {0}; |
chaithanyarss | 261:1e54415b34d3 | 5 | |
ee12b079 | 259:066a7abd2a5f | 6 | void FCTN_CDMS_WR_FLASH(uint16_t , uint32_t); |
chaithanyarss | 257:7d404e9dc9e2 | 7 | int strt_add = flash_size() - (2*SECTOR_SIZE); |
chaithanyarss | 257:7d404e9dc9e2 | 8 | uint32_t flasharray[32]; //256+(3*1024) |
chaithanyarss | 257:7d404e9dc9e2 | 9 | uint32_t INITIAL_FLASH[32]; |
chaithanyarss | 257:7d404e9dc9e2 | 10 | /*corrected*/ |
chaithanyarss | 257:7d404e9dc9e2 | 11 | int *nativeflash = (int*)strt_add; |
chaithanyarss | 257:7d404e9dc9e2 | 12 | |
chaithanyarss | 257:7d404e9dc9e2 | 13 | void FLASH_INI() |
chaithanyarss | 257:7d404e9dc9e2 | 14 | { |
chaithanyarss | 257:7d404e9dc9e2 | 15 | uint32_t read[32]; |
chaithanyarss | 257:7d404e9dc9e2 | 16 | for(int i=0;i<32;i++) |
chaithanyarss | 257:7d404e9dc9e2 | 17 | { |
chaithanyarss | 257:7d404e9dc9e2 | 18 | read[i] = nativeflash[i]; |
chaithanyarss | 257:7d404e9dc9e2 | 19 | } |
chaithanyarss | 257:7d404e9dc9e2 | 20 | |
chaithanyarss | 257:7d404e9dc9e2 | 21 | if(read[0] == -1) |
chaithanyarss | 257:7d404e9dc9e2 | 22 | for(int j=0;j<32;j++) |
chaithanyarss | 257:7d404e9dc9e2 | 23 | { |
chaithanyarss | 257:7d404e9dc9e2 | 24 | FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); |
chaithanyarss | 257:7d404e9dc9e2 | 25 | } |
chaithanyarss | 257:7d404e9dc9e2 | 26 | else |
chaithanyarss | 257:7d404e9dc9e2 | 27 | { |
chaithanyarss | 257:7d404e9dc9e2 | 28 | for(int j=0;j<32;j++) |
chaithanyarss | 257:7d404e9dc9e2 | 29 | { |
chaithanyarss | 257:7d404e9dc9e2 | 30 | read[j] = nativeflash[j]; |
chaithanyarss | 257:7d404e9dc9e2 | 31 | } |
ee12b079 | 259:066a7abd2a5f | 32 | EPS_V_A_EN_STATUS = read[0]; |
ee12b079 | 289:9bd62b69874c | 33 | BAE_STATUS = read[1]; |
ee12b079 | 289:9bd62b69874c | 34 | SD_STATUS = read[2]; |
ee12b079 | 289:9bd62b69874c | 35 | PL_STATUS = read[3]; |
ee12b079 | 259:066a7abd2a5f | 36 | PL_EPS_LATCH_SW_EN = read[4]; |
ee12b079 | 259:066a7abd2a5f | 37 | RTC_INIT_STATUS = read[5]; |
ee12b079 | 259:066a7abd2a5f | 38 | CDMS_RTC_DISABLE = read[6]; |
ee12b079 | 259:066a7abd2a5f | 39 | CDMS_RESET_COUNTER = read[7]; |
ee12b079 | 259:066a7abd2a5f | 40 | TIME_LATEST_CDSMS_RESET = read[8]; |
ee12b079 | 259:066a7abd2a5f | 41 | COM_TC_BYTES_LIMIT = read[9]; |
ee12b079 | 259:066a7abd2a5f | 42 | COM_RX_CURRENT_MAX = read[10]; |
ee12b079 | 259:066a7abd2a5f | 43 | COM_RX_DISABLE_TIMEOUT = read[11]; |
ee12b079 | 259:066a7abd2a5f | 44 | COM_PA_TMP_HIGH = read[12]; |
ee12b079 | 259:066a7abd2a5f | 45 | COM_PA_RECOVERY_TIMEOUT = read[13]; |
ee12b079 | 259:066a7abd2a5f | 46 | COM_SESSION_TIMEOUT = read[14]; |
ee12b079 | 259:066a7abd2a5f | 47 | COM_RSSI_MIN = read[15]; |
ee12b079 | 259:066a7abd2a5f | 48 | SD_LIB_BLK_CURRENT = read[16]; |
chaithanyarss | 257:7d404e9dc9e2 | 49 | } |
chaithanyarss | 257:7d404e9dc9e2 | 50 | |
chaithanyarss | 257:7d404e9dc9e2 | 51 | } |
aniruddhv | 52:0bd68655c651 | 52 | |
aniruddhv | 52:0bd68655c651 | 53 | /*Writing to the Flash*/ |
chaithanyarss | 257:7d404e9dc9e2 | 54 | void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t datablock) //j-position to write address ; fdata - flash data to be written |
aniruddhv | 52:0bd68655c651 | 55 | { |
chaithanyarss | 261:1e54415b34d3 | 56 | for(int i=0;i<17;i++) |
aniruddhv | 52:0bd68655c651 | 57 | { |
aniruddhv | 52:0bd68655c651 | 58 | flasharray[i]=nativeflash[i]; |
aniruddhv | 52:0bd68655c651 | 59 | } |
chaithanyarss | 257:7d404e9dc9e2 | 60 | flasharray[j]=datablock; |
aniruddhv | 52:0bd68655c651 | 61 | erase_sector(strt_add); |
chaithanyarss | 257:7d404e9dc9e2 | 62 | program_flash(strt_add, (char*)flasharray,32); |
aniruddhv | 52:0bd68655c651 | 63 | } |
aniruddhv | 52:0bd68655c651 | 64 | /*End*/ |
aniruddhv | 52:0bd68655c651 | 65 | |
chaithanyarss | 257:7d404e9dc9e2 | 66 | /*===================================================MMS Functions=================================================*/ |
chaithanyarss | 261:1e54415b34d3 | 67 | |
chaithanyarss | 261:1e54415b34d3 | 68 | void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock); |
chaithanyarss | 261:1e54415b34d3 | 69 | |
chaithanyarss | 261:1e54415b34d3 | 70 | void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock) |
chaithanyarss | 261:1e54415b34d3 | 71 | { |
chaithanyarss | 261:1e54415b34d3 | 72 | if(mid == 0x0100) |
chaithanyarss | 261:1e54415b34d3 | 73 | { |
chaithanyarss | 261:1e54415b34d3 | 74 | FCTN_CDMS_WR_FLASH(11,(datablock>>16) & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 75 | FCTN_CDMS_WR_FLASH(13,(datablock>>8) & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 76 | FCTN_CDMS_WR_FLASH(14,datablock & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 77 | } |
chaithanyarss | 261:1e54415b34d3 | 78 | else if(mid == 0x0101) |
chaithanyarss | 261:1e54415b34d3 | 79 | { |
chaithanyarss | 261:1e54415b34d3 | 80 | FCTN_CDMS_WR_FLASH(12,(datablock>>16) & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 81 | FCTN_CDMS_WR_FLASH(10,(datablock>>8) & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 82 | FCTN_CDMS_WR_FLASH(15,datablock & 0x000000FF); |
chaithanyarss | 261:1e54415b34d3 | 83 | } |
chaithanyarss | 261:1e54415b34d3 | 84 | else if(mid == 0x0102) |
chaithanyarss | 261:1e54415b34d3 | 85 | { |
chaithanyarss | 261:1e54415b34d3 | 86 | FCTN_CDMS_WR_FLASH(9,datablock & 0x0000FFFF); |
chaithanyarss | 261:1e54415b34d3 | 87 | } |
chaithanyarss | 261:1e54415b34d3 | 88 | else if(mid == 0x0103) |
chaithanyarss | 261:1e54415b34d3 | 89 | { |
chaithanyarss | 261:1e54415b34d3 | 90 | FCTN_CDMS_WR_FLASH(6,datablock & 0x00000001); |
chaithanyarss | 261:1e54415b34d3 | 91 | } |
chaithanyarss | 261:1e54415b34d3 | 92 | } |