startup.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 <gd32f4xx.h>
  17. #include "board.h"
  18. /**
  19. * @addtogroup GD32F4xx
  20. */
  21. /*@{*/
  22. extern int rt_application_init(void);
  23. #ifdef RT_USING_FINSH
  24. extern int finsh_system_init(void);
  25. extern void finsh_set_device(const char* device);
  26. #endif
  27. /*******************************************************************************
  28. * Function Name : assert_failed
  29. * Description : Reports the name of the source file and the source line number
  30. * where the assert error has occurred.
  31. * Input : - file: pointer to the source file name
  32. * - line: assert error line source number
  33. * Output : None
  34. * Return : None
  35. *******************************************************************************/
  36. void assert_failed(uint8_t* file, uint32_t line)
  37. {
  38. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  39. rt_kprintf(" file %s\r\n", file);
  40. rt_kprintf(" line %d\r\n", line);
  41. while (1) ;
  42. }
  43. /**
  44. * This function will startup RT-Thread RTOS.
  45. */
  46. void rtthread_startup(void)
  47. {
  48. /* init board */
  49. rt_hw_board_init();
  50. /* show version */
  51. rt_show_version();
  52. /* init tick */
  53. rt_system_tick_init();
  54. /* init kernel object */
  55. rt_system_object_init();
  56. /* init timer system */
  57. rt_system_timer_init();
  58. #ifdef RT_USING_EXT_SDRAM
  59. rt_system_heap_init((void*)EXT_SDRAM_BEGIN, (void*)EXT_SDRAM_END);
  60. #else
  61. rt_system_heap_init((void*)HEAP_BEGIN, (void*)HEAP_END);
  62. #endif
  63. /* init scheduler system */
  64. rt_system_scheduler_init();
  65. /* init application */
  66. rt_application_init();
  67. /* init timer thread */
  68. rt_system_timer_thread_init();
  69. /* init idle thread */
  70. rt_thread_idle_init();
  71. /* start scheduler */
  72. rt_system_scheduler_start();
  73. /* never reach here */
  74. return ;
  75. }
  76. int main(void)
  77. {
  78. /* disable interrupt first */
  79. rt_hw_interrupt_disable();
  80. /* startup RT-Thread RTOS */
  81. rtthread_startup();
  82. return 0;
  83. }
  84. /*@}*/