From deff538909f50ee9b792b313fe8c32f32beb6263 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 15 Dec 2019 20:21:56 -0600 Subject: [PATCH] Fix broken M100_dump_routine --- Marlin/src/gcode/calibrate/M100.cpp | 17 +++++++++-------- Marlin/src/gcode/gcode.cpp | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Marlin/src/gcode/calibrate/M100.cpp b/Marlin/src/gcode/calibrate/M100.cpp index a6f4f8f5d2..452dfd033c 100644 --- a/Marlin/src/gcode/calibrate/M100.cpp +++ b/Marlin/src/gcode/calibrate/M100.cpp @@ -51,7 +51,7 @@ * Also, there are two support functions that can be called from a developer's C code. * * uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start); - * void M100_dump_routine(PGM_P const title, char *start, char *end); + * void M100_dump_routine(PGM_P const title, const char * const start, const char * const end); * * Initial version by Roxy-3D */ @@ -151,8 +151,8 @@ inline int32_t count_test_bytes(const char * const start_free_memory) { // Start and end the dump on a nice 16 byte boundary // (even though the values are not 16-byte aligned). // - start_free_memory = (char*)((ptr_int_t)((uint32_t)start_free_memory & 0xFFFFFFF0)); // Align to 16-byte boundary - end_free_memory = (char*)((ptr_int_t)((uint32_t)end_free_memory | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory) + start_free_memory = (char*)(ptr_int_t(uint32_t(start_free_memory) & ~0xFUL)); // Align to 16-byte boundary + end_free_memory = (char*)(ptr_int_t(uint32_t(end_free_memory) | 0xFUL)); // Align end_free_memory to the 15th byte (at or above end_free_memory) // Dump command main loop while (start_free_memory < end_free_memory) { @@ -177,15 +177,16 @@ inline int32_t count_test_bytes(const char * const start_free_memory) { } } - void M100_dump_routine(PGM_P const title, char *start, char *end) { + void M100_dump_routine(PGM_P const title, const char * const start, const char * const end) { serialprintPGM(title); SERIAL_EOL(); // // Round the start and end locations to produce full lines of output // - start = (char*)((ptr_int_t)((uint32_t)start & 0xFFFFFFF0)); // Align to 16-byte boundary - end = (char*)((ptr_int_t)((uint32_t)end | 0x0000000F)); // Align end_free_memory to the 15th byte (at or above end_free_memory) - dump_free_memory(start, end); + dump_free_memory( + (char*)(ptr_int_t(uint32_t(start) & ~0xFUL)), // Align to 16-byte boundary + (char*)(ptr_int_t(uint32_t(end) | 0xFUL)) // Align end_free_memory to the 15th byte (at or above end_free_memory) + ); } #endif // M100_FREE_MEMORY_DUMPER @@ -211,7 +212,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) { // idle(); serial_delay(20); #if ENABLED(M100_FREE_MEMORY_DUMPER) - M100_dump_routine(PSTR(" Memory corruption detected with end_free_memory