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

@ -58,11 +58,47 @@ void GcodeSuite::M502() {
#endif // !DISABLE_M503
#if ENABLED(EEPROM_SETTINGS)
#if ENABLED(MARLIN_DEV_MODE)
#include "../../libs/hex_print_routines.h"
#endif
/**
* M504: Validate EEPROM Contents
*/
void GcodeSuite::M504() {
#if ENABLED(MARLIN_DEV_MODE)
const bool dowrite = parser.seenval('W');
if (dowrite || parser.seenval('R')) {
uint8_t val = 0;
int addr = parser.value_ushort();
if (dowrite) {
val = parser.byteval('V');
persistentStore.write_data(addr, &val);
SERIAL_ECHOLNPAIR("Wrote address ", addr, " with ", int(val));
}
else {
if (parser.seenval('T')) {
const int endaddr = parser.value_ushort();
while (addr <= endaddr) {
persistentStore.read_data(addr, &val);
SERIAL_ECHOLNPAIR("0x", hex_word(addr), ":", hex_byte(val));
addr++;
safe_delay(10);
}
SERIAL_EOL();
}
else {
persistentStore.read_data(addr, &val);
SERIAL_ECHOLNPAIR("Read address ", addr, " and got ", int(val));
}
}
return;
}
#endif
if (settings.validate())
SERIAL_ECHO_MSG("EEPROM OK");
}
#endif