sram.c 1023 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * File : sram.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009-2013 RT-Thread Develop Team
  5. *
  6. * The license and distribution terms for this file may be
  7. * found in the file LICENSE in this distribution or at
  8. * http://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2013-05-19 Bernard The first version for LPC40xx
  13. */
  14. #include "sram.h"
  15. #include "board.h"
  16. #include <rtthread.h>
  17. #ifdef LPC_EXT_SDRAM
  18. struct rt_memheap system_heap;
  19. void sram_init(void)
  20. {
  21. /* initialize the built-in SRAM as a memory heap */
  22. rt_memheap_init(&system_heap,
  23. "system",
  24. (void *)HEAP_BEGIN,
  25. (rt_uint32_t)HEAP_END - (rt_uint32_t)HEAP_BEGIN);
  26. }
  27. void *sram_malloc(unsigned long size)
  28. {
  29. return rt_memheap_alloc(&system_heap, size);
  30. }
  31. void sram_free(void *ptr)
  32. {
  33. rt_memheap_free(ptr);
  34. }
  35. void *sram_realloc(void *ptr, unsigned long size)
  36. {
  37. return rt_memheap_realloc(&system_heap, ptr, size);
  38. }
  39. #endif