HAL_STM32F1_EEPROM_SIZE => HAL_EEPROM_SIZE

This commit is contained in:
Scott Lahteine 2019-08-02 05:36:00 -05:00
parent ee5e46b46b
commit e1942715ce

View file

@ -36,10 +36,10 @@
#ifndef E2END #ifndef E2END
#define E2END 0xFFF // 4KB #define E2END 0xFFF // 4KB
#endif #endif
#define HAL_STM32F1_EEPROM_SIZE (E2END + 1) #define HAL_EEPROM_SIZE (E2END + 1)
#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat. #define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
static char _ALIGN(4) HAL_eeprom_data[HAL_STM32F1_EEPROM_SIZE]; static char _ALIGN(4) HAL_eeprom_data[HAL_EEPROM_SIZE];
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
@ -54,9 +54,9 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_STM32F1_EEPROM_SIZE];
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY)) if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
return false; return false;
int bytes_read = file.read(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE); int bytes_read = file.read(HAL_eeprom_data, HAL_EEPROM_SIZE);
if (bytes_read < 0) return false; if (bytes_read < 0) return false;
for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++) for (; bytes_read < HAL_EEPROM_SIZE; bytes_read++)
HAL_eeprom_data[bytes_read] = 0xFF; HAL_eeprom_data[bytes_read] = 0xFF;
file.close(); file.close();
return true; return true;
@ -68,10 +68,10 @@ static char _ALIGN(4) HAL_eeprom_data[HAL_STM32F1_EEPROM_SIZE];
SdFile file, root = card.getroot(); SdFile file, root = card.getroot();
int bytes_written = 0; int bytes_written = 0;
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) { if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
bytes_written = file.write(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE); bytes_written = file.write(HAL_eeprom_data, HAL_EEPROM_SIZE);
file.close(); file.close();
} }
return (bytes_written == HAL_STM32F1_EEPROM_SIZE); return (bytes_written == HAL_EEPROM_SIZE);
} }
#else // !SDSUPPORT #else // !SDSUPPORT
@ -98,7 +98,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uin
return false; return false;
} }
size_t PersistentStore::capacity() { return HAL_STM32F1_EEPROM_SIZE; } size_t PersistentStore::capacity() { return HAL_EEPROM_SIZE; }
#endif // EEPROM_SETTINGS #endif // EEPROM_SETTINGS