startup.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 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. * 2010-06-29 lgnq for V850
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. #include "CG_macrodriver.h"
  19. #include "CG_system.h"
  20. #include "CG_port.h"
  21. #include "CG_timer.h"
  22. /* Start user code for include. Do not edit comment generated here */
  23. /* End user code. Do not edit comment generated here */
  24. #include "CG_userdefine.h"
  25. extern int rt_application_init(void);
  26. #ifdef RT_USING_FINSH
  27. extern void finsh_system_init(void);
  28. extern void finsh_set_device(const char *device);
  29. #endif
  30. #ifdef RT_USING_HEAP
  31. #ifdef __ICCV850__
  32. #pragma section="RT_HEAP"
  33. #endif
  34. #endif
  35. /**
  36. * This function will startup RT-Thread RTOS.
  37. */
  38. void rtthread_startup(void)
  39. {
  40. /* init board */
  41. rt_hw_board_init();
  42. /* show version */
  43. rt_show_version();
  44. /* init tick */
  45. rt_system_tick_init();
  46. /* init kernel object */
  47. rt_system_object_init();
  48. /* init timer system */
  49. rt_system_timer_init();
  50. #ifdef RT_USING_HEAP
  51. #ifdef __ICCV850__
  52. rt_system_heap_init(__segment_begin("RT_HEAP"), __segment_end("RT_HEAP"));
  53. #endif
  54. #endif
  55. /* init scheduler system */
  56. rt_system_scheduler_init();
  57. /* init application */
  58. rt_application_init();
  59. #ifdef RT_USING_FINSH
  60. /* init finsh */
  61. finsh_system_init();
  62. finsh_set_device("uart0");
  63. #endif
  64. /* init timer thread */
  65. rt_system_timer_thread_init();
  66. /* init idle thread */
  67. rt_thread_idle_init();
  68. /* start scheduler */
  69. rt_system_scheduler_start();
  70. /* never reach here */
  71. return ;
  72. }
  73. int main(void)
  74. {
  75. /* disable interrupt first */
  76. rt_hw_interrupt_disable();
  77. /* init system setting */
  78. TAB0_Start();
  79. /* startup RT-Thread RTOS */
  80. rtthread_startup();
  81. return 0;
  82. }