Add freeRam() function for stm32

This commit is contained in:
Josh Stewart 2017-07-07 09:04:45 +10:00
parent 5ddfde074f
commit a09c5772ee
2 changed files with 4 additions and 2 deletions

View File

@ -13,6 +13,7 @@
#define CORE_STM32
#define LED_BUILTIN 33
extern "C" char* sbrk(int incr); //Used to freeRam
inline unsigned char digitalPinToInterrupt(unsigned char Interrupt_pin) { return Interrupt_pin; } //This isn't included in the stm32duino libs (yet)
#define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value
#define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) //These are defined in STM32F1/variants/generic_stm32f103c/variant.h but return a non byte* value

View File

@ -34,8 +34,9 @@ uint16_t freeRam ()
// The difference is the free, available ram.
return (uint16_t)stackTop - heapTop;
#elif defined(CORE_STM32)
//Figure this out some_time
return 0;
char top = 't';
return &top - reinterpret_cast<char*>(sbrk(0));
#endif
}