startup.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2011-05-23 aozima first implementation for PIC32.
  9. */
  10. // Adds support for PIC32 Peripheral library functions and macros
  11. #include <plib.h>
  12. #include <rtthread.h>
  13. extern int _ramfunc_end;
  14. #define PIC32_SRAM_END (0xA0000000 + 1024UL*128) //795F512L 512K FLASH 128KB SRAM
  15. #ifdef RT_USING_FINSH
  16. extern int finsh_system_init(void);
  17. extern void finsh_set_device(const char* device);
  18. #endif
  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. /* init application */
  41. rt_application_init();
  42. #ifdef RT_USING_FINSH
  43. /* init finsh */
  44. finsh_system_init();
  45. #ifdef RT_USING_DEVICE
  46. finsh_set_device("uart1");
  47. #endif
  48. #endif
  49. /* init timer thread */
  50. rt_system_timer_thread_init();
  51. /* init idle thread */
  52. rt_thread_idle_init();
  53. /* start scheduler */
  54. rt_system_scheduler_start();
  55. /* never reach here */
  56. return ;
  57. }
  58. int main(void)
  59. {
  60. /* disable interrupt first */
  61. rt_hw_interrupt_disable();
  62. /* startup RT-Thread RTOS */
  63. rtthread_startup();
  64. return 0;
  65. }