startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012, RT-Thread Development 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. * 2009-01-05 Bernard first implementation
  13. * 2012-12-11 lgnq modified for LPC4330
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "platform.h"
  18. /**
  19. * @addtogroup LPC4330
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef __CC_ARM
  24. extern int Image$$RW_IRAM1$$ZI$$Limit;
  25. #define LPC4300_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
  26. #elif __ICCARM__
  27. #pragma section="HEAP"
  28. #define LPC4300_SRAM_BEGIN (__segment_end("HEAP"))
  29. #else
  30. extern int __bss_end;
  31. #define LPC4300_SRAM_BEGIN (&__bss_end)
  32. #endif
  33. /**
  34. * This function will startup RT-Thread RTOS.
  35. */
  36. void rtthread_startup(void)
  37. {
  38. /* init board */
  39. rt_hw_board_init();
  40. /* show version */
  41. rt_show_version();
  42. #ifdef RT_USING_HEAP
  43. /* initialize memory system */
  44. rt_system_heap_init((void *)LPC4300_SRAM_BEGIN, (void *)(0x10000000 + 1024*128));
  45. #endif
  46. /* init scheduler system */
  47. rt_system_scheduler_init();
  48. #ifdef RT_USING_DEVICE
  49. /* init all device */
  50. rt_device_init_all();
  51. #endif
  52. /* init application */
  53. rt_application_init();
  54. /* init timer thread */
  55. rt_system_timer_thread_init();
  56. /* init idle thread */
  57. rt_thread_idle_init();
  58. /* start scheduler */
  59. rt_system_scheduler_start();
  60. /* never reach here */
  61. return ;
  62. }
  63. int main(void)
  64. {
  65. /* disable interrupt first */
  66. rt_hw_interrupt_disable();
  67. /* startup RT-Thread RTOS */
  68. rtthread_startup();
  69. return 0;
  70. }
  71. /*@}*/