startup.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 + 1024UL*128) //795F512L 512K FLASH 128KB SRAM
  19. #ifdef RT_USING_FINSH
  20. extern void finsh_system_init(void);
  21. extern void finsh_set_device(const char* device);
  22. #endif
  23. /**
  24. * This function will startup RT-Thread RTOS.
  25. */
  26. void rtthread_startup(void)
  27. {
  28. /* init board */
  29. rt_hw_board_init();
  30. /* show version */
  31. rt_show_version();
  32. /* init tick */
  33. rt_system_tick_init();
  34. /* init kernel object */
  35. rt_system_object_init();
  36. /* init timer system */
  37. rt_system_timer_init();
  38. #ifdef RT_USING_HEAP
  39. /* init memory system */
  40. rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
  41. #endif
  42. /* init scheduler system */
  43. rt_system_scheduler_init();
  44. /* init application */
  45. rt_application_init();
  46. #ifdef RT_USING_FINSH
  47. /* init finsh */
  48. finsh_system_init();
  49. #ifdef RT_USING_DEVICE
  50. finsh_set_device("uart1");
  51. #endif
  52. #endif
  53. /* init timer thread */
  54. rt_system_timer_thread_init();
  55. /* init idle thread */
  56. rt_thread_idle_init();
  57. /* start scheduler */
  58. rt_system_scheduler_start();
  59. /* never reach here */
  60. return ;
  61. }
  62. int main(void)
  63. {
  64. /* disable interrupt first */
  65. rt_hw_interrupt_disable();
  66. /* startup RT-Thread RTOS */
  67. rtthread_startup();
  68. return 0;
  69. }