Browse Source

More generic EEPROM data array name

pull/1/head
Scott Lahteine 5 years ago
parent
commit
fd945d1070
  1. 12
      Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp

12
Marlin/src/HAL/HAL_STM32F1/persistent_store_sdcard.cpp

@ -39,7 +39,7 @@
#define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
static char _ALIGN(4) HAL_eeprom_data[HAL_STM32F1_EEPROM_SIZE];
#if ENABLED(SDSUPPORT)
@ -54,10 +54,10 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
return false;
int bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
int bytes_read = file.read(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE);
if (bytes_read < 0) return false;
for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++)
HAL_STM32F1_eeprom_content[bytes_read] = 0xFF;
HAL_eeprom_data[bytes_read] = 0xFF;
file.close();
return true;
}
@ -68,7 +68,7 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
SdFile file, root = card.getroot();
int bytes_written = 0;
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
bytes_written = file.write(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE);
file.close();
}
return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
@ -82,7 +82,7 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
for (size_t i = 0; i < size; i++)
HAL_STM32F1_eeprom_content[pos + i] = value[i];
HAL_eeprom_data[pos + i] = value[i];
crc16(crc, value, size);
pos += size;
return false;
@ -90,7 +90,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t si
bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
for (size_t i = 0; i < size; i++) {
uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
uint8_t c = HAL_eeprom_data[pos + i];
if (writing) value[i] = c;
crc16(crc, &c, 1);
}

Loading…
Cancel
Save