application.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. * 2012-04-15 Bernard enable components_init.
  17. */
  18. #include <rtthread.h>
  19. #include "platform.h"
  20. #ifdef RT_USING_COMPONENTS_INIT
  21. #include <components_init.h>
  22. #endif
  23. #ifdef RT_USING_LWIP
  24. #include <emac.h>
  25. #endif
  26. #ifdef RT_USING_DFS
  27. #include <dfs_fs.h>
  28. #endif
  29. /* thread phase init */
  30. void rt_init_thread_entry(void *parameter)
  31. {
  32. /* initialize platform */
  33. platform_init();
  34. #ifdef RT_USING_LWIP
  35. /* register Ethernet interface device */
  36. lpc17xx_emac_hw_init();
  37. #endif
  38. #ifdef RT_USING_COMPONENTS_INIT
  39. /* initialization RT-Thread Components */
  40. rt_components_init();
  41. #endif
  42. /* Filesystem Initialization */
  43. #ifdef RT_USING_DFS
  44. /* mount sd card fat partition 1 as root directory */
  45. if (dfs_mount("sd0", "/", "elm", 0, 0) == 0)
  46. rt_kprintf("File System initialized!\n");
  47. else
  48. rt_kprintf("File System init failed!\n");
  49. #endif
  50. }
  51. int rt_application_init()
  52. {
  53. rt_thread_t tid;
  54. tid = rt_thread_create("init",
  55. rt_init_thread_entry, RT_NULL,
  56. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  57. if (tid != RT_NULL) rt_thread_startup(tid);
  58. return 0;
  59. }