application.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. rt_device_t lcd;
  33. /* GDB STUB */
  34. #ifdef RT_USING_GDB
  35. gdb_set_device("uart6");
  36. gdb_start();
  37. #endif
  38. /* LwIP Initialization */
  39. #ifdef RT_USING_LWIP
  40. {
  41. extern void lwip_sys_init(void);
  42. /* register ethernetif device */
  43. eth_system_device_init();
  44. rt_hw_stm32_eth_init();
  45. /* init lwip system */
  46. lwip_sys_init();
  47. rt_kprintf("TCP/IP initialized!\n");
  48. }
  49. #endif
  50. #ifdef RT_USING_FINSH
  51. finsh_system_init();
  52. #endif
  53. lcd = rt_device_find("lcd");
  54. rtgui_graphic_set_device(lcd);
  55. rt_gui_demo_init();
  56. }
  57. int rt_application_init()
  58. {
  59. rt_thread_t tid;
  60. tid = rt_thread_create("init",
  61. rt_init_thread_entry, RT_NULL,
  62. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  63. if (tid != RT_NULL)
  64. rt_thread_startup(tid);
  65. return 0;
  66. }
  67. /*@}*/