startup.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2009-01-05 Bernard first implementation
  9. * 2010-06-29 lgnq for V850
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include "board.h"
  14. #include "CG_macrodriver.h"
  15. #include "CG_system.h"
  16. #include "CG_port.h"
  17. #include "CG_timer.h"
  18. /* Start user code for include. Do not edit comment generated here */
  19. /* End user code. Do not edit comment generated here */
  20. #include "CG_userdefine.h"
  21. extern int rt_application_init(void);
  22. #ifdef RT_USING_FINSH
  23. extern int finsh_system_init(void);
  24. extern void finsh_set_device(const char *device);
  25. #endif
  26. #ifdef RT_USING_HEAP
  27. #ifdef __ICCV850__
  28. #pragma section="RT_HEAP"
  29. #endif
  30. #endif
  31. /**
  32. * This function will startup RT-Thread RTOS.
  33. */
  34. void rtthread_startup(void)
  35. {
  36. /* init board */
  37. rt_hw_board_init();
  38. /* show version */
  39. rt_show_version();
  40. /* init timer system */
  41. rt_system_timer_init();
  42. #ifdef RT_USING_HEAP
  43. #ifdef __ICCV850__
  44. rt_system_heap_init(__segment_begin("RT_HEAP"), __segment_end("RT_HEAP"));
  45. #endif
  46. #endif
  47. /* init scheduler system */
  48. rt_system_scheduler_init();
  49. /* init application */
  50. rt_application_init();
  51. #ifdef RT_USING_FINSH
  52. /* init finsh */
  53. finsh_system_init();
  54. #if !defined(RT_USING_POSIX_STDIO) && defined(RT_USING_DEVICE)
  55. finsh_set_device("uart0");
  56. #endif
  57. #endif
  58. /* init timer thread */
  59. rt_system_timer_thread_init();
  60. /* init idle thread */
  61. rt_thread_idle_init();
  62. /* start scheduler */
  63. rt_system_scheduler_start();
  64. /* never reach here */
  65. return ;
  66. }
  67. int main(void)
  68. {
  69. /* disable interrupt first */
  70. rt_hw_interrupt_disable();
  71. /* init system setting */
  72. TAB0_Start();
  73. /* startup RT-Thread RTOS */
  74. rtthread_startup();
  75. return 0;
  76. }