startup.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 timer system */
  29. rt_system_timer_init();
  30. #ifdef RT_USING_HEAP
  31. /* init memory system */
  32. rt_system_heap_init((void*)&_ramfunc_end, (void*)PIC32_SRAM_END);
  33. #endif
  34. /* init scheduler system */
  35. rt_system_scheduler_init();
  36. /* init application */
  37. rt_application_init();
  38. #ifdef RT_USING_FINSH
  39. /* init finsh */
  40. finsh_system_init();
  41. #ifdef RT_USING_DEVICE
  42. finsh_set_device("uart1");
  43. #endif
  44. #endif
  45. /* init timer thread */
  46. rt_system_timer_thread_init();
  47. /* init idle thread */
  48. rt_thread_idle_init();
  49. /* start scheduler */
  50. rt_system_scheduler_start();
  51. /* never reach here */
  52. return ;
  53. }
  54. int main(void)
  55. {
  56. /* disable interrupt first */
  57. rt_hw_interrupt_disable();
  58. /* startup RT-Thread RTOS */
  59. rtthread_startup();
  60. return 0;
  61. }