Ender 3 V2 BL24C16 EEPROM support (#18758)

This commit is contained in:
Scott Lahteine
2020-07-24 03:09:14 -05:00
committed by GitHub
parent 8c88c33d9f
commit 451f48231d
15 changed files with 498 additions and 306 deletions

View File

@@ -29,20 +29,38 @@
class PersistentStore {
public:
static bool access_start();
static bool access_finish();
static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc);
static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true);
// Total available persistent storage space (in bytes)
static size_t capacity();
// Prepare to read or write
static bool access_start();
// Housecleaning after read or write
static bool access_finish();
// Write one or more bytes of data and update the CRC
// Return 'true' on write error
static bool write_data(int &pos, const uint8_t *value, size_t size, uint16_t *crc);
// Read one or more bytes of data and update the CRC
// Return 'true' on read error
static bool read_data(int &pos, uint8_t* value, size_t size, uint16_t *crc, const bool writing=true);
// Write one or more bytes of data
// Return 'true' on write error
static inline bool write_data(const int pos, const uint8_t* value, const size_t size=sizeof(uint8_t)) {
int data_pos = pos;
uint16_t crc = 0;
return write_data(data_pos, value, size, &crc);
}
// Write a single byte of data
// Return 'true' on write error
static inline bool write_data(const int pos, const uint8_t value) { return write_data(pos, &value); }
// Read one or more bytes of data
// Return 'true' on read error
static inline bool read_data(const int pos, uint8_t* value, const size_t size=1) {
int data_pos = pos;
uint16_t crc = 0;