startup.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, 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. * 2010-03-04 Magicoe for LPC17xx
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "LPC17xx.h"
  18. #include "board.h"
  19. #ifdef RT_USING_DFS
  20. #include "sd.h"
  21. #endif
  22. /**
  23. * @addtogroup LPC17
  24. */
  25. /*@{*/
  26. extern int rt_application_init(void);
  27. #ifdef __CC_ARM
  28. extern int Image$$RW_IRAM1$$ZI$$Limit;
  29. #elif __ICCARM__
  30. #pragma section="HEAP"
  31. #else
  32. extern int __bss_end;
  33. #endif
  34. #ifdef DEBUG
  35. /*******************************************************************************
  36. * Function Name : assert_failed
  37. * Description : Reports the name of the source file and the source line number
  38. * where the assert error has occurred.
  39. * Input : - file: pointer to the source file name
  40. * - line: assert error line source number
  41. * Output : None
  42. * Return : None
  43. *******************************************************************************/
  44. void assert_failed(u8* file, u32 line)
  45. {
  46. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  47. rt_kprintf(" file %s\r\n", file);
  48. rt_kprintf(" line %d\r\n", line);
  49. while (1) ;
  50. }
  51. #endif
  52. /**
  53. * This function will startup RT-Thread RTOS.
  54. */
  55. void rtthread_startup(void)
  56. {
  57. /* initialize board */
  58. rt_hw_board_init();
  59. /* show version */
  60. rt_show_version();
  61. #ifdef RT_USING_HEAP
  62. /* initialize memory system */
  63. #ifdef __CC_ARM
  64. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x10008000);
  65. #elif __ICCARM__
  66. rt_system_heap_init(__segment_end("HEAP"), (void*)0x10008000);
  67. #else
  68. rt_system_heap_init((void*)&__bss_end, (void*)0x10008000);
  69. #endif
  70. #endif
  71. /* initialize scheduler system */
  72. rt_system_scheduler_init();
  73. #ifdef RT_USING_DEVICE
  74. #ifdef RT_USING_DFS
  75. rt_hw_sdcard_init();
  76. #endif
  77. /* initialize all device */
  78. rt_device_init_all();
  79. #endif
  80. /* initialize application */
  81. rt_application_init();
  82. /* initialize timer thread */
  83. rt_system_timer_thread_init();
  84. /* initialize idle thread */
  85. rt_thread_idle_init();
  86. /* start scheduler */
  87. rt_system_scheduler_start();
  88. /* never reach here */
  89. return ;
  90. }
  91. int main(void)
  92. {
  93. /* disable interrupt first */
  94. rt_hw_interrupt_disable();
  95. /* startup RT-Thread RTOS */
  96. rtthread_startup();
  97. return 0;
  98. }
  99. /*@}*/