startup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. * 2013-11-15 bright modify for stm32f0xx version and components initial
  14. */
  15. #include <rthw.h>
  16. #include <rtthread.h>
  17. #include "board.h"
  18. /**
  19. * @addtogroup STM32
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef __CC_ARM
  24. extern int Image$$RW_IRAM1$$ZI$$Limit;
  25. #define STM32_SRAM_BEGIN (&Image$$RW_IRAM1$$ZI$$Limit)
  26. #elif __ICCARM__
  27. #pragma section="HEAP"
  28. #define STM32_SRAM_BEGIN (__segment_end("HEAP"))
  29. #else
  30. extern int __bss_end;
  31. #define STM32_SRAM_BEGIN (&__bss_end)
  32. #endif
  33. /*******************************************************************************
  34. * Function Name : assert_failed
  35. * Description : Reports the name of the source file and the source line number
  36. * where the assert error has occurred.
  37. * Input : - file: pointer to the source file name
  38. * - line: assert error line source number
  39. * Output : None
  40. * Return : None
  41. *******************************************************************************/
  42. void assert_failed(uint8_t* file, uint32_t line)
  43. {
  44. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  45. rt_kprintf(" file %s\r\n", file);
  46. rt_kprintf(" line %d\r\n", line);
  47. while (1) ;
  48. }
  49. /**
  50. * This function will startup RT-Thread RTOS.
  51. */
  52. void rtthread_startup(void)
  53. {
  54. /* init board */
  55. rt_hw_board_init();
  56. /* show version */
  57. rt_show_version();
  58. /* init tick */
  59. rt_system_tick_init();
  60. /* init kernel object */
  61. rt_system_object_init();
  62. /* init timer system */
  63. rt_system_timer_init();
  64. #ifdef RT_USING_HEAP
  65. rt_system_heap_init((void*)STM32_SRAM_BEGIN, (void*)STM32_SRAM_END);
  66. #endif
  67. /* init scheduler system */
  68. rt_system_scheduler_init();
  69. /* init application */
  70. rt_application_init();
  71. /* init timer thread */
  72. rt_system_timer_thread_init();
  73. /* init idle thread */
  74. rt_thread_idle_init();
  75. /* start scheduler */
  76. rt_system_scheduler_start();
  77. /* never reach here */
  78. return ;
  79. }
  80. int main(void)
  81. {
  82. /* disable interrupt first */
  83. rt_hw_interrupt_disable();
  84. /* startup RT-Thread RTOS */
  85. rtthread_startup();
  86. return 0;
  87. }
  88. /*@}*/