CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Committer:
chaithanyarss
Date:
Mon Jul 11 14:33:02 2016 +0000
Revision:
255:642ea552ac77
Parent:
52:0bd68655c651
Integration and Testing is in progress

Who changed what in which revision?

UserRevisionLine numberNew contents of line
aniruddhv 52:0bd68655c651 1 #include "FreescaleIAP.h"
aniruddhv 52:0bd68655c651 2
aniruddhv 52:0bd68655c651 3 int strt_add = flash_size() - (4*SECTOR_SIZE);
aniruddhv 52:0bd68655c651 4 uint32_t flasharray[256+(3*1024)];
aniruddhv 52:0bd68655c651 5 char *nativeflash = (char*)strt_add;
aniruddhv 52:0bd68655c651 6
aniruddhv 52:0bd68655c651 7 /*Writing to the Flash*/
aniruddhv 52:0bd68655c651 8 void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t block)
aniruddhv 52:0bd68655c651 9 {
aniruddhv 52:0bd68655c651 10 for(int64_t i=0;i<(256+(3*1024));i++)
aniruddhv 52:0bd68655c651 11 {
aniruddhv 52:0bd68655c651 12 flasharray[i]=nativeflash[i];
aniruddhv 52:0bd68655c651 13 }
aniruddhv 52:0bd68655c651 14 flasharray[j]=block;
aniruddhv 52:0bd68655c651 15 erase_sector(strt_add);
aniruddhv 52:0bd68655c651 16 program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3)));
aniruddhv 52:0bd68655c651 17 }
aniruddhv 52:0bd68655c651 18 /*End*/
aniruddhv 52:0bd68655c651 19
aniruddhv 52:0bd68655c651 20 /*Reading from Flash*/
aniruddhv 52:0bd68655c651 21 uint32_t FCTN_CDMS_RD_FLASH(uint16_t j)
aniruddhv 52:0bd68655c651 22 {
aniruddhv 52:0bd68655c651 23 for(int64_t i=0;i<(256+(3*1024));i++)
aniruddhv 52:0bd68655c651 24 {
aniruddhv 52:0bd68655c651 25 flasharray[i]=nativeflash[i];
aniruddhv 52:0bd68655c651 26 }
aniruddhv 52:0bd68655c651 27 return flasharray[j];
chaithanyarss 255:642ea552ac77 28 }
chaithanyarss 255:642ea552ac77 29
chaithanyarss 255:642ea552ac77 30 /*===================================================MMS Functions=================================================*/
chaithanyarss 255:642ea552ac77 31
chaithanyarss 255:642ea552ac77 32 void WRITE_TO_FLASH(uint8_t *);
chaithanyarss 255:642ea552ac77 33
chaithanyarss 255:642ea552ac77 34 void WRITE_TO_FLASH(uint8_t *flash)
chaithanyarss 255:642ea552ac77 35 {
chaithanyarss 255:642ea552ac77 36 uint32_t FLASH[5];
chaithanyarss 255:642ea552ac77 37 FLASH[0] = ((uint32_t)flash[0] << 24) | ((uint32_t)flash[1] << 16) | ((uint32_t)flash[2] << 8) | ((uint32_t)flash[3]);
chaithanyarss 255:642ea552ac77 38 FLASH[1] = ((uint32_t)flash[4] << 24) | ((uint32_t)flash[5] << 16) | ((uint32_t)flash[6] << 8) | ((uint32_t)flash[7]);
chaithanyarss 255:642ea552ac77 39 FLASH[2] = ((uint32_t)flash[8] << 24) | ((uint32_t)flash[9] << 16) | ((uint32_t)flash[10] << 8) | ((uint32_t)flash[11]);
chaithanyarss 255:642ea552ac77 40 FLASH[3] = ((uint32_t)flash[12] << 24) | ((uint32_t)flash[13] << 16) | ((uint32_t)flash[14] << 8) | ((uint32_t)flash[15]);
chaithanyarss 255:642ea552ac77 41 FLASH[4] = ((uint32_t)flash[16] << 24) | ((uint32_t)flash[17] << 16) | ((uint32_t)flash[18] << 8) | ((uint32_t)flash[19]);
chaithanyarss 255:642ea552ac77 42 erase_sector(strt_add);
chaithanyarss 255:642ea552ac77 43 program_flash(strt_add, (char*)FLASH,160);
chaithanyarss 255:642ea552ac77 44 }