keybrd library is an open source library for creating custom-keyboard firmware.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
Este repositório está arquivado. Você pode visualizar os arquivos e realizar clone, mas não poderá realizar push nem abrir issues e pull requests.

getFreeSRAM.h 1.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // getFreeSRAM.h copied from
  2. // http://andybrown.me.uk/2011/01/01/debugging-avr-dynamic-memory-allocation/
  3. /*
  4. * memdebug.h
  5. *
  6. * Created on: 15 Dec 2010
  7. * Author: Andy Brown
  8. *
  9. * Use without attribution is permitted provided that this
  10. * header remains intact and that these terms and conditions
  11. * are followed:
  12. *
  13. * http://andybrown.me.uk/ws/terms-and-conditions
  14. */
  15. #include <inttypes.h>
  16. extern unsigned int __bss_end;
  17. extern unsigned int __heap_start;
  18. extern void *__brkval;
  19. //measure and return amount of free SRAM
  20. /*
  21. uint16_t getFreeSRAM()
  22. {
  23. uint8_t newVariable;
  24. // if heap is empty, use bss as start memory address
  25. if ((uint16_t)__brkval == 0)
  26. {
  27. return (((uint16_t)&newVariable) - ((uint16_t)&__bss_end));
  28. }
  29. // else use heap end as the start of the memory address
  30. else
  31. {
  32. return (((uint16_t)&newVariable) - ((uint16_t)__brkval));
  33. }
  34. };
  35. */
  36. // uint32_t for Teensy LC
  37. uint32_t getFreeSRAM()
  38. {
  39. uint8_t newVariable;
  40. // if heap is empty, use bss as start memory address
  41. if ((uint32_t)__brkval == 0)
  42. {
  43. return (((uint32_t)&newVariable) - ((uint32_t)&__bss_end));
  44. }
  45. // else use heap end as the start of the memory address
  46. else
  47. {
  48. return (((uint32_t)&newVariable) - ((uint32_t)__brkval));
  49. }
  50. };