startup.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 "board.h"
  17. #include "rtc.h"
  18. #ifdef RT_USING_LWIP
  19. #include <netif/ethernetif.h>
  20. #include "enc28j60.h"
  21. #endif
  22. /**
  23. * @addtogroup STM32
  24. */
  25. /*@{*/
  26. #ifdef RT_USING_FINSH
  27. extern void finsh_system_init(void);
  28. extern void finsh_set_device(char* device);
  29. #endif
  30. extern int rt_application_init(void);
  31. #ifdef __CC_ARM
  32. extern int Image$$RW_IRAM1$$ZI$$Limit;
  33. #elif __ICCARM__
  34. #pragma section="HEAP"
  35. #else
  36. extern int __bss_end;
  37. #endif
  38. extern rt_err_t wm8753_hw_init(void);
  39. #ifdef DEBUG
  40. /*******************************************************************************
  41. * Function Name : assert_failed
  42. * Description : Reports the name of the source file and the source line number
  43. * where the assert error has occurred.
  44. * Input : - file: pointer to the source file name
  45. * - line: assert error line source number
  46. * Output : None
  47. * Return : None
  48. *******************************************************************************/
  49. void assert_failed(u8* file, u32 line)
  50. {
  51. rt_kprintf("\n\r Wrong parameter value detected on\r\n");
  52. rt_kprintf(" file %s\r\n", file);
  53. rt_kprintf(" line %d\r\n", line);
  54. while (1) ;
  55. }
  56. #endif
  57. /**
  58. * This function will startup RT-Thread RTOS.
  59. */
  60. void rtthread_startup(void)
  61. {
  62. /* init board */
  63. rt_hw_board_init();
  64. /* show version */
  65. rt_show_version();
  66. /* init tick */
  67. rt_system_tick_init();
  68. /* init kernel object */
  69. rt_system_object_init();
  70. /* init timer system */
  71. rt_system_timer_init();
  72. #ifdef RT_USING_HEAP
  73. #ifdef RT_USING_SRAM
  74. rt_system_heap_init((void*)0x68000000, (void*)0x68080000);
  75. #else
  76. #ifdef __CC_ARM
  77. rt_system_heap_init((void*)&Image$$RW_IRAM1$$ZI$$Limit, (void*)0x20010000);
  78. #elif __ICCARM__
  79. rt_system_heap_init(__segment_end("HEAP"), (void*)0x20010000);
  80. #else
  81. /* init memory system */
  82. rt_system_heap_init((void*)&__bss_end, (void*)0x20010000);
  83. #endif
  84. #endif
  85. #endif
  86. /* init scheduler system */
  87. rt_system_scheduler_init();
  88. #ifdef RT_USING_LWIP
  89. eth_system_device_init();
  90. /* register ethernetif device */
  91. rt_hw_enc28j60_init();
  92. #endif
  93. rt_hw_rtc_init();
  94. wm8753_hw_init();
  95. /* init hardware serial device */
  96. rt_hw_usart_init();
  97. #ifdef RT_USING_DFS
  98. rt_hw_sdcard_init();
  99. #endif
  100. /* init all device */
  101. rt_device_init_all();
  102. /* init application */
  103. rt_application_init();
  104. #ifdef RT_USING_FINSH
  105. /* init finsh */
  106. finsh_system_init();
  107. #ifdef RT_USING_DEVICE
  108. finsh_set_device("uart1");
  109. #endif
  110. #endif
  111. /* init idle thread */
  112. rt_thread_idle_init();
  113. /* start scheduler */
  114. rt_system_scheduler_start();
  115. /* never reach here */
  116. return ;
  117. }
  118. int main(void)
  119. {
  120. rt_uint32_t UNUSED level;
  121. /* disable interrupt first */
  122. level = rt_hw_interrupt_disable();
  123. rtthread_startup();
  124. return 0;
  125. }
  126. /*@}*/