1
0

startup.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. * 2006-08-31 Bernard first implementation
  9. * 2017-07-29 Tanek modify for LPC8xx version
  10. */
  11. #include <stdint.h>
  12. #include <rthw.h>
  13. #include <rtthread.h>
  14. #include "board.h"
  15. /**
  16. * @addtogroup LPC8xx
  17. */
  18. /*@{*/
  19. extern int rt_application_init(void);
  20. /*******************************************************************************
  21. * Function Name : assert_failed
  22. * Description : Reports the name of the source file and the source line number
  23. * where the assert error has occurred.
  24. * Input : - file: pointer to the source file name
  25. * - line: assert error line source number
  26. * Output : None
  27. * Return : None
  28. *******************************************************************************/
  29. void assert_failed(uint8_t* file, uint32_t line)
  30. {
  31. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  32. rt_kprintf(" file %s\r\n", file);
  33. rt_kprintf(" line %d\r\n", line);
  34. while (1) ;
  35. }
  36. /**
  37. * This function will startup RT-Thread RTOS.
  38. */
  39. void rtthread_startup(void)
  40. {
  41. /* init board */
  42. rt_hw_board_init();
  43. /* show version */
  44. rt_show_version();
  45. /* init timer system */
  46. rt_system_timer_init();
  47. #ifdef RT_USING_HEAP
  48. rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
  49. #endif
  50. /* init scheduler system */
  51. rt_system_scheduler_init();
  52. /* init application */
  53. rt_application_init();
  54. /* init timer thread */
  55. rt_system_timer_thread_init();
  56. /* init idle thread */
  57. rt_thread_idle_init();
  58. /* start scheduler */
  59. rt_system_scheduler_start();
  60. /* never reach here */
  61. return ;
  62. }
  63. int main(void)
  64. {
  65. /* disable interrupt first */
  66. rt_hw_interrupt_disable();
  67. /* startup RT-Thread RTOS */
  68. rtthread_startup();
  69. return 0;
  70. }
  71. /*@}*/