startup.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. #include "stm32f10x.h"
  17. #include "board.h"
  18. /**
  19. * @addtogroup STM32
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  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. /* init board */
  47. rt_hw_board_init();
  48. /* show version */
  49. rt_show_version();
  50. /* init tick */
  51. rt_system_tick_init();
  52. /* init kernel object */
  53. rt_system_object_init();
  54. /* init timer system */
  55. rt_system_timer_init();
  56. /* init scheduler system */
  57. rt_system_scheduler_init();
  58. /* init application */
  59. rt_application_init();
  60. /* init idle thread */
  61. rt_thread_idle_init();
  62. /* start scheduler */
  63. rt_system_scheduler_start();
  64. /* never reach here */
  65. return ;
  66. }
  67. int main(void)
  68. {
  69. rt_uint32_t UNUSED level;
  70. /* disable interrupt first */
  71. level = rt_hw_interrupt_disable();
  72. /* init system setting */
  73. SystemInit();
  74. /* startup RT-Thread RTOS */
  75. rtthread_startup();
  76. return 0;
  77. }
  78. /*@}*/