Update PersistentStore api (#11538)
- Clean up the API to use a `static` class instance to adhere to Marlin convention - Add `const` position data access for read/write - Add Storage capacity to the interface
This commit is contained in:
committed by
Scott Lahteine
parent
60f1376798
commit
66d2b48b59
@ -24,19 +24,16 @@
|
||||
|
||||
#ifdef STM32F7
|
||||
|
||||
#include "../persistent_store_api.h"
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
|
||||
namespace HAL {
|
||||
namespace PersistentStore {
|
||||
#include "../persistent_store_api.h"
|
||||
|
||||
bool access_start() { return true; }
|
||||
bool access_finish() { return true; }
|
||||
bool PersistentStore::access_start() { return true; }
|
||||
bool PersistentStore::access_finish() { return true; }
|
||||
|
||||
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||
bool PersistentStore::write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc) {
|
||||
while (size--) {
|
||||
uint8_t * const p = (uint8_t * const)pos;
|
||||
uint8_t v = *value;
|
||||
@ -57,7 +54,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
|
||||
bool PersistentStore::read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc) {
|
||||
do {
|
||||
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
||||
*value = c;
|
||||
@ -68,10 +65,21 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
|
||||
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;
|
||||
}
|
||||
|
||||
#endif // EEPROM_SETTINGS
|
||||
#endif // STM32F7
|
||||
|
||||
|
Reference in New Issue
Block a user