-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsram1.ino
46 lines (31 loc) · 905 Bytes
/
sram1.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println(freeMemory(), DEC);
Serial.println("Hello!!"); // forced to be compiled into and read
Serial.println(freeMemory(), DEC);
int x = 15;
int y = 20;
int result = x + y;
Serial.println(freeMemory(), DEC);
}
void loop() {
// put your main code here, to run repeatedly:
}
#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else // __ARM__
extern char *__brkval;
#endif // __arm__
int freeMemory()
{
char top;
#ifdef __arm__
return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
return &top - __brkval;
#else // __arm__
return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif // __arm__
}