startup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009 - 2011, 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. * 2011-05-23 aozima first implementation for PIC32.
  13. */
  14. // Adds support for PIC32 Peripheral library functions and macros
  15. #include <plib.h>
  16. /**
  17. * This function will startup RT-Thread RTOS.
  18. */
  19. void rtthread_startup(void)
  20. {
  21. /* init board */
  22. rt_hw_board_init();
  23. /* show version */
  24. rt_show_version();
  25. /* init tick */
  26. rt_system_tick_init();
  27. /* init kernel object */
  28. rt_system_object_init();
  29. /* init timer system */
  30. rt_system_timer_init();
  31. //#ifdef RT_USING_HEAP
  32. // #ifdef __CC_ARM
  33. // rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)FM3_SRAM_END);
  34. // #elif __ICCARM__
  35. // rt_system_heap_init(__segment_end("HEAP"), (void*)FM3_SRAM_END);
  36. // #else
  37. // /* init memory system */
  38. // rt_system_heap_init((void*)&__bss_end, (void*)FM3_SRAM_END);
  39. // #endif
  40. //#endif
  41. /* init scheduler system */
  42. rt_system_scheduler_init();
  43. //#ifdef RT_USING_DEVICE
  44. // /* register uart0 */
  45. // rt_hw_serial_register(&uart0_device, "uart0",
  46. // RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  47. // &uart0);
  48. //
  49. // /* register uart2, used for RTI debug */
  50. // rt_hw_serial_register(&uart2_device, "uart2",
  51. // RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  52. // &uart2);
  53. //
  54. //#ifdef RT_USING_DFS
  55. //#ifdef RT_USING_DFS_UFFS
  56. // rt_hw_nand_init();
  57. //#endif
  58. //#endif
  59. //
  60. // /*init all registed devices */
  61. // rt_device_init_all();
  62. //#endif
  63. /* init application */
  64. rt_application_init();
  65. //#ifdef RT_USING_FINSH
  66. // /* init finsh */
  67. // finsh_system_init();
  68. //#ifdef RT_USING_DEVICE
  69. // finsh_set_device("uart2");
  70. //#endif
  71. //#endif
  72. /* init timer thread */
  73. rt_system_timer_thread_init();
  74. /* init idle thread */
  75. rt_thread_idle_init();
  76. /* start scheduler */
  77. rt_system_scheduler_start();
  78. /* never reach here */
  79. return ;
  80. }
  81. int main(void)
  82. {
  83. // /* disable interrupt first */
  84. // rt_hw_interrupt_disable();
  85. /* startup RT-Thread RTOS */
  86. rtthread_startup();
  87. return 0;
  88. }