Subversion Repositories Projects

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1702 - 1
 /*
2
 * MemoryFree.c
3
 * returns the number of free RAM bytes
4
*/
5
 
6
// Get the common arduino functions
7
#if defined(ARDUINO) && ARDUINO >= 100
8
        #include "Arduino.h"
9
#else
10
        #include "wiring.h"
11
#endif
12
#include "MemoryFree.h"
13
 
14
extern unsigned int __data_start;
15
extern unsigned int __data_end;
16
extern unsigned int __bss_start;
17
extern unsigned int __bss_end;
18
extern unsigned int __heap_start;
19
extern void *__brkval;
20
 
21
 
22
int freeMem()
23
{
24
  int free_memory;
25
 
26
  if((int)__brkval == 0)
27
     free_memory = ((int)&free_memory) - ((int)&__bss_end);
28
  else
29
    free_memory = ((int)&free_memory) - ((int)__brkval);
30
 
31
  return free_memory;
32
}
33
 
34