|
@@ -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
|
*
|