application.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. */
  14. /**
  15. * @addtogroup STM32
  16. */
  17. /*@{*/
  18. #include <board.h>
  19. #include <rtthread.h>
  20. #ifdef RT_USING_LWIP
  21. #include <lwip/sys.h>
  22. #include <lwip/api.h>
  23. #include <netif/ethernetif.h>
  24. #endif
  25. void rt_init_thread_entry(void* parameter)
  26. {
  27. /* LwIP Initialization */
  28. #ifdef RT_USING_LWIP
  29. {
  30. extern void lwip_sys_init(void);
  31. /* register ethernetif device */
  32. eth_system_device_init();
  33. #ifdef STM32F10X_CL
  34. rt_hw_stm32_eth_init();
  35. #else
  36. /* STM32F103 */
  37. #if STM32_ETH_IF == 0
  38. rt_hw_enc28j60_init();
  39. #elif STM32_ETH_IF == 1
  40. rt_hw_dm9000_init();
  41. #endif
  42. #endif
  43. /* re-init device driver */
  44. rt_device_init_all();
  45. /* init lwip system */
  46. lwip_sys_init();
  47. rt_kprintf("TCP/IP initialized!\n");
  48. }
  49. #endif
  50. }
  51. int rt_application_init()
  52. {
  53. rt_thread_t init_thread;
  54. #if (RT_THREAD_PRIORITY_MAX == 32)
  55. init_thread = rt_thread_create("init",
  56. rt_init_thread_entry, RT_NULL,
  57. 2048, 8, 20);
  58. #else
  59. init_thread = rt_thread_create("init",
  60. rt_init_thread_entry, RT_NULL,
  61. 2048, 80, 20);
  62. #endif
  63. if (init_thread != RT_NULL)
  64. rt_thread_startup(init_thread);
  65. return 0;
  66. }
  67. /*@}*/