|
|
@ -26,21 +26,24 @@
|
|
|
|
/** Amount of free RAM
|
|
|
|
/** Amount of free RAM
|
|
|
|
* \return The number of free bytes.
|
|
|
|
* \return The number of free bytes.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __arm__
|
|
|
|
|
|
|
|
extern "C" char* sbrk(int incr);
|
|
|
|
int SdFatUtil::FreeRam() {
|
|
|
|
int SdFatUtil::FreeRam() {
|
|
|
|
extern int __bss_end;
|
|
|
|
char top;
|
|
|
|
extern int* __brkval;
|
|
|
|
return &top - reinterpret_cast<char*>(sbrk(0));
|
|
|
|
int free_memory;
|
|
|
|
|
|
|
|
if (reinterpret_cast<int>(__brkval) == 0) {
|
|
|
|
|
|
|
|
// if no heap use from end of bss section
|
|
|
|
|
|
|
|
free_memory = reinterpret_cast<int>(&free_memory)
|
|
|
|
|
|
|
|
- reinterpret_cast<int>(&__bss_end);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// use from top of stack to heap
|
|
|
|
|
|
|
|
free_memory = reinterpret_cast<int>(&free_memory)
|
|
|
|
|
|
|
|
- reinterpret_cast<int>(__brkval);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return free_memory;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // __arm__
|
|
|
|
|
|
|
|
extern char *__brkval;
|
|
|
|
|
|
|
|
extern char __bss_end;
|
|
|
|
|
|
|
|
/** Amount of free RAM
|
|
|
|
|
|
|
|
* \return The number of free bytes.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
int SdFatUtil::FreeRam() {
|
|
|
|
|
|
|
|
char top;
|
|
|
|
|
|
|
|
return __brkval ? &top - __brkval : &top - &__bss_end;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __arm
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
/** %Print a string in flash memory.
|
|
|
|
/** %Print a string in flash memory.
|
|
|
|
*
|
|
|
|
*
|
|
|
|