startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 void rt_hw_interrupt_init(void);
  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. #if (defined (__ICCM16C__))
  28. #pragma section="DATA16_HEAP"
  29. #elif (defined (__GNUC__))
  30. extern unsigned char user_ram_end;
  31. #endif
  32. #endif
  33. /**
  34. * This function will startup RT-Thread RTOS.
  35. */
  36. void rtthread_startup(void)
  37. {
  38. /* init hardware interrupt */
  39. rt_hw_interrupt_init();
  40. /* init board */
  41. rt_hw_board_init();
  42. /* show version */
  43. rt_show_version();
  44. /* init timer system */
  45. rt_system_timer_init();
  46. #ifdef RT_USING_HEAP
  47. #ifdef __ICCM16C__
  48. rt_system_heap_init(__segment_begin("DATA16_HEAP"), __segment_end("DATA16_HEAP"));
  49. #elif (defined (__GNUC__))
  50. rt_system_heap_init((void*)&user_ram_end, (void*)M16C62P_SRAM_END);
  51. #endif
  52. #endif
  53. /* init scheduler system */
  54. rt_system_scheduler_init();
  55. /* init application */
  56. rt_application_init();
  57. #ifdef RT_USING_FINSH
  58. /* init finsh */
  59. finsh_system_init();
  60. finsh_set_device("uart0");
  61. #endif
  62. /* init timer thread */
  63. rt_system_timer_thread_init();
  64. /* init idle thread */
  65. rt_thread_idle_init();
  66. /* start scheduler */
  67. rt_system_scheduler_start();
  68. /* never reach here */
  69. return ;
  70. }
  71. int main(void)
  72. {
  73. /* disable interrupt first */
  74. rt_hw_interrupt_disable();
  75. /* init system setting */
  76. system_init();
  77. /* startup RT-Thread RTOS */
  78. rtthread_startup();
  79. return 0;
  80. }