From 94931c49fc22cf99237d0d92ff8e261ad78a3310 Mon Sep 17 00:00:00 2001
From: Sergi Hernandez Juan <shernand@iri.upc.edu>
Date: Tue, 7 Jan 2020 22:45:58 +0100
Subject: [PATCH] Solved a bug in the EEPROM module.

---
 Makefile     |  4 ++--
 src/eeprom.c | 43 ++++++++++++++++++++++++++++++++-----------
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index d9f8ca6..79a4b64 100755
--- a/Makefile
+++ b/Makefile
@@ -1,8 +1,8 @@
 # setup
 # modified by zerom for WinARM 8/2010
 
-STM32_HAL_PATH=$(HOME)/humanoids/stm32_hal
-STM32_LIBRARIES_PATH=$(HOME)/humanoids/stm32_libraries
+STM32_HAL_PATH=$(HOME)/humanoides/tools/stm32_hal
+STM32_LIBRARIES_PATH=$(HOME)/humanoides/tools/stm32_libraries
 
 PROJECT_NAME=darwin_firmware
 #TARGET_FILES=$(wildcard src/*.c)
diff --git a/src/eeprom.c b/src/eeprom.c
index ca45c91..3edde16 100755
--- a/src/eeprom.c
+++ b/src/eeprom.c
@@ -331,22 +331,43 @@ uint16_t EE_VerifyPageFullyErased(uint32_t Address)
   uint16_t addressvalue = 0x5555;
     
   /* Check each active page address starting from end */
-  while (Address <= PAGE0_END_ADDRESS)
+  if(Address==PAGE0_BASE_ADDRESS)
   {
-    /* Get the current location content to be compared with virtual address */
-    addressvalue = (*(__IO uint16_t*)Address);
+    while (Address <= PAGE0_END_ADDRESS)
+    {
+      /* Get the current location content to be compared with virtual address */
+      addressvalue = (*(__IO uint16_t*)Address);
 
-    /* Compare the read address with the virtual address */
-    if (addressvalue != ERASED)
+      /* Compare the read address with the virtual address */
+      if (addressvalue != ERASED)
+      {
+        /* In case variable value is read, reset readstatus flag */
+        readstatus = 0;
+
+        break;
+      }
+      /* Next address location */
+      Address = Address + 4;
+    }
+  }
+  else
+  {
+    while (Address <= PAGE1_END_ADDRESS)
     {
-      
-      /* In case variable value is read, reset readstatus flag */
-      readstatus = 0;
+      /* Get the current location content to be compared with virtual address */
+      addressvalue = (*(__IO uint16_t*)Address);
 
-      break;
+      /* Compare the read address with the virtual address */
+      if (addressvalue != ERASED)
+      {
+        /* In case variable value is read, reset readstatus flag */
+        readstatus = 0;
+
+        break;
+      }
+      /* Next address location */
+      Address = Address + 4;
     }
-    /* Next address location */
-    Address = Address + 4;
   }
   
   /* Return readstatus value: (0: Page not erased, 1: Page erased) */
-- 
GitLab