startup.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include <rtthread.h>
  17. extern int _ramfunc_end;
  18. #define PIC32_SRAM_END (0xA0000000+0x8000) //795F512L 512KB
  19. /**
  20. * This function will startup RT-Thread RTOS.
  21. */
  22. void rtthread_startup(void)
  23. {
  24. /* init board */
  25. rt_hw_board_init();
  26. /* show version */
  27. rt_show_version();
  28. /* init tick */
  29. rt_system_tick_init();
  30. /* init kernel object */
  31. rt_system_object_init();
  32. /* init timer system */
  33. rt_system_timer_init();
  34. #ifdef RT_USING_HEAP
  35. /* init memory system */
  36. rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
  37. #endif
  38. /* init scheduler system */
  39. rt_system_scheduler_init();
  40. //#ifdef RT_USING_DEVICE
  41. // /* register uart0 */
  42. // rt_hw_serial_register(&uart0_device, "uart0",
  43. // RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  44. // &uart0);
  45. //
  46. // /* register uart2, used for RTI debug */
  47. // rt_hw_serial_register(&uart2_device, "uart2",
  48. // RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM,
  49. // &uart2);
  50. //
  51. //#ifdef RT_USING_DFS
  52. //#ifdef RT_USING_DFS_UFFS
  53. // rt_hw_nand_init();
  54. //#endif
  55. //#endif
  56. //
  57. // /*init all registed devices */
  58. // rt_device_init_all();
  59. //#endif
  60. /* init application */
  61. rt_application_init();
  62. //#ifdef RT_USING_FINSH
  63. // /* init finsh */
  64. // finsh_system_init();
  65. //#ifdef RT_USING_DEVICE
  66. // finsh_set_device("uart2");
  67. //#endif
  68. //#endif
  69. /* init timer thread */
  70. rt_system_timer_thread_init();
  71. /* init idle thread */
  72. rt_thread_idle_init();
  73. /* start scheduler */
  74. rt_system_scheduler_start();
  75. /* never reach here */
  76. return ;
  77. }
  78. int main(void)
  79. {
  80. /* disable interrupt first */
  81. rt_hw_interrupt_disable();
  82. /* startup RT-Thread RTOS */
  83. rtthread_startup();
  84. return 0;
  85. }