Merge pull request #1167 from thinkyhead/sd_freemem
Use SdFatUtil::FreeRam() for freeMemory() if there
This commit is contained in:
commit
60628864ca
1 changed files with 17 additions and 12 deletions
|
@ -402,22 +402,27 @@ void serial_echopair_P(const char *s_P, double v)
|
||||||
void serial_echopair_P(const char *s_P, unsigned long v)
|
void serial_echopair_P(const char *s_P, unsigned long v)
|
||||||
{ serialprintPGM(s_P); SERIAL_ECHO(v); }
|
{ serialprintPGM(s_P); SERIAL_ECHO(v); }
|
||||||
|
|
||||||
extern "C"{
|
#ifdef SDSUPPORT
|
||||||
extern unsigned int __bss_end;
|
#include "SdFatUtil.h"
|
||||||
extern unsigned int __heap_start;
|
int freeMemory() { return SdFatUtil::FreeRam(); }
|
||||||
extern void *__brkval;
|
#else
|
||||||
|
extern "C" {
|
||||||
|
extern unsigned int __bss_end;
|
||||||
|
extern unsigned int __heap_start;
|
||||||
|
extern void *__brkval;
|
||||||
|
|
||||||
int freeMemory() {
|
int freeMemory() {
|
||||||
int free_memory;
|
int free_memory;
|
||||||
|
|
||||||
if((int)__brkval == 0)
|
if ((int)__brkval == 0)
|
||||||
free_memory = ((int)&free_memory) - ((int)&__bss_end);
|
free_memory = ((int)&free_memory) - ((int)&__bss_end);
|
||||||
else
|
else
|
||||||
free_memory = ((int)&free_memory) - ((int)__brkval);
|
free_memory = ((int)&free_memory) - ((int)__brkval);
|
||||||
|
|
||||||
return free_memory;
|
return free_memory;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
#endif //!SDSUPPORT
|
||||||
|
|
||||||
//adds an command to the main command buffer
|
//adds an command to the main command buffer
|
||||||
//thats really done in a non-safe way.
|
//thats really done in a non-safe way.
|
||||||
|
|
Reference in a new issue