application.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006, RT-Thread Development 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://www.rt-thread.org/license/LICENSE
  9. *
  10. * Change Logs:
  11. * Date Author Notes
  12. * 2009-01-05 Bernard the first version
  13. * 2014-04-27 Bernard make code cleanup.
  14. */
  15. #include <board.h>
  16. #include <rtthread.h>
  17. #ifdef RT_USING_FINSH
  18. #include <shell.h>
  19. #include <finsh.h>
  20. #endif
  21. #ifdef RT_USING_LWIP
  22. #include <lwip/sys.h>
  23. #include <lwip/api.h>
  24. #include <netif/ethernetif.h>
  25. #include "stm32f4xx_eth.h"
  26. #endif
  27. #ifdef RT_USING_GDB
  28. #include <gdb_stub.h>
  29. #endif
  30. void rt_init_thread_entry(void* parameter)
  31. {
  32. /* GDB STUB */
  33. #ifdef RT_USING_GDB
  34. gdb_set_device("uart6");
  35. gdb_start();
  36. #endif
  37. /* LwIP Initialization */
  38. #ifdef RT_USING_LWIP
  39. {
  40. extern void lwip_sys_init(void);
  41. /* register ethernetif device */
  42. eth_system_device_init();
  43. rt_hw_stm32_eth_init();
  44. /* init lwip system */
  45. lwip_sys_init();
  46. rt_kprintf("TCP/IP initialized!\n");
  47. }
  48. #endif
  49. #ifdef RT_USING_FINSH
  50. finsh_system_init();
  51. #endif
  52. }
  53. int rt_application_init()
  54. {
  55. rt_thread_t tid;
  56. tid = rt_thread_create("init",
  57. rt_init_thread_entry, RT_NULL,
  58. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  59. if (tid != RT_NULL)
  60. rt_thread_startup(tid);
  61. return 0;
  62. }
  63. /*@}*/