Add MarlinSettings::validate()

This commit is contained in:
Scott Lahteine
2018-01-04 19:51:18 -06:00
parent 878f54c27b
commit 51e0f2bee3
12 changed files with 192 additions and 138 deletions

View File

@ -93,13 +93,13 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
return true;
}
void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
void read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
for (uint16_t i = 0; i < size; i++) {
byte* accessPoint = (byte*)(pageBase + pos + i);
value[i] = *accessPoint;
uint8_t c = *accessPoint;
if (writing) value[i] = c;
crc16(crc, &c, 1);
}
crc16(crc, value, size);
pos += ((size + 1) & ~1);
}

View File

@ -62,7 +62,6 @@ bool access_start() {
return true;
}
bool access_finish(){
if (!card.cardOK) return false;
int16_t bytes_written = 0;
@ -81,11 +80,12 @@ 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 read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc, const bool writing/*=true*/) {
for (int i = 0; i < size; i++) {
value[i] = HAL_STM32F1_eeprom_content [pos + i];
uint8_t c = HAL_STM32F1_eeprom_content[pos + i];
if (writing) value[i] = c`;
crc16(crc, &c, 1);
}
crc16(crc, value, size);
pos += size;
return false;
}