startup.c 2.4 KB

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