startup.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 "LPC177x_8x.h"
  18. #include "board.h"
  19. extern int rt_application_init(void);
  20. #ifdef RT_USING_FINSH
  21. extern void finsh_system_init(void);
  22. extern void finsh_set_device(const char* device);
  23. #endif
  24. #ifdef __CC_ARM
  25. extern int Image$$RW_IRAM1$$ZI$$Limit;
  26. #elif __ICCARM__
  27. #pragma section="HEAP"
  28. #else
  29. extern int __bss_end;
  30. #endif
  31. #ifdef DEBUG
  32. /*******************************************************************************
  33. * Function Name : assert_failed
  34. * Description : Reports the name of the source file and the source line number
  35. * where the assert error has occurred.
  36. * Input : - file: pointer to the source file name
  37. * - line: assert error line source number
  38. * Output : None
  39. * Return : None
  40. *******************************************************************************/
  41. void assert_failed(u8* file, u32 line)
  42. {
  43. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  44. rt_kprintf(" file %s\r\n", file);
  45. rt_kprintf(" line %d\r\n", line);
  46. while (1) ;
  47. }
  48. #endif
  49. /**
  50. * This function will startup RT-Thread RTOS.
  51. */
  52. void rtthread_startup(void)
  53. {
  54. /* initialize board */
  55. rt_hw_board_init();
  56. /* show version */
  57. rt_show_version();
  58. #ifdef RT_USING_HEAP
  59. /* initialize memory system */
  60. #ifdef __CC_ARM
  61. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)(0x10000000 + 1024*64));
  62. #elif __ICCARM__
  63. rt_system_heap_init(__segment_end("HEAP"), (void*)(0x10000000 + 1024*64));
  64. #else
  65. rt_system_heap_init((void*)&__bss_end, (void*)(0x10000000 + 1024*64));
  66. #endif
  67. #endif
  68. /* initialize scheduler system */
  69. rt_system_scheduler_init();
  70. /* initialize application */
  71. rt_application_init();
  72. #ifdef RT_USING_FINSH
  73. /* initialize finsh */
  74. finsh_system_init();
  75. finsh_set_device( FINSH_DEVICE_NAME );
  76. #endif
  77. /* initialize timer thread */
  78. rt_system_timer_thread_init();
  79. /* initialize idle thread */
  80. rt_thread_idle_init();
  81. /* start scheduler */
  82. rt_system_scheduler_start();
  83. /* never reach here */
  84. return ;
  85. }
  86. int main(void)
  87. {
  88. /* disable interrupt first */
  89. rt_hw_interrupt_disable();
  90. /* startup RT-Thread RTOS */
  91. rtthread_startup();
  92. return 0;
  93. }