Merge pull request #58 from Autohome2/new_master

freeram calc
This commit is contained in:
Josh Stewart 2016-11-21 23:15:08 +11:00 committed by GitHub
commit bea6dd17bc
1 changed files with 13 additions and 1 deletions

View File

@ -17,7 +17,19 @@ int freeRam ()
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
#elif defined(CORE_TEENSY)
return 0;
uint32_t stackTop;
uint32_t heapTop;
// current position of the stack.
stackTop = (uint32_t) &stackTop;
// current position of heap.
void* hTop = malloc(1);
heapTop = (uint32_t) hTop;
free(hTop);
// The difference is the free, available ram.
return (uint16_t)stackTop - heapTop;
#endif
}