application.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /**
  18. * @addtogroup LPC17
  19. */
  20. /*@{*/
  21. #include <rtthread.h>
  22. #ifdef RT_USING_DFS
  23. /* dfs init */
  24. #include <dfs_init.h>
  25. /* dfs filesystem:ELM FatFs filesystem init */
  26. #include <dfs_elm.h>
  27. /* dfs Filesystem APIs */
  28. #include <dfs_fs.h>
  29. #endif
  30. #ifdef RT_USING_LWIP
  31. #include <lwip/sys.h>
  32. #include <lwip/api.h>
  33. #include <netif/ethernetif.h>
  34. #endif
  35. /* thread phase init */
  36. void rt_init_thread_entry(void *parameter)
  37. {
  38. /* Filesystem Initialization */
  39. #ifdef RT_USING_DFS
  40. {
  41. /* init the device filesystem */
  42. dfs_init();
  43. /* init the elm FAT filesystam*/
  44. elm_init();
  45. /* mount sd card fat partition 1 as root directory */
  46. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  47. rt_kprintf("File System initialized!\n");
  48. else
  49. rt_kprintf("File System init failed!\n");
  50. }
  51. #endif
  52. /* LwIP Initialization */
  53. #ifdef RT_USING_LWIP
  54. {
  55. extern void lwip_sys_init(void);
  56. extern void lpc17xx_emac_hw_init(void);
  57. eth_system_device_init();
  58. /* register ethernetif device */
  59. lpc17xx_emac_hw_init();
  60. /* init all device */
  61. rt_device_init_all();
  62. /* init lwip system */
  63. lwip_sys_init();
  64. rt_kprintf("TCP/IP initialized!\n");
  65. }
  66. #endif
  67. }
  68. int rt_application_init()
  69. {
  70. rt_thread_t init_thread;
  71. #if (RT_THREAD_PRIORITY_MAX == 32)
  72. init_thread = rt_thread_create("init",
  73. rt_init_thread_entry, RT_NULL,
  74. 2048, 8, 20);
  75. #else
  76. init_thread = rt_thread_create("init",
  77. rt_init_thread_entry, RT_NULL,
  78. 2048, 80, 20);
  79. #endif
  80. if (init_thread != RT_NULL) rt_thread_startup(init_thread);
  81. return 0;
  82. }
  83. /*@}*/