things are working
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_DEC_2016_jan by
Flash.cpp@0:bcbd76c86cde, 2015-12-16 (annotated)
- Committer:
- cholletisaik777
- Date:
- Wed Dec 16 09:06:59 2015 +0000
- Revision:
- 0:bcbd76c86cde
nnb
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
cholletisaik777 | 0:bcbd76c86cde | 1 | #include "mbed.h" |
cholletisaik777 | 0:bcbd76c86cde | 2 | #include "FreescaleIAP.h" |
cholletisaik777 | 0:bcbd76c86cde | 3 | #include "Flash.h" |
cholletisaik777 | 0:bcbd76c86cde | 4 | |
cholletisaik777 | 0:bcbd76c86cde | 5 | int strt_add = flash_size() - (4*SECTOR_SIZE); |
cholletisaik777 | 0:bcbd76c86cde | 6 | uint32_t flasharray[256+(3*1024)]; |
cholletisaik777 | 0:bcbd76c86cde | 7 | char *nativeflash = (char*)strt_add; |
cholletisaik777 | 0:bcbd76c86cde | 8 | |
cholletisaik777 | 0:bcbd76c86cde | 9 | /*Writing to the Flash*/ |
cholletisaik777 | 0:bcbd76c86cde | 10 | void FCTN_CDMS_WR_FLASH(uint16_t j,uint32_t block) |
cholletisaik777 | 0:bcbd76c86cde | 11 | { |
cholletisaik777 | 0:bcbd76c86cde | 12 | for(int64_t i=0;i<(256+(3*1024));i++) |
cholletisaik777 | 0:bcbd76c86cde | 13 | { |
cholletisaik777 | 0:bcbd76c86cde | 14 | flasharray[i]=nativeflash[i]; |
cholletisaik777 | 0:bcbd76c86cde | 15 | } |
cholletisaik777 | 0:bcbd76c86cde | 16 | flasharray[j]=block; |
cholletisaik777 | 0:bcbd76c86cde | 17 | erase_sector(strt_add); |
cholletisaik777 | 0:bcbd76c86cde | 18 | program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3))); |
cholletisaik777 | 0:bcbd76c86cde | 19 | } |
cholletisaik777 | 0:bcbd76c86cde | 20 | /*End*/ |
cholletisaik777 | 0:bcbd76c86cde | 21 | |
cholletisaik777 | 0:bcbd76c86cde | 22 | /*Reading from Flash*/ |
cholletisaik777 | 0:bcbd76c86cde | 23 | uint32_t FCTN_CDMS_RD_FLASH(uint16_t j) |
cholletisaik777 | 0:bcbd76c86cde | 24 | { |
cholletisaik777 | 0:bcbd76c86cde | 25 | for(int64_t i=0;i<(256+(3*1024));i++) |
cholletisaik777 | 0:bcbd76c86cde | 26 | { |
cholletisaik777 | 0:bcbd76c86cde | 27 | flasharray[i]=nativeflash[i]; |
cholletisaik777 | 0:bcbd76c86cde | 28 | } |
cholletisaik777 | 0:bcbd76c86cde | 29 | return flasharray[j]; |
cholletisaik777 | 0:bcbd76c86cde | 30 | } |
cholletisaik777 | 0:bcbd76c86cde | 31 | /*End*/ |