|
@@ -39,7 +39,7 @@
|
39
|
39
|
#define HAL_STM32F1_EEPROM_SIZE (E2END + 1)
|
40
|
40
|
|
41
|
41
|
#define _ALIGN(x) __attribute__ ((aligned(x))) // SDIO uint32_t* compat.
|
42
|
|
-static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
|
42
|
+static char _ALIGN(4) HAL_eeprom_data[HAL_STM32F1_EEPROM_SIZE];
|
43
|
43
|
|
44
|
44
|
#if ENABLED(SDSUPPORT)
|
45
|
45
|
|
|
@@ -54,10 +54,10 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
54
|
54
|
if (!file.open(&root, EEPROM_FILENAME, O_RDONLY))
|
55
|
55
|
return false;
|
56
|
56
|
|
57
|
|
- int bytes_read = file.read(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
|
57
|
+ int bytes_read = file.read(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE);
|
58
|
58
|
if (bytes_read < 0) return false;
|
59
|
59
|
for (; bytes_read < HAL_STM32F1_EEPROM_SIZE; bytes_read++)
|
60
|
|
- HAL_STM32F1_eeprom_content[bytes_read] = 0xFF;
|
|
60
|
+ HAL_eeprom_data[bytes_read] = 0xFF;
|
61
|
61
|
file.close();
|
62
|
62
|
return true;
|
63
|
63
|
}
|
|
@@ -68,7 +68,7 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
68
|
68
|
SdFile file, root = card.getroot();
|
69
|
69
|
int bytes_written = 0;
|
70
|
70
|
if (file.open(&root, EEPROM_FILENAME, O_CREAT | O_WRITE | O_TRUNC)) {
|
71
|
|
- bytes_written = file.write(HAL_STM32F1_eeprom_content, HAL_STM32F1_EEPROM_SIZE);
|
|
71
|
+ bytes_written = file.write(HAL_eeprom_data, HAL_STM32F1_EEPROM_SIZE);
|
72
|
72
|
file.close();
|
73
|
73
|
}
|
74
|
74
|
return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
|
|
@@ -82,7 +82,7 @@ static char _ALIGN(4) HAL_STM32F1_eeprom_content[HAL_STM32F1_EEPROM_SIZE];
|
82
|
82
|
|
83
|
83
|
bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
|
84
|
84
|
for (size_t i = 0; i < size; i++)
|
85
|
|
- HAL_STM32F1_eeprom_content[pos + i] = value[i];
|
|
85
|
+ HAL_eeprom_data[pos + i] = value[i];
|
86
|
86
|
crc16(crc, value, size);
|
87
|
87
|
pos += size;
|
88
|
88
|
return false;
|
|
@@ -90,7 +90,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t si
|
90
|
90
|
|
91
|
91
|
bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
92
|
92
|
for (size_t i = 0; i < size; i++) {
|
93
|
|
- uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
|
|
93
|
+ uint8_t c = HAL_eeprom_data[pos + i];
|
94
|
94
|
if (writing) value[i] = c;
|
95
|
95
|
crc16(crc, &c, 1);
|
96
|
96
|
}
|