
CDMS code for testing sbc
Dependencies: FreescaleIAP SimpleDMA mbed-rtos mbed
Fork of CDMS_CODE by
Flash.h@218:c63cdba0550f, 2016-07-03 (annotated)
- Committer:
- chaithanyarss
- Date:
- Sun Jul 03 15:25:24 2016 +0000
- Revision:
- 218:c63cdba0550f
- Parent:
- 216:570251b23c7b
Flash Completed;
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 | 218:c63cdba0550f | 3 | int strt_add = flash_size() - SECTOR_SIZE; // Using the last sector of flash memory |
aniruddhv | 52:0bd68655c651 | 4 | char *nativeflash = (char*)strt_add; |
aniruddhv | 52:0bd68655c651 | 5 | |
chaithanyarss | 218:c63cdba0550f | 6 | void FCTN_CDMS_WR_FLASH(uint16_t ,uint32_t ); |
chaithanyarss | 218:c63cdba0550f | 7 | uint32_t* FCTN_CDMS_RD_FLASH(); |
chaithanyarss | 218:c63cdba0550f | 8 | uint32_t flasharray[5]; |
chaithanyarss | 218:c63cdba0550f | 9 | |
chaithanyarss | 218:c63cdba0550f | 10 | uint32_t INITIAL_FLASH_VALUES[5] = {0}; |
chaithanyarss | 218:c63cdba0550f | 11 | |
chaithanyarss | 216:570251b23c7b | 12 | void FLASH_INIT() |
chaithanyarss | 216:570251b23c7b | 13 | { |
chaithanyarss | 218:c63cdba0550f | 14 | uint32_t read[5]; |
chaithanyarss | 218:c63cdba0550f | 15 | for(int i=0;i<5;i++) |
chaithanyarss | 216:570251b23c7b | 16 | { |
chaithanyarss | 218:c63cdba0550f | 17 | read[i] = nativeflash[i]; |
chaithanyarss | 216:570251b23c7b | 18 | } |
chaithanyarss | 216:570251b23c7b | 19 | |
chaithanyarss | 216:570251b23c7b | 20 | if(read[0] == -1) |
chaithanyarss | 218:c63cdba0550f | 21 | for(int j=0;j<5;j++) |
chaithanyarss | 216:570251b23c7b | 22 | { |
chaithanyarss | 218:c63cdba0550f | 23 | FCTN_CDMS_WR_FLASH(j,INITIAL_FLASH_VALUES[j]); |
chaithanyarss | 216:570251b23c7b | 24 | } |
chaithanyarss | 216:570251b23c7b | 25 | else |
chaithanyarss | 216:570251b23c7b | 26 | { |
chaithanyarss | 218:c63cdba0550f | 27 | for(int j=0;j<5;j++) |
chaithanyarss | 218:c63cdba0550f | 28 | read[j] = nativeflash[j]; |
chaithanyarss | 216:570251b23c7b | 29 | |
chaithanyarss | 218:c63cdba0550f | 30 | EPS_V_A_EN_STATUS = read[0]&0x00000001; |
chaithanyarss | 218:c63cdba0550f | 31 | BAE_SW_STATUS = read[0]&0x00000006; |
chaithanyarss | 218:c63cdba0550f | 32 | CDMS_SD_SW_STATUS = read[0]&0x00000018; |
chaithanyarss | 218:c63cdba0550f | 33 | PL_BEE_SW_STATUS = read[0]&0x00000060; |
chaithanyarss | 218:c63cdba0550f | 34 | PL_EPS_LATCH_SW_EN = read[0]&0x00000080; |
chaithanyarss | 218:c63cdba0550f | 35 | RTC_INIT_STATUS = read[0]&0x00000300; |
chaithanyarss | 218:c63cdba0550f | 36 | CDMS_RTC_DISABLE = read[0]&0x00000400; |
chaithanyarss | 218:c63cdba0550f | 37 | CDMS_RESET_COUNTER = read[0]&0xFFFF0000; |
chaithanyarss | 218:c63cdba0550f | 38 | TIME_LATEST_CDSMS_RESET = read[1]&0xFFFFFFFF; |
chaithanyarss | 218:c63cdba0550f | 39 | COM_TC_BYTES_LIMIT = read[2]&0x0000FFFF; |
chaithanyarss | 218:c63cdba0550f | 40 | COM_RX_CURRENT_MAX = read[2]&0x00FF0000; |
chaithanyarss | 218:c63cdba0550f | 41 | COM_RX_DISABLE_TIMEOUT = read[2]&0xFF000000; |
chaithanyarss | 218:c63cdba0550f | 42 | COM_PA_TMP_HIGH = read[3]&0x000000FF; |
chaithanyarss | 218:c63cdba0550f | 43 | COM_PA_RECOVERY_TIMEOUT = read[3]&0x0000FF00; |
chaithanyarss | 218:c63cdba0550f | 44 | COM_SESSION_TIMEOUT = read[3]&0x00FF0000; |
chaithanyarss | 218:c63cdba0550f | 45 | COM_RSSI_MIN = read[3]&0xFF000000; |
chaithanyarss | 218:c63cdba0550f | 46 | SD_LIB_BLK_CURRENT_NMBR = read[4]&0x0000FFFF; |
chaithanyarss | 216:570251b23c7b | 47 | } |
chaithanyarss | 216:570251b23c7b | 48 | } |
chaithanyarss | 216:570251b23c7b | 49 | |
chaithanyarss | 218:c63cdba0550f | 50 | void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t data) // Function to write into flash |
aniruddhv | 52:0bd68655c651 | 51 | { |
chaithanyarss | 218:c63cdba0550f | 52 | for(int64_t i=0;i<5;i++) |
aniruddhv | 52:0bd68655c651 | 53 | { |
aniruddhv | 52:0bd68655c651 | 54 | flasharray[i]=nativeflash[i]; |
aniruddhv | 52:0bd68655c651 | 55 | } |
chaithanyarss | 218:c63cdba0550f | 56 | flasharray[j]=data; |
aniruddhv | 52:0bd68655c651 | 57 | erase_sector(strt_add); |
chaithanyarss | 218:c63cdba0550f | 58 | program_flash(strt_add, (char*)flasharray,32); |
aniruddhv | 52:0bd68655c651 | 59 | } |
aniruddhv | 52:0bd68655c651 | 60 | |
chaithanyarss | 218:c63cdba0550f | 61 | uint32_t* FCTN_CDMS_RD_FLASH() // Function to read from flash |
aniruddhv | 52:0bd68655c651 | 62 | { |
chaithanyarss | 218:c63cdba0550f | 63 | for(int64_t i=0;i<5;i++) |
aniruddhv | 52:0bd68655c651 | 64 | flasharray[i]=nativeflash[i]; |
chaithanyarss | 218:c63cdba0550f | 65 | |
chaithanyarss | 218:c63cdba0550f | 66 | return flasharray; |
aniruddhv | 52:0bd68655c651 | 67 | } |