startup.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * File : startup.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Develop 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://openlab.rt-thread.com/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2006-08-31 Bernard first implementation
  13. */
  14. #include <rthw.h>
  15. #include <rtthread.h>
  16. #ifdef RT_USING_COMPONENTS_INIT
  17. #include <components.h>
  18. #endif /* RT_USING_COMPONENTS_INIT */
  19. #include "board.h"
  20. extern int rt_application_init(void); // define in application/application.c
  21. #ifdef __CC_ARM
  22. extern int Image$$RW_IRAM1$$ZI$$Limit;
  23. #elif __ICCARM__
  24. #pragma section="HEAP"
  25. #else
  26. extern int __bss_end;
  27. extern int _stack;
  28. #endif
  29. /*******************************************************************************
  30. * Function Name : assert_failed
  31. * Description : Reports the name of the source file and the source line number
  32. * where the assert error has occurred.
  33. * Input : - file: pointer to the source file name
  34. * - line: assert error line source number
  35. * Output : None
  36. * Return : None
  37. *******************************************************************************/
  38. void assert_failed(char* file, int line)
  39. {
  40. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  41. rt_kprintf(" file %s\r\n", file);
  42. rt_kprintf(" line %d\r\n", line);
  43. while (1) ;
  44. }
  45. /**
  46. * This function will startup RT-Thread RTOS.
  47. */
  48. void rtthread_startup(void)
  49. {
  50. /* show version */
  51. rt_show_version();
  52. #ifdef RT_USING_HEAP
  53. #if STM32_EXT_SRAM
  54. rt_system_heap_init((void*)STM32_EXT_SRAM_BEGIN, (void*)STM32_EXT_SRAM_END);
  55. #else
  56. #ifdef __CC_ARM
  57. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)MXT_IRAM_END);
  58. #elif __ICCARM__
  59. rt_system_heap_init(__segment_end("HEAP"), (void*)STM32_SRAM_END);
  60. #else
  61. /* init memory system */
  62. rt_system_heap_init((void *)0x00250000, (void *)0x00280000);
  63. #endif
  64. #endif /* STM32_EXT_SRAM */
  65. #endif /* RT_USING_HEAP */
  66. #ifdef RT_USING_COMPONENTS_INIT
  67. rt_components_board_init();
  68. #endif
  69. /* init scheduler system */
  70. rt_system_scheduler_init();
  71. /* initialize timer */
  72. rt_system_timer_init();
  73. /* init timer thread */
  74. rt_system_timer_thread_init();
  75. /* init application */
  76. rt_application_init();
  77. /* init idle thread */
  78. rt_thread_idle_init();
  79. /* start scheduler */
  80. rt_system_scheduler_start();
  81. /* never reach here */
  82. return ;
  83. }
  84. //int main(void)
  85. //{
  86. // /* disable interrupt first */
  87. // rt_hw_interrupt_disable();
  88. //
  89. // /* startup RT-Thread RTOS */
  90. // rtthread_startup();
  91. //
  92. // return 0;
  93. //}
  94. /*@}*/