vr1.1
Dependencies: FreescaleIAP mbed-rtos mbed
Fork of CDMS_RTOS_v1_1 by
Flash.cpp@10:2c8b9ebc79e9, 2015-07-04 (annotated)
- Committer:
- pradeepvk2208
- Date:
- Sat Jul 04 10:48:18 2015 +0000
- Revision:
- 10:2c8b9ebc79e9
- Parent:
- 8:607ae92fa6af
- Child:
- 11:d6dc9074075b
added flash code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
pradeepvk2208 | 10:2c8b9ebc79e9 | 1 | #include "mbed.h" |
pradeepvk2208 | 10:2c8b9ebc79e9 | 2 | #include "FreescaleIAP.h" |
pradeepvk2208 | 10:2c8b9ebc79e9 | 3 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 4 | //--------------------------------------in bae init : |
pradeepvk2208 | 10:2c8b9ebc79e9 | 5 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 6 | int strt_add = flash_size() - (4*SECTOR_SIZE); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 7 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 8 | uint32_t flasharray[256+(3*1024)]; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 9 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 10 | char *nativeflash = (char*)strt_add; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 11 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 12 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 13 | //--------------------------WRITING AND READING FLASH--------------------------------------------------------------------------------// |
pradeepvk2208 | 10:2c8b9ebc79e9 | 14 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 15 | void P_BAE_WRFLASH() |
pradeepvk2208 | 10:2c8b9ebc79e9 | 16 | { |
pradeepvk2208 | 10:2c8b9ebc79e9 | 17 | erase_sector(strt_add); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 18 | program_flash(strt_add, (char*)&flasharray,4*(256+(1024*3))); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 19 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 20 | } |
pradeepvk2208 | 10:2c8b9ebc79e9 | 21 | void P_BAE_RDFLASH() |
pradeepvk2208 | 10:2c8b9ebc79e9 | 22 | { |
pradeepvk2208 | 10:2c8b9ebc79e9 | 23 | for(int64_t i=0;i<(256+(3*1024));i++)flasharray[i]=nativeflash[i]; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 24 | } |
pradeepvk2208 | 10:2c8b9ebc79e9 | 25 | int P_CDMS_WRITEBLOCK(int i,uint32_t block) |
pradeepvk2208 | 10:2c8b9ebc79e9 | 26 | { P_BAE_RDFLASH(); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 27 | flasharray[i]=block; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 28 | P_BAE_WRFLASH(); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 29 | return 0; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 30 | } |
pradeepvk2208 | 10:2c8b9ebc79e9 | 31 | |
pradeepvk2208 | 10:2c8b9ebc79e9 | 32 | uint32_t P_CDMS_READBLOCK(int i) |
pradeepvk2208 | 10:2c8b9ebc79e9 | 33 | { P_BAE_RDFLASH(); |
pradeepvk2208 | 10:2c8b9ebc79e9 | 34 | return flasharray[i]; |
pradeepvk2208 | 10:2c8b9ebc79e9 | 35 | } |