AGirs
GirsUtils.cpp
Go to the documentation of this file.
1 #include "GirsUtils.h"
2 
3 //#ifdef FREEMEM
4 // Ref: http://playground.arduino.cc/Code/AvailableMemory#.U0EnzKogTzs
5 unsigned long GirsUtils::freeRam () {
6  extern int __heap_start, *__brkval;
7  int v;
8  return (unsigned long) &v - (__brkval == 0 ? (unsigned long) &__heap_start : (unsigned long) __brkval);
9 }
10 //#endif
11 
12 //#ifdef RESET
13 // TODO: This is somewhat suspect. Use at your own risk.
14 // Works at least on atmega386 and atmega2560,
15 
16 // Restarts program from beginning but does not reset the peripherals and registers
18 #if defined(ARDUINO_AVR_LEONARDO) | defined(ARDUINO_AVR_MICRO) | defined(ARDUINO_ARCH_SAMD)
19 #warning RESET not working on this platform, generating empty function
20 #else
21  asm volatile(" jmp 0");
22 #endif
23 }
static unsigned long freeRam()
Definition: GirsUtils.cpp:5
static void reset()
Definition: GirsUtils.cpp:17