sram.c 855 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2013-05-19 Bernard The first version for LPC40xx
  9. */
  10. #include "sram.h"
  11. #include "board.h"
  12. #include <rtthread.h>
  13. #ifdef LPC_EXT_SDRAM
  14. struct rt_memheap system_heap;
  15. void sram_init(void)
  16. {
  17. /* initialize the built-in SRAM as a memory heap */
  18. rt_memheap_init(&system_heap,
  19. "system",
  20. (void *)HEAP_BEGIN,
  21. (rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN);
  22. }
  23. void *sram_malloc(unsigned long size)
  24. {
  25. return rt_memheap_alloc(&system_heap, size);
  26. }
  27. void sram_free(void *ptr)
  28. {
  29. rt_memheap_free(ptr);
  30. }
  31. void *sram_realloc(void *ptr, unsigned long size)
  32. {
  33. return rt_memheap_realloc(&system_heap, ptr, size);
  34. }
  35. #endif