Basic

Dependencies:   MQTT

Revision:
3:cb954c31709f
Parent:
2:e90526c0bcbe
--- a/LPG_FlashIAP/LPG_FlashIAP.cpp	Tue Apr 23 03:42:26 2019 +0000
+++ b/LPG_FlashIAP/LPG_FlashIAP.cpp	Tue Apr 23 05:02:48 2019 +0000
@@ -10,13 +10,16 @@
 
 void LPG_FlashIAP_WriteToFlash(char* buffer, uint32_t addr)
 {
-    int sector = flash.get_page_size();
-    flash.erase(addr,flash.get_sector_size(addr));
+    /* 目前無法erase成功,手動erase後可以寫入 */
+    int sector = flash.get_sector_size(addr);
+    int page = flash.get_page_size();
+    
+    flash.erase(addr,page);
     flash.program(buffer,addr,sector);
     flash.deinit();
 }
 
-void LPG_FlashIAP_ReadFromFlash(char* buffer)
+void LPG_FlashIAP_ReadFromFlash(char* buffer,uint32_t addr)
 {
-    flash.read(buffer,(uint32_t)0x0800BF00/*0x08000010*/,sizeof(uint32_t));
+    flash.read(buffer,addr,sizeof(uint32_t));
 }
\ No newline at end of file