From e91a7aa073dd137c373c8ccd72dcc0b57e5cc730 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: Sun, 15 Oct 2017 14:09:29 +0330 Subject: [PATCH] Fix Some Bugs. --- eeprom.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/eeprom.c b/eeprom.c index 6441893..f7aac08 100644 --- a/eeprom.c +++ b/eeprom.c @@ -55,14 +55,11 @@ bool EE_Write(uint16_t VirtualAddress, uint32_t Data) HAL_FLASH_Unlock(); for(uint16_t i=0 ; i<_EEPROM_FLASH_PAGE_SIZE/4 ; i++) { - if(EEPROMPageBackup[i]!=0xFFFFFFFF) + if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,(i*4)+_EEPROM_FLASH_PAGE_ADDRESS,(uint64_t)EEPROMPageBackup[i])==false) { - if(HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,(i*4)+_EEPROM_FLASH_PAGE_ADDRESS,(uint64_t)EEPROMPageBackup[i])==false) - { - HAL_FLASH_Lock(); - return false; - } - } + HAL_FLASH_Lock(); + return false; + } } } HAL_FLASH_Unlock(); @@ -88,7 +85,7 @@ bool EE_Reads(uint16_t StartVirtualAddress,uint16_t HowMuchToRead,uint32_t* Data { if((StartVirtualAddress+HowMuchToRead) > (_EEPROM_FLASH_PAGE_SIZE/4)) return false; - for(uint16_t i=StartVirtualAddress ; i