startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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-04-09 fify for M16C
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "iom16c62p.h"
  18. #include "board.h"
  19. #include "bsp.h"
  20. extern int rt_application_init(void);
  21. #ifdef RT_USING_FINSH
  22. extern void finsh_system_init(void);
  23. extern void finsh_set_device(const char* device);
  24. #endif
  25. #ifdef RT_USING_HEAP
  26. #ifdef __ICCM16C__
  27. #pragma section="DATA16_HEAP"
  28. #endif
  29. #endif
  30. /**
  31. * This function will startup RT-Thread RTOS.
  32. */
  33. void rtthread_startup(void)
  34. {
  35. /* init board */
  36. rt_hw_board_init();
  37. /* show version */
  38. rt_show_version();
  39. /* init tick */
  40. rt_system_tick_init();
  41. /* init kernel object */
  42. rt_system_object_init();
  43. /* init timer system */
  44. rt_system_timer_init();
  45. #ifdef RT_USING_HEAP
  46. #ifdef __ICCM16C__
  47. rt_system_heap_init(__segment_begin("DATA16_HEAP"),__segment_end("DATA16_HEAP"));
  48. #endif
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. #ifdef RT_USING_DEVICE
  53. /* init all device */
  54. rt_device_init_all();
  55. #endif
  56. /* init application */
  57. rt_application_init();
  58. #ifdef RT_USING_FINSH
  59. /* init finsh */
  60. finsh_system_init();
  61. finsh_set_device("uart0");
  62. #endif
  63. /* init timer thread */
  64. rt_system_timer_thread_init();
  65. /* init idle thread */
  66. rt_thread_idle_init();
  67. /* start scheduler */
  68. rt_system_scheduler_start();
  69. /* never reach here */
  70. return ;
  71. }
  72. int main(void)
  73. {
  74. /* disable interrupt first */
  75. rt_hw_interrupt_disable();
  76. /* init system setting */
  77. system_init();
  78. /* startup RT-Thread RTOS */
  79. rtthread_startup();
  80. return 0;
  81. }