Wen-ting Lo
/
STM32F303RE_LPG
Basic
LPG_FlashIAP/LPG_FlashIAP.cpp@2:e90526c0bcbe, 2019-04-23 (annotated)
- Committer:
- lwtroach
- Date:
- Tue Apr 23 03:42:26 2019 +0000
- Revision:
- 2:e90526c0bcbe
- Child:
- 3:cb954c31709f
Flash readable
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lwtroach | 2:e90526c0bcbe | 1 | #include "LPG_FlashIAP.h" |
lwtroach | 2:e90526c0bcbe | 2 | |
lwtroach | 2:e90526c0bcbe | 3 | FlashIAP flash; |
lwtroach | 2:e90526c0bcbe | 4 | |
lwtroach | 2:e90526c0bcbe | 5 | void LPG_FlashIAP_InitIAP() |
lwtroach | 2:e90526c0bcbe | 6 | { |
lwtroach | 2:e90526c0bcbe | 7 | flash.init(); |
lwtroach | 2:e90526c0bcbe | 8 | } |
lwtroach | 2:e90526c0bcbe | 9 | |
lwtroach | 2:e90526c0bcbe | 10 | |
lwtroach | 2:e90526c0bcbe | 11 | void LPG_FlashIAP_WriteToFlash(char* buffer, uint32_t addr) |
lwtroach | 2:e90526c0bcbe | 12 | { |
lwtroach | 2:e90526c0bcbe | 13 | int sector = flash.get_page_size(); |
lwtroach | 2:e90526c0bcbe | 14 | flash.erase(addr,flash.get_sector_size(addr)); |
lwtroach | 2:e90526c0bcbe | 15 | flash.program(buffer,addr,sector); |
lwtroach | 2:e90526c0bcbe | 16 | flash.deinit(); |
lwtroach | 2:e90526c0bcbe | 17 | } |
lwtroach | 2:e90526c0bcbe | 18 | |
lwtroach | 2:e90526c0bcbe | 19 | void LPG_FlashIAP_ReadFromFlash(char* buffer) |
lwtroach | 2:e90526c0bcbe | 20 | { |
lwtroach | 2:e90526c0bcbe | 21 | flash.read(buffer,(uint32_t)0x0800BF00/*0x08000010*/,sizeof(uint32_t)); |
lwtroach | 2:e90526c0bcbe | 22 | } |