1
0

sram.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * File : sram.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2015, RT-Thread Development Team
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2015-08-03 xiaonong The first version for STM32F7
  23. * 2017-08-25 LongfeiMa transplantation for stm32h7xx
  24. */
  25. #include "sram.h"
  26. #include "board.h"
  27. #include <rtthread.h>
  28. #ifdef RT_USING_EXT_SDRAM
  29. struct rt_memheap system_heap;
  30. void sram_init(void)
  31. {
  32. /* initialize the built-in SRAM as a memory heap */
  33. rt_memheap_init(&system_heap,
  34. "system",
  35. (void *)HEAP_BEGIN,
  36. (rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN);
  37. }
  38. void *sram_malloc(unsigned long size)
  39. {
  40. return rt_memheap_alloc(&system_heap, size);
  41. }
  42. RTM_EXPORT(sram_malloc);
  43. void sram_free(void *ptr)
  44. {
  45. rt_memheap_free(ptr);
  46. }
  47. RTM_EXPORT(sram_free);
  48. void *sram_realloc(void *ptr, unsigned long size)
  49. {
  50. return rt_memheap_realloc(&system_heap, ptr, size);
  51. }
  52. RTM_EXPORT(sram_realloc);
  53. #endif