From 834104401f6de85348fc4a1c3f9697eae676d2f0 Mon Sep 17 00:00:00 2001 From: Sergi Hernandez Juan <shernand@iri.upc.edu> Date: Tue, 5 Sep 2017 01:11:10 +0200 Subject: [PATCH] Solved a problem with the EEPROM leveleing algorithm. --- src/eeprom.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/eeprom.c b/src/eeprom.c index ad139df..fd7d1f0 100755 --- a/src/eeprom.c +++ b/src/eeprom.c @@ -773,7 +773,7 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) HAL_StatusTypeDef flashstatus = HAL_OK; uint32_t newpageaddress = EEPROM_START_ADDRESS; uint32_t oldpageid = 0; - uint16_t validpage = PAGE0, varidx = 0; + uint16_t validpage = PAGE0, varidx = 0, address=0; uint16_t eepromstatus = 0, readstatus = 0; uint32_t page_error = 0; FLASH_EraseInitTypeDef s_eraseinit; @@ -821,15 +821,16 @@ static uint16_t EE_PageTransfer(uint16_t VirtAddress, uint16_t Data) /* Transfer process: transfer variables from old to the new active page */ for (varidx = 0; varidx < NB_OF_VAR; varidx++) { - if (eeprom_data[varidx] != VirtAddress) /* Check each variable except the one passed as parameter */ + address=((__IO uint16_t*)oldpageid)[1+varidx*2]; + if (address != VirtAddress) /* Check each variable except the one passed as parameter */ { /* Read the other last variable updates */ - readstatus = EE_ReadVariable(eeprom_data[varidx], &DataVar); + readstatus = EE_ReadVariable(address, &DataVar); /* In case variable corresponding to the virtual address was found */ if (readstatus != 0x1) { /* Transfer the variable to the new active page */ - eepromstatus = EE_VerifyPageFullWriteVariable(eeprom_data[varidx], DataVar); + eepromstatus = EE_VerifyPageFullWriteVariable(address, DataVar); /* If program operation was failed, a Flash error code is returned */ if (eepromstatus != HAL_OK) { -- GitLab