Merge pull request #9056 from thinkyhead/bf2_new_eeprom_powers
[2.0.x] New EEPROM powers
This commit is contained in:
commit
013c911a82
|
@ -38,10 +38,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||||
return false;
|
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*/) {
|
||||||
do {
|
do {
|
||||||
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
||||||
*value = c;
|
if (writing) *value = c;
|
||||||
crc16(crc, &c, 1);
|
crc16(crc, &c, 1);
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
|
|
|
@ -43,10 +43,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||||
return false;
|
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*/) {
|
||||||
do {
|
do {
|
||||||
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
||||||
*value = c;
|
if (writing) *value = c;
|
||||||
crc16(crc, &c, 1);
|
crc16(crc, &c, 1);
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
|
|
|
@ -128,7 +128,7 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||||
return (bytes_written != size); // return true for any error
|
return (bytes_written != size); // return true for any error
|
||||||
}
|
}
|
||||||
|
|
||||||
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*/) {
|
||||||
UINT bytes_read = 0;
|
UINT bytes_read = 0;
|
||||||
FRESULT s;
|
FRESULT s;
|
||||||
s = f_lseek(&eeprom_file, pos);
|
s = f_lseek(&eeprom_file, pos);
|
||||||
|
@ -140,7 +140,15 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
|
||||||
SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
|
SERIAL_PROTOCOLLNPAIR(" f_lseek()=", (int)s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (writing) {
|
||||||
s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
|
s = f_read(&eeprom_file, (void *)value, size, &bytes_read);
|
||||||
|
crc16(crc, value, size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
uint8_t temp[size];
|
||||||
|
s = f_read(&eeprom_file, (void *)temp, size, &bytes_read);
|
||||||
|
crc16(crc, temp, size);
|
||||||
|
}
|
||||||
if (s) {
|
if (s) {
|
||||||
SERIAL_PROTOCOLPAIR(" read_data(", pos); // This extra chit-chat goes away soon. But it is helpful
|
SERIAL_PROTOCOLPAIR(" read_data(", pos); // This extra chit-chat goes away soon. But it is helpful
|
||||||
SERIAL_PROTOCOLPAIR(",", (int)value); // right now to see errors that are happening in the
|
SERIAL_PROTOCOLPAIR(",", (int)value); // right now to see errors that are happening in the
|
||||||
|
@ -151,7 +159,6 @@ bool read_data(int &pos, uint8_t* value, uint16_t size, uint16_t *crc) {
|
||||||
SERIAL_PROTOCOLLNPAIR("\n bytes_read=", bytes_read);
|
SERIAL_PROTOCOLLNPAIR("\n bytes_read=", bytes_read);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
crc16(crc, value, size);
|
|
||||||
pos = pos + size;
|
pos = pos + size;
|
||||||
return bytes_read != size; // return true for any error
|
return bytes_read != size; // return true for any error
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,13 +93,13 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||||
return true;
|
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++) {
|
for (uint16_t i = 0; i < size; i++) {
|
||||||
byte* accessPoint = (byte*)(pageBase + pos + 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);
|
pos += ((size + 1) & ~1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@ bool access_start() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool access_finish(){
|
bool access_finish(){
|
||||||
if (!card.cardOK) return false;
|
if (!card.cardOK) return false;
|
||||||
int16_t bytes_written = 0;
|
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;
|
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++) {
|
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;
|
pos += size;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,10 @@ bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc) {
|
||||||
return false;
|
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*/) {
|
||||||
do {
|
do {
|
||||||
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
uint8_t c = eeprom_read_byte((unsigned char*)pos);
|
||||||
*value = c;
|
if (writing) *value = c;
|
||||||
crc16(crc, &c, 1);
|
crc16(crc, &c, 1);
|
||||||
pos++;
|
pos++;
|
||||||
value++;
|
value++;
|
||||||
|
|
|
@ -10,7 +10,7 @@ namespace PersistentStore {
|
||||||
bool access_start();
|
bool access_start();
|
||||||
bool access_finish();
|
bool access_finish();
|
||||||
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc);
|
bool write_data(int &pos, const uint8_t *value, uint16_t size, uint16_t *crc);
|
||||||
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);
|
||||||
|
|
||||||
} // PersistentStore
|
} // PersistentStore
|
||||||
} // HAL
|
} // HAL
|
||||||
|
|
|
@ -309,12 +309,6 @@
|
||||||
|
|
||||||
void unified_bed_leveling::G29() {
|
void unified_bed_leveling::G29() {
|
||||||
|
|
||||||
if (!settings.calc_num_meshes()) {
|
|
||||||
SERIAL_PROTOCOLLNPGM("?Enable EEPROM and init with");
|
|
||||||
SERIAL_PROTOCOLLNPGM("M502, M500, M501 in that order.\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
|
if (g29_parameter_parsing()) return; // abort if parsing the simple parameters causes a problem,
|
||||||
|
|
||||||
// Check for commands that require the printer to be homed
|
// Check for commands that require the printer to be homed
|
||||||
|
@ -1272,8 +1266,8 @@
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
safe_delay(50);
|
safe_delay(50);
|
||||||
|
|
||||||
SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.get_start_of_meshes()));
|
SERIAL_PROTOCOLPAIR("Meshes go from ", hex_address((void*)settings.meshes_start_index()));
|
||||||
SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.get_end_of_meshes()));
|
SERIAL_PROTOCOLLNPAIR(" to ", hex_address((void*)settings.meshes_end_index()));
|
||||||
safe_delay(50);
|
safe_delay(50);
|
||||||
|
|
||||||
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
SERIAL_PROTOCOLLNPAIR("sizeof(ubl) : ", (int)sizeof(ubl));
|
||||||
|
@ -1282,7 +1276,7 @@
|
||||||
SERIAL_EOL();
|
SERIAL_EOL();
|
||||||
safe_delay(25);
|
safe_delay(25);
|
||||||
|
|
||||||
SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.get_end_of_meshes() - settings.get_start_of_meshes())));
|
SERIAL_PROTOCOLLNPAIR("EEPROM free for UBL: ", hex_address((void*)(settings.meshes_end_index() - settings.meshes_start_index())));
|
||||||
safe_delay(50);
|
safe_delay(50);
|
||||||
|
|
||||||
SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
|
SERIAL_PROTOCOLPAIR("EEPROM can hold ", settings.calc_num_meshes());
|
||||||
|
|
|
@ -55,3 +55,15 @@ void GcodeSuite::M502() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // !DISABLE_M503
|
#endif // !DISABLE_M503
|
||||||
|
|
||||||
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
|
/**
|
||||||
|
* M504: Validate EEPROM Contents
|
||||||
|
*/
|
||||||
|
void GcodeSuite::M504() {
|
||||||
|
if (settings.validate()) {
|
||||||
|
SERIAL_ECHO_START();
|
||||||
|
SERIAL_ECHOLNPGM("EEPROM OK");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -610,6 +610,9 @@ void GcodeSuite::process_parsed_command() {
|
||||||
#if DISABLED(DISABLE_M503)
|
#if DISABLED(DISABLE_M503)
|
||||||
case 503: M503(); break; // M503: print settings currently in memory
|
case 503: M503(); break; // M503: print settings currently in memory
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
|
case 504: M504(); break; // M504: Validate EEPROM contents
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
||||||
case 540: M540(); break; // M540: Set abort on endstop hit for SD printing
|
case 540: M540(); break; // M540: Set abort on endstop hit for SD printing
|
||||||
|
|
|
@ -271,8 +271,8 @@ public:
|
||||||
static WorkspacePlane workspace_plane;
|
static WorkspacePlane workspace_plane;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
||||||
#define MAX_COORDINATE_SYSTEMS 9
|
#define MAX_COORDINATE_SYSTEMS 9
|
||||||
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
||||||
static int8_t active_coordinate_system;
|
static int8_t active_coordinate_system;
|
||||||
static float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
static float coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
||||||
static bool select_coordinate_system(const int8_t _new);
|
static bool select_coordinate_system(const int8_t _new);
|
||||||
|
@ -681,6 +681,9 @@ private:
|
||||||
#if DISABLED(DISABLE_M503)
|
#if DISABLED(DISABLE_M503)
|
||||||
static void M503();
|
static void M503();
|
||||||
#endif
|
#endif
|
||||||
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
|
static void M504();
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
||||||
static void M540();
|
static void M540();
|
||||||
|
|
|
@ -2309,7 +2309,6 @@ void kill_screen(const char* lcd_msg) {
|
||||||
MENU_BACK(MSG_UBL_LEVEL_BED);
|
MENU_BACK(MSG_UBL_LEVEL_BED);
|
||||||
if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
|
if (!WITHIN(ubl_storage_slot, 0, a - 1)) {
|
||||||
STATIC_ITEM(MSG_NO_STORAGE);
|
STATIC_ITEM(MSG_NO_STORAGE);
|
||||||
STATIC_ITEM(MSG_INIT_EEPROM);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
|
MENU_ITEM_EDIT(int3, MSG_UBL_STORAGE_SLOT, &ubl_storage_slot, 0, a - 1);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,31 +29,31 @@ class MarlinSettings {
|
||||||
public:
|
public:
|
||||||
MarlinSettings() { }
|
MarlinSettings() { }
|
||||||
|
|
||||||
|
static uint16_t datasize();
|
||||||
|
|
||||||
static void reset();
|
static void reset();
|
||||||
static bool save();
|
static bool save(); // Return 'true' if data was saved
|
||||||
|
|
||||||
FORCE_INLINE static bool init_eeprom() {
|
FORCE_INLINE static bool init_eeprom() {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
reset();
|
reset();
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
if ((success = save())) {
|
success = save();
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(EEPROM_CHITCHAT)
|
||||||
success = load(); // UBL uses load() to know the end of EEPROM
|
if (success) report();
|
||||||
#elif ENABLED(EEPROM_CHITCHAT)
|
|
||||||
report();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
static bool load();
|
static bool load(); // Return 'true' if data was loaded ok
|
||||||
|
static bool validate(); // Return 'true' if EEPROM data is ok
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
|
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
|
||||||
// That can store is enabled
|
// That can store is enabled
|
||||||
FORCE_INLINE static int16_t get_start_of_meshes() { return meshes_begin; }
|
static int16_t meshes_start_index();
|
||||||
FORCE_INLINE static int16_t get_end_of_meshes() { return meshes_end; }
|
FORCE_INLINE static int16_t meshes_end_index() { return meshes_end; }
|
||||||
static uint16_t calc_num_meshes();
|
static uint16_t calc_num_meshes();
|
||||||
static void store_mesh(const int8_t slot);
|
static void store_mesh(const int8_t slot);
|
||||||
static void load_mesh(const int8_t slot, void * const into=NULL);
|
static void load_mesh(const int8_t slot, void * const into=NULL);
|
||||||
|
@ -77,16 +77,18 @@ class MarlinSettings {
|
||||||
static void postprocess();
|
static void postprocess();
|
||||||
|
|
||||||
#if ENABLED(EEPROM_SETTINGS)
|
#if ENABLED(EEPROM_SETTINGS)
|
||||||
static bool eeprom_error;
|
|
||||||
|
static bool eeprom_error, validating;
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
|
#if ENABLED(AUTO_BED_LEVELING_UBL) // Eventually make these available if any leveling system
|
||||||
// That can store is enabled
|
// That can store is enabled
|
||||||
static int16_t meshes_begin;
|
|
||||||
const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
|
const static int16_t meshes_end = E2END - 128; // 128 is a placeholder for the size of the MAT; the MAT will always
|
||||||
// live at the very end of the eeprom
|
// live at the very end of the eeprom
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool _load();
|
||||||
|
static bool size_error(const uint16_t size);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue