application.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * File : application.c
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2009, 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. * 2010-03-04 Magicoe for LPC1766 version
  14. * 2010-05-02 Aozima add led function
  15. * 2010-05-24 Bernard add filesystem initialization and move led function to led.c
  16. */
  17. #include <rtthread.h>
  18. #ifdef RT_USING_DFS
  19. /* dfs init */
  20. #include <dfs_init.h>
  21. /* dfs filesystem:ELM FatFs filesystem init */
  22. #include <dfs_elm.h>
  23. /* dfs Filesystem APIs */
  24. #include <dfs_fs.h>
  25. #endif
  26. #ifdef RT_USING_LWIP
  27. #include <lwip/sys.h>
  28. #include <lwip/api.h>
  29. #include <netif/ethernetif.h>
  30. #endif
  31. /* thread phase init */
  32. void rt_init_thread_entry(void *parameter)
  33. {
  34. /* Filesystem Initialization */
  35. #ifdef RT_USING_DFS
  36. {
  37. /* init the device filesystem */
  38. dfs_init();
  39. /* init the elm FAT filesystam*/
  40. elm_init();
  41. /* mount sd card fat partition 1 as root directory */
  42. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  43. rt_kprintf("File System initialized!\n");
  44. else
  45. rt_kprintf("File System init failed!\n");
  46. }
  47. #endif
  48. /* LwIP Initialization */
  49. #ifdef RT_USING_LWIP
  50. {
  51. extern void lwip_sys_init(void);
  52. extern void lpc17xx_emac_hw_init(void);
  53. eth_system_device_init();
  54. /* register Ethernet interface device */
  55. lpc17xx_emac_hw_init();
  56. /* init all device */
  57. rt_device_init_all();
  58. /* init lwip system */
  59. lwip_sys_init();
  60. rt_kprintf("TCP/IP initialized!\n");
  61. }
  62. #endif
  63. }
  64. int rt_application_init()
  65. {
  66. rt_thread_t tid;
  67. tid = rt_thread_create("init",
  68. rt_init_thread_entry, RT_NULL,
  69. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  70. if (tid != RT_NULL) rt_thread_startup(tid);
  71. return 0;
  72. }