gcode_D EEPROM size, cleanup
Fixes #19920 Co-Authored-By: Orel <37673727+0r31@users.noreply.github.com>
This commit is contained in:
parent
de315c97b1
commit
f8d57370d0
|
@ -54,9 +54,7 @@
|
||||||
size_t total = persistentStore.capacity();
|
size_t total = persistentStore.capacity();
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
const uint8_t value = 0x0;
|
const uint8_t value = 0x0;
|
||||||
while(total--) {
|
while (total--) persistentStore.write_data(pos, &value, 1);
|
||||||
persistentStore.write_data(pos, &value, 1);
|
|
||||||
}
|
|
||||||
persistentStore.access_finish();
|
persistentStore.access_finish();
|
||||||
#else
|
#else
|
||||||
settings.reset();
|
settings.reset();
|
||||||
|
@ -70,7 +68,7 @@
|
||||||
uint8_t *pointer = parser.hex_adr_val('A');
|
uint8_t *pointer = parser.hex_adr_val('A');
|
||||||
uint16_t len = parser.ushortval('C', 1);
|
uint16_t len = parser.ushortval('C', 1);
|
||||||
uintptr_t addr = (uintptr_t)pointer;
|
uintptr_t addr = (uintptr_t)pointer;
|
||||||
NOMORE(addr, (size_t)(SRAM_SIZE - 1));
|
NOMORE(addr, size_t(SRAM_SIZE - 1));
|
||||||
NOMORE(len, SRAM_SIZE - addr);
|
NOMORE(len, SRAM_SIZE - addr);
|
||||||
if (parser.seenval('X')) {
|
if (parser.seenval('X')) {
|
||||||
// Write the hex bytes after the X
|
// Write the hex bytes after the X
|
||||||
|
@ -91,11 +89,8 @@
|
||||||
uint8_t *pointer = parser.hex_adr_val('A');
|
uint8_t *pointer = parser.hex_adr_val('A');
|
||||||
uint16_t len = parser.ushortval('C', 1);
|
uint16_t len = parser.ushortval('C', 1);
|
||||||
uintptr_t addr = (uintptr_t)pointer;
|
uintptr_t addr = (uintptr_t)pointer;
|
||||||
#ifndef MARLIN_EEPROM_SIZE
|
NOMORE(addr, size_t(persistentStore.capacity() - 1));
|
||||||
#define MARLIN_EEPROM_SIZE size_t(E2END + 1)
|
NOMORE(len, persistentStore.capacity() - addr);
|
||||||
#endif
|
|
||||||
NOMORE(addr, (size_t)(MARLIN_EEPROM_SIZE - 1));
|
|
||||||
NOMORE(len, MARLIN_EEPROM_SIZE - addr);
|
|
||||||
if (parser.seenval('X')) {
|
if (parser.seenval('X')) {
|
||||||
uint16_t val = parser.hex_val('X');
|
uint16_t val = parser.hex_val('X');
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
|
@ -111,23 +106,18 @@
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (len--) {
|
|
||||||
// Read bytes from EEPROM
|
// Read bytes from EEPROM
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
persistentStore.access_start();
|
persistentStore.access_start();
|
||||||
uint8_t val;
|
|
||||||
while(len--) {
|
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
if (!persistentStore.read_data(pos, (uint8_t *)&val, sizeof(val))) {
|
uint8_t val;
|
||||||
print_hex_byte(val);
|
while (len--) if (!persistentStore.read_data(pos, &val, 1)) print_hex_byte(val);
|
||||||
}
|
|
||||||
}
|
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
persistentStore.access_finish();
|
persistentStore.access_finish();
|
||||||
#else
|
#else
|
||||||
SERIAL_ECHOLNPGM("NO EEPROM");
|
SERIAL_ECHOLNPGM("NO EEPROM");
|
||||||
|
len = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -156,7 +146,7 @@
|
||||||
uint8_t *pointer = parser.hex_adr_val('A');
|
uint8_t *pointer = parser.hex_adr_val('A');
|
||||||
uint16_t len = parser.ushortval('C', 1);
|
uint16_t len = parser.ushortval('C', 1);
|
||||||
uintptr_t addr = (uintptr_t)pointer;
|
uintptr_t addr = (uintptr_t)pointer;
|
||||||
NOMORE(addr, (size_t)(FLASH_SIZE - 1));
|
NOMORE(addr, size_t(FLASH_SIZE - 1));
|
||||||
NOMORE(len, FLASH_SIZE - addr);
|
NOMORE(len, FLASH_SIZE - addr);
|
||||||
if (parser.seenval('X')) {
|
if (parser.seenval('X')) {
|
||||||
// TODO: Write the hex bytes after the X
|
// TODO: Write the hex bytes after the X
|
||||||
|
|
Loading…
Reference in a new issue