application.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /******************************************************************//**
  2. * @file application.c
  3. * @brief application tasks
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author Bernard, onelife
  6. * @version 0.4 beta
  7. **********************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file LICENSE in this
  10. * distribution or at http://www.rt-thread.org/license/LICENSE
  11. **********************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2009-01-05 Bernard first version
  15. * 2010-12-29 onelife Modify for EFM32
  16. *********************************************************************/
  17. /******************************************************************//**
  18. * @addtogroup cortex-m3
  19. * @{
  20. *********************************************************************/
  21. /* Includes -------------------------------------------------------------------*/
  22. #include <board.h>
  23. #ifdef RT_USING_DFS
  24. /* dfs init */
  25. #include <dfs_init.h>
  26. /* dfs filesystem:ELM filesystem init */
  27. #include <dfs_elm.h>
  28. /* dfs Filesystem APIs */
  29. #include <dfs_fs.h>
  30. #endif
  31. #ifdef RT_USING_LWIP
  32. #include <lwip/sys.h>
  33. #include <lwip/api.h>
  34. #include <netif/ethernetif.h>
  35. #endif
  36. /* Private typedef -------------------------------------------------------------*/
  37. /* Private define --------------------------------------------------------------*/
  38. /* Private macro --------------------------------------------------------------*/
  39. /* Private variables ------------------------------------------------------------*/
  40. rt_uint32_t rt_system_status = 0;
  41. /* Private function prototypes ---------------------------------------------------*/
  42. /* Private functions ------------------------------------------------------------*/
  43. void rt_led_thread_entry(void* parameter)
  44. {
  45. // rt_uint8_t n = 0;
  46. rt_hw_led_on(0);
  47. rt_hw_led_on(1);
  48. rt_hw_led_on(2);
  49. rt_hw_led_on(3);
  50. // while(1)
  51. // {
  52. /* light on leds for one second */
  53. // rt_hw_led_toggle(n++);
  54. // if (n == 4)
  55. // n =0;
  56. // rt_thread_delay(200);
  57. // }
  58. }
  59. int rt_application_init()
  60. {
  61. rt_thread_t led_thread;
  62. /* Initialize all device drivers (dev_?.c) */
  63. if (rt_hw_led_init() != RT_EOK)
  64. {
  65. rt_kprintf("*** Failed to initialize LED driver!");
  66. while(1); //Or do something?
  67. }
  68. if (rt_hw_misc_init() != RT_EOK)
  69. {
  70. rt_kprintf("*** Failed to miscellaneous driver!");
  71. while(1); //Or do something?
  72. }
  73. #if (RT_THREAD_PRIORITY_MAX == 32)
  74. led_thread = rt_thread_create(
  75. "led",
  76. rt_led_thread_entry,
  77. RT_NULL,
  78. 256,
  79. 3,
  80. 20);
  81. #else
  82. #endif
  83. if(led_thread != RT_NULL)
  84. {
  85. rt_kprintf("led sp:%x\n", led_thread->sp);
  86. rt_thread_startup(led_thread);
  87. }
  88. return 0;
  89. }
  90. /******************************************************************//**
  91. * @}
  92. *********************************************************************/