Followup persistent store with heading, const
This commit is contained in:
@ -55,7 +55,7 @@ bool PersistentStore::access_finish() {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
|
||||
FLASH_Status status;
|
||||
|
||||
if (firstWrite) {
|
||||
@ -90,7 +90,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
for (uint16_t i = 0; i < size; i++) {
|
||||
byte* accessPoint = (byte*)(pageBase + pos + i);
|
||||
uint8_t c = *accessPoint;
|
||||
@ -101,22 +101,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
|
||||
int data_pos = pos;
|
||||
uint16_t crc = 0;
|
||||
return write_data(data_pos, value, size, &crc);
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
|
||||
int data_pos = pos;
|
||||
uint16_t crc = 0;
|
||||
return read_data(data_pos, value, size, &crc);
|
||||
}
|
||||
|
||||
const size_t PersistentStore::capacity() {
|
||||
return E2END + 1;
|
||||
}
|
||||
|
||||
const size_t PersistentStore::capacity() { return E2END + 1; }
|
||||
|
||||
#endif // EEPROM_SETTINGS && EEPROM FLASH
|
||||
#endif // __STM32F1__
|
||||
|
@ -60,7 +60,7 @@ bool PersistentStore::access_finish() {
|
||||
return (bytes_written == HAL_STM32F1_EEPROM_SIZE);
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, const size_t size, uint16_t *crc) {
|
||||
for (int i = 0; i < size; i++)
|
||||
HAL_STM32F1_eeprom_content[pos + i] = value[i];
|
||||
crc16(crc, value, size);
|
||||
@ -68,7 +68,7 @@ bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, ui
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, const size_t size, uint16_t *crc, const bool writing/*=true*/) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
|
||||
if (writing) value[i] = c;
|
||||
@ -78,21 +78,7 @@ bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t
|
||||
return false;
|
||||
}
|
||||
|
||||
bool PersistentStore::write_data(const int pos, uint8_t* value, size_t size) {
|
||||
int data_pos = pos;
|
||||
uint16_t crc = 0;
|
||||
return write_data(data_pos, value, size, &crc);
|
||||
}
|
||||
|
||||
bool PersistentStore::read_data(const int pos, uint8_t* value, size_t size) {
|
||||
int data_pos = pos;
|
||||
uint16_t crc = 0;
|
||||
return read_data(data_pos, value, size, &crc);
|
||||
}
|
||||
|
||||
const size_t PersistentStore::capacity() {
|
||||
return HAL_STM32F1_EEPROM_SIZE;
|
||||
}
|
||||
const size_t PersistentStore::capacity() { return HAL_STM32F1_EEPROM_SIZE; }
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
|
||||
|
Reference in New Issue
Block a user