Browse Source

Fix regressions affecting compilation

This fixes two regressions, caused by #1167 and #1191 .
Scott Lahteine 9 years ago
parent
commit
2ec2bf1564
2 changed files with 17 additions and 14 deletions
  1. 16
    13
      Marlin/SdFatUtil.cpp
  2. 1
    1
      Marlin/dogm_lcd_implementation.h

+ 16
- 13
Marlin/SdFatUtil.cpp View File

@@ -26,21 +26,24 @@
26 26
 /** Amount of free RAM
27 27
  * \return The number of free bytes.
28 28
  */
29
+#ifdef __arm__
30
+extern "C" char* sbrk(int incr);
29 31
 int SdFatUtil::FreeRam() {
30
-  extern int  __bss_end;
31
-  extern int* __brkval;
32
-  int free_memory;
33
-  if (reinterpret_cast<int>(__brkval) == 0) {
34
-    // if no heap use from end of bss section
35
-    free_memory = reinterpret_cast<int>(&free_memory)
36
-                  - reinterpret_cast<int>(&__bss_end);
37
-  } else {
38
-    // use from top of stack to heap
39
-    free_memory = reinterpret_cast<int>(&free_memory)
40
-                  - reinterpret_cast<int>(__brkval);
41
-  }
42
-  return free_memory;
32
+  char top;
33
+  return &top - reinterpret_cast<char*>(sbrk(0));
43 34
 }
35
+#else  // __arm__
36
+extern char *__brkval;
37
+extern char __bss_end;
38
+/** Amount of free RAM
39
+ * \return The number of free bytes.
40
+ */
41
+int SdFatUtil::FreeRam() {
42
+  char top;
43
+  return __brkval ? &top - __brkval : &top - &__bss_end;
44
+}
45
+#endif  // __arm
46
+
44 47
 //------------------------------------------------------------------------------
45 48
 /** %Print a string in flash memory.
46 49
  *

+ 1
- 1
Marlin/dogm_lcd_implementation.h View File

@@ -337,7 +337,7 @@ static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, c
337 337
 		u8g.setColorIndex(1);		// restore settings to black on white
338 338
 }
339 339
 
340
-static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, char* data, bool pgm) {
340
+static void _drawmenu_setting_edit_generic(uint8_t row, const char* pstr, char pre_char, const char* data, bool pgm) {
341 341
   char c;
342 342
   uint8_t n = LCD_WIDTH - 1 - 2 - (pgm ? strlen_P(data) : strlen(data));
343 343
 		

Loading…
Cancel
Save