startup.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. * 2009-01-05 Bernard first implementation
  9. * 2010-03-04 Magicoe for LPC17xx
  10. */
  11. #include <rthw.h>
  12. #include <rtthread.h>
  13. #include "LPC177x_8x.h"
  14. #include "board.h"
  15. extern int rt_application_init(void);
  16. #ifdef __CC_ARM
  17. extern int Image$$RW_IRAM1$$ZI$$Limit;
  18. #elif __ICCARM__
  19. #pragma section="HEAP"
  20. #else
  21. extern int __bss_end;
  22. #endif
  23. #ifdef DEBUG
  24. /*******************************************************************************
  25. * Function Name : assert_failed
  26. * Description : Reports the name of the source file and the source line number
  27. * where the assert error has occurred.
  28. * Input : - file: pointer to the source file name
  29. * - line: assert error line source number
  30. * Output : None
  31. * Return : None
  32. *******************************************************************************/
  33. void assert_failed(u8* file, u32 line)
  34. {
  35. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  36. rt_kprintf(" file %s\r\n", file);
  37. rt_kprintf(" line %d\r\n", line);
  38. while (1) ;
  39. }
  40. #endif
  41. /**
  42. * This function will startup RT-Thread RTOS.
  43. */
  44. void rtthread_startup(void)
  45. {
  46. /* initialize board */
  47. rt_hw_board_init();
  48. /* show version */
  49. rt_show_version();
  50. #ifdef RT_USING_HEAP
  51. /* initialize memory system */
  52. #ifdef __CC_ARM
  53. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)(0x10000000 + 1024*64));
  54. #elif __ICCARM__
  55. rt_system_heap_init(__segment_end("HEAP"), (void*)(0x10000000 + 1024*64));
  56. #else
  57. rt_system_heap_init((void*)&__bss_end, (void*)(0x10000000 + 1024*64));
  58. #endif
  59. #endif
  60. /* initialize scheduler system */
  61. rt_system_scheduler_init();
  62. /* initialize application */
  63. rt_application_init();
  64. /* initialize timer */
  65. rt_system_timer_init();
  66. /* initialize timer thread */
  67. rt_system_timer_thread_init();
  68. /* initialize idle thread */
  69. rt_thread_idle_init();
  70. /* start scheduler */
  71. rt_system_scheduler_start();
  72. /* never reach here */
  73. return ;
  74. }
  75. int main(void)
  76. {
  77. /* disable interrupt first */
  78. rt_hw_interrupt_disable();
  79. /* startup RT-Thread RTOS */
  80. rtthread_startup();
  81. return 0;
  82. }