From 3dbe1f60654a6ef357c4081e806a66e50b219ca6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nima=20Askari=20-----=20=D9=86=DB=8C=D9=85=D8=A7=20=D8=B9?= =?UTF-8?q?=D8=B3=DA=A9=D8=B1=DB=8C?= Date: Tue, 19 Feb 2019 13:18:02 +0330 Subject: [PATCH] Add files via upload --- eeprom.c | 21 +++++++++++++++++++-- eepromConfig.h | 1 + 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/eeprom.c b/eeprom.c index bbe0980..407c1f9 100644 --- a/eeprom.c +++ b/eeprom.c @@ -44,7 +44,9 @@ #endif #endif +#if (_EEPROM_AUTO_ERASE___NEED_MORE_RAM==1) uint32_t EEPROMPageBackup[_EEPROM_FLASH_PAGE_SIZE/4]; +#endif //########################################################################################################## //########################################################################################################## @@ -85,6 +87,7 @@ bool EE_Write(uint16_t VirtualAddress, uint32_t Data) if(VirtualAddress >= (_EEPROM_FLASH_PAGE_SIZE/4)) return false; + #if (_EEPROM_AUTO_ERASE___NEED_MORE_RAM==1) if((*(__IO uint32_t*)((VirtualAddress*4)+_EEPROM_FLASH_PAGE_ADDRESS)) != 0xFFFFFFFF) { @@ -106,6 +109,7 @@ bool EE_Write(uint16_t VirtualAddress, uint32_t Data) } } } + #endif HAL_FLASH_Unlock(); if(Data!=0xFFFFFFFF) { @@ -122,7 +126,6 @@ bool EE_Write(uint16_t VirtualAddress, uint32_t Data) } HAL_FLASH_Lock(); return true; - } //########################################################################################################## bool EE_Reads(uint16_t StartVirtualAddress,uint16_t HowMuchToRead,uint32_t* Data) @@ -141,6 +144,7 @@ bool EE_Writes(uint16_t StartVirtualAddress,uint16_t HowMuchToWrite,uint32_t* D { if((StartVirtualAddress+HowMuchToWrite) > (_EEPROM_FLASH_PAGE_SIZE/4)) return false; + #if (_EEPROM_AUTO_ERASE___NEED_MORE_RAM==1) if( EE_Reads(0,(_EEPROM_FLASH_PAGE_SIZE/4),EEPROMPageBackup)==false) return false; for(uint16_t i=StartVirtualAddress ; i