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: mbed mbed-rtos SimpleDMA FreescaleIAP eeprom
Fork of CDMS_CODE_FM_28JAN2017 by
Flash.h@324:c0a5228cc666, 2016-12-10 (annotated)
- Committer:
 - chaithanyarss
 - Date:
 - Sat Dec 10 13:39:35 2016 +0000
 - Revision:
 - 324:c0a5228cc666
 - Parent:
 - 322:7d906d34aaff
 - Child:
 - 325:d375c11595be
 
Added sdlib and cdms reset time and counter in flash
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]; | 
| ee12b079 | 322:7d906d34aaff | 10 | |
| chaithanyarss | 257:7d404e9dc9e2 | 11 | /*corrected*/ | 
| chaithanyarss | 257:7d404e9dc9e2 | 12 | int *nativeflash = (int*)strt_add; | 
| chaithanyarss | 257:7d404e9dc9e2 | 13 | |
| chaithanyarss | 257:7d404e9dc9e2 | 14 | void FLASH_INI() | 
| chaithanyarss | 257:7d404e9dc9e2 | 15 | { | 
| chaithanyarss | 324:c0a5228cc666 | 16 | INITIAL_FLASH[16] = 80000; | 
| chaithanyarss | 257:7d404e9dc9e2 | 17 | uint32_t read[32]; | 
| chaithanyarss | 257:7d404e9dc9e2 | 18 | for(int i=0;i<32;i++) | 
| ee12b079 | 322:7d906d34aaff | 19 | { | 
| ee12b079 | 322:7d906d34aaff | 20 | read[i] = nativeflash[i]; | 
| ee12b079 | 322:7d906d34aaff | 21 | } | 
| chaithanyarss | 257:7d404e9dc9e2 | 22 | |
| chaithanyarss | 257:7d404e9dc9e2 | 23 | if(read[0] == -1) | 
| ee12b079 | 322:7d906d34aaff | 24 | { | 
| chaithanyarss | 257:7d404e9dc9e2 | 25 | for(int j=0;j<32;j++) | 
| ee12b079 | 322:7d906d34aaff | 26 | { | 
| ee12b079 | 322:7d906d34aaff | 27 | FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH[j]); | 
| ee12b079 | 322:7d906d34aaff | 28 | } | 
| ee12b079 | 322:7d906d34aaff | 29 | } | 
| chaithanyarss | 257:7d404e9dc9e2 | 30 | else | 
| ee12b079 | 322:7d906d34aaff | 31 | { | 
| chaithanyarss | 257:7d404e9dc9e2 | 32 | for(int j=0;j<32;j++) | 
| ee12b079 | 322:7d906d34aaff | 33 | { | 
| ee12b079 | 322:7d906d34aaff | 34 | read[j] = nativeflash[j]; | 
| chaithanyarss | 257:7d404e9dc9e2 | 35 | } | 
| ee12b079 | 322:7d906d34aaff | 36 | } | 
| ee12b079 | 322:7d906d34aaff | 37 | EPS_V_A_EN_STATUS = read[0]; | 
| ee12b079 | 322:7d906d34aaff | 38 | BAE_STATUS = read[1]; | 
| ee12b079 | 322:7d906d34aaff | 39 | SD_STATUS = read[2]; | 
| ee12b079 | 322:7d906d34aaff | 40 | PL_STATUS = read[3]; | 
| ee12b079 | 322:7d906d34aaff | 41 | PL_EPS_LATCH_SW_EN = read[4]; | 
| ee12b079 | 322:7d906d34aaff | 42 | RTC_INIT_STATUS = read[5]; | 
| ee12b079 | 322:7d906d34aaff | 43 | CDMS_RTC_DISABLE = read[6]; | 
| ee12b079 | 322:7d906d34aaff | 44 | CDMS_RESET_COUNTER = read[7]; | 
| ee12b079 | 322:7d906d34aaff | 45 | TIME_LATEST_CDSMS_RESET = read[8]; | 
| ee12b079 | 322:7d906d34aaff | 46 | COM_TC_BYTES_LIMIT = read[9]; | 
| ee12b079 | 322:7d906d34aaff | 47 | COM_RX_CURRENT_MAX = read[10]; | 
| ee12b079 | 322:7d906d34aaff | 48 | COM_RX_DISABLE_TIMEOUT = read[11]; | 
| ee12b079 | 322:7d906d34aaff | 49 | COM_PA_TMP_HIGH = read[12]; | 
| ee12b079 | 322:7d906d34aaff | 50 | COM_PA_RECOVERY_TIMEOUT = read[13]; | 
| ee12b079 | 322:7d906d34aaff | 51 | COM_SESSION_TIMEOUT = read[14]; | 
| ee12b079 | 322:7d906d34aaff | 52 | COM_RSSI_MIN = read[15]; | 
| ee12b079 | 322:7d906d34aaff | 53 | SD_LIB_BLK_CURRENT = read[16]; | 
| chaithanyarss | 324:c0a5228cc666 | 54 | CDMS_RESET_COUNTER = read[17]; | 
| chaithanyarss | 257:7d404e9dc9e2 | 55 | } | 
| aniruddhv | 52:0bd68655c651 | 56 | |
| aniruddhv | 52:0bd68655c651 | 57 | /*Writing to the Flash*/ | 
| chaithanyarss | 257:7d404e9dc9e2 | 58 | 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 | 59 | { | 
| chaithanyarss | 261:1e54415b34d3 | 60 | for(int i=0;i<17;i++) | 
| aniruddhv | 52:0bd68655c651 | 61 | { | 
| aniruddhv | 52:0bd68655c651 | 62 | flasharray[i]=nativeflash[i]; | 
| aniruddhv | 52:0bd68655c651 | 63 | } | 
| chaithanyarss | 257:7d404e9dc9e2 | 64 | flasharray[j]=datablock; | 
| aniruddhv | 52:0bd68655c651 | 65 | erase_sector(strt_add); | 
| chaithanyarss | 257:7d404e9dc9e2 | 66 | program_flash(strt_add, (char*)flasharray,32); | 
| aniruddhv | 52:0bd68655c651 | 67 | } | 
| aniruddhv | 52:0bd68655c651 | 68 | /*End*/ | 
| aniruddhv | 52:0bd68655c651 | 69 | |
| chaithanyarss | 257:7d404e9dc9e2 | 70 | /*===================================================MMS Functions=================================================*/ | 
| chaithanyarss | 261:1e54415b34d3 | 71 | |
| chaithanyarss | 261:1e54415b34d3 | 72 | void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock); | 
| chaithanyarss | 261:1e54415b34d3 | 73 | |
| chaithanyarss | 261:1e54415b34d3 | 74 | void FCTN_CDMS_WR_S_FLASH(uint16_t mid,uint32_t datablock) | 
| chaithanyarss | 261:1e54415b34d3 | 75 | { | 
| chaithanyarss | 261:1e54415b34d3 | 76 | if(mid == 0x0100) | 
| chaithanyarss | 261:1e54415b34d3 | 77 | { | 
| chaithanyarss | 261:1e54415b34d3 | 78 | FCTN_CDMS_WR_FLASH(11,(datablock>>16) & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 79 | FCTN_CDMS_WR_FLASH(13,(datablock>>8) & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 80 | FCTN_CDMS_WR_FLASH(14,datablock & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 81 | } | 
| chaithanyarss | 261:1e54415b34d3 | 82 | else if(mid == 0x0101) | 
| chaithanyarss | 261:1e54415b34d3 | 83 | { | 
| chaithanyarss | 261:1e54415b34d3 | 84 | FCTN_CDMS_WR_FLASH(12,(datablock>>16) & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 85 | FCTN_CDMS_WR_FLASH(10,(datablock>>8) & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 86 | FCTN_CDMS_WR_FLASH(15,datablock & 0x000000FF); | 
| chaithanyarss | 261:1e54415b34d3 | 87 | } | 
| chaithanyarss | 261:1e54415b34d3 | 88 | else if(mid == 0x0102) | 
| chaithanyarss | 261:1e54415b34d3 | 89 | { | 
| chaithanyarss | 261:1e54415b34d3 | 90 | FCTN_CDMS_WR_FLASH(9,datablock & 0x0000FFFF); | 
| chaithanyarss | 261:1e54415b34d3 | 91 | } | 
| chaithanyarss | 261:1e54415b34d3 | 92 | else if(mid == 0x0103) | 
| chaithanyarss | 261:1e54415b34d3 | 93 | { | 
| chaithanyarss | 261:1e54415b34d3 | 94 | FCTN_CDMS_WR_FLASH(6,datablock & 0x00000001); | 
| chaithanyarss | 261:1e54415b34d3 | 95 | } | 
| chaithanyarss | 261:1e54415b34d3 | 96 | } | 
