瀏覽代碼

Minor M100 cleanup

Scott Lahteine 5 年之前
父節點
當前提交
04715e04ee
共有 2 個文件被更改,包括 24 次插入33 次删除
  1. 23
    32
      Marlin/src/gcode/calibrate/M100.cpp
  2. 1
    1
      Marlin/src/gcode/gcode.cpp

+ 23
- 32
Marlin/src/gcode/calibrate/M100.cpp 查看文件

@@ -51,7 +51,7 @@
51 51
  * Also, there are two support functions that can be called from a developer's C code.
52 52
  *
53 53
  *    uint16_t check_for_free_memory_corruption(PGM_P const free_memory_start);
54
- *    void M100_dump_routine(PGM_P const title, const char *start, const char *end);
54
+ *    void M100_dump_routine(PGM_P const title, char *start, char *end);
55 55
  *
56 56
  * Initial version by Roxy-3D
57 57
  */
@@ -63,43 +63,34 @@
63 63
 #if defined(__AVR__) || IS_32BIT_TEENSY
64 64
 
65 65
   extern char __bss_end;
66
-  char* end_bss =  &__bss_end;
67
-  char* free_memory_start = end_bss;
68
-
69
-
70
-  char* free_memory_end = 0;
71
-  char* stacklimit = 0;
72
-  char* heaplimit = 0;
66
+  char *end_bss = &__bss_end,
67
+       *free_memory_start = end_bss, *free_memory_end = 0,
68
+       *stacklimit = 0, *heaplimit = 0;
73 69
 
74 70
   #define MEMORY_END_CORRECTION 0
75 71
 
76 72
 #elif defined(TARGET_LPC1768)
77 73
 
78
-  extern char   __bss_end__;
79
-  extern char   __StackLimit;
80
-  extern char   __HeapLimit;
74
+  extern char __bss_end__, __StackLimit, __HeapLimit;
81 75
 
82
-  char* end_bss =  &__bss_end__;
83
-  char* stacklimit =  &__StackLimit;
84
-  char* heaplimit =  &__HeapLimit ;
76
+  char *end_bss = &__bss_end__,
77
+       *stacklimit = &__StackLimit,
78
+       *heaplimit = &__HeapLimit ;
85 79
 
86 80
   #define MEMORY_END_CORRECTION 0x200
87 81
 
88
-  char* free_memory_start = heaplimit;
89
-  char* free_memory_end = stacklimit - MEMORY_END_CORRECTION;
90
-
82
+  char *free_memory_start = heaplimit,
83
+       *free_memory_end = stacklimit - MEMORY_END_CORRECTION;
91 84
 
92 85
 #elif defined(__SAM3X8E__)
93 86
 
94
-  extern char   _ebss;
95
-
96
-  char* end_bss = &_ebss;
97
-
98
-  char* free_memory_start = end_bss;
87
+  extern char _ebss;
99 88
 
100
-  char* free_memory_end = 0;
101
-  char* stacklimit = 0;
102
-  char* heaplimit = 0;
89
+  char *end_bss = &_ebss,
90
+       *free_memory_start = end_bss,
91
+       *free_memory_end = 0,
92
+       *stacklimit = 0,
93
+       *heaplimit = 0;
103 94
 
104 95
   #define MEMORY_END_CORRECTION 0x10000  // need to stay well below 0x20080000 or M100 F crashes
105 96
 
@@ -141,7 +132,7 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
141 132
    *  the block. If so, it may indicate memory corruption due to a bad pointer.
142 133
    *  Unexpected bytes are flagged in the right column.
143 134
    */
144
-  inline void dump_free_memory(const char *start_free_memory, const char *end_free_memory) {
135
+  inline void dump_free_memory(char *start_free_memory, char *end_free_memory) {
145 136
     //
146 137
     // Start and end the dump on a nice 16 byte boundary
147 138
     // (even though the values are not 16-byte aligned).
@@ -162,7 +153,7 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
162 153
       SERIAL_CHAR('|');                   // Point out non test bytes
163 154
       for (uint8_t i = 0; i < 16; i++) {
164 155
         char ccc = (char)start_free_memory[i]; // cast to char before automatically casting to char on assignment, in case the compiler is broken
165
-        if (&start_free_memory[i] >= (const char*)command_queue && &start_free_memory[i] < (const char*)(command_queue + sizeof(command_queue))) { // Print out ASCII in the command buffer area
156
+        if (&start_free_memory[i] >= (char*)command_queue && &start_free_memory[i] < (char*)command_queue + sizeof(command_queue)) { // Print out ASCII in the command buffer area
166 157
           if (!WITHIN(ccc, ' ', 0x7E)) ccc = ' ';
167 158
         }
168 159
         else { // If not in the command buffer area, flag bytes that don't match the test byte
@@ -177,7 +168,7 @@ inline int32_t count_test_bytes(const char * const start_free_memory) {
177 168
     }
178 169
   }
179 170
 
180
-  void M100_dump_routine(PGM_P const title, const char *start, const char *end) {
171
+  void M100_dump_routine(PGM_P const title, char *start, char *end) {
181 172
     serialprintPGM(title);
182 173
     SERIAL_EOL();
183 174
     //
@@ -198,7 +189,7 @@ inline int check_for_free_memory_corruption(PGM_P const title) {
198 189
 
199 190
   SERIAL_ECHOPAIR("\nfmc() n=", n);
200 191
   SERIAL_ECHOPAIR("\nfree_memory_start=", hex_address(free_memory_start));
201
-  SERIAL_ECHOLNPAIR("  end_free_memory=",          hex_address(end_free_memory));
192
+  SERIAL_ECHOLNPAIR("  end_free_memory=", hex_address(end_free_memory));
202 193
 
203 194
   if (end_free_memory < start_free_memory)  {
204 195
     SERIAL_ECHOPGM(" end_free_memory < Heap ");
@@ -340,11 +331,11 @@ void GcodeSuite::M100() {
340 331
   char *sp = top_of_stack();
341 332
   if (!free_memory_end) free_memory_end = sp - MEMORY_END_CORRECTION;
342 333
   SERIAL_ECHOPAIR("\nbss_end               : ", hex_address(end_bss));
343
-  if (heaplimit) SERIAL_ECHOPAIR("\n__heaplimit           : ", hex_address(heaplimit ));
334
+  if (heaplimit) SERIAL_ECHOPAIR("\n__heaplimit           : ", hex_address(heaplimit));
344 335
   SERIAL_ECHOPAIR("\nfree_memory_start     : ", hex_address(free_memory_start));
345 336
   if (stacklimit) SERIAL_ECHOPAIR("\n__stacklimit          : ", hex_address(stacklimit));
346
-  SERIAL_ECHOPAIR("\nfree_memory_end       : ", hex_address(free_memory_end  ));
347
-  if (MEMORY_END_CORRECTION)  SERIAL_ECHOPAIR("\nMEMORY_END_CORRECTION: ", MEMORY_END_CORRECTION );
337
+  SERIAL_ECHOPAIR("\nfree_memory_end       : ", hex_address(free_memory_end));
338
+  if (MEMORY_END_CORRECTION)  SERIAL_ECHOPAIR("\nMEMORY_END_CORRECTION: ", MEMORY_END_CORRECTION);
348 339
   SERIAL_ECHOLNPAIR("\nStack Pointer         : ", hex_address(sp));
349 340
 
350 341
   // Always init on the first invocation of M100

+ 1
- 1
Marlin/src/gcode/gcode.cpp 查看文件

@@ -181,7 +181,7 @@ void GcodeSuite::dwell(millis_t time) {
181 181
 // Placeholders for non-migrated codes
182 182
 //
183 183
 #if ENABLED(M100_FREE_MEMORY_WATCHER)
184
-  extern void M100_dump_routine(PGM_P const title, const char *start, const char *end);
184
+  extern void M100_dump_routine(PGM_P const title, char *start, char *end);
185 185
 #endif
186 186
 
187 187
 /**

Loading…
取消
儲存