application.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. * 2014-04-27 Bernard make code cleanup.
  14. */
  15. #include <board.h>
  16. #include <rtthread.h>
  17. #include <finsh.h>
  18. #ifdef RT_USING_GUIENGINE
  19. #include "rtgui_demo.h"
  20. #include <rtgui/driver.h>
  21. #endif
  22. #include <gd32f4xx.h>
  23. void gd_eval_led_init (void)
  24. {
  25. /* enable the led clock */
  26. rcu_periph_clock_enable(RCU_GPIOD);
  27. /* configure led GPIO port */
  28. gpio_mode_set(GPIOD, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE,GPIO_PIN_4);
  29. gpio_output_options_set(GPIOD, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,GPIO_PIN_4);
  30. GPIO_BC(GPIOD) = GPIO_PIN_4;
  31. }
  32. void rt_init_thread_entry(void* parameter)
  33. {
  34. /* initialization RT-Thread Components */
  35. #ifdef RT_USING_COMPONENTS_INIT
  36. rt_components_init();
  37. #endif
  38. gd_eval_led_init();
  39. #ifdef RT_USING_GUIENGINE
  40. {
  41. rt_device_t device;
  42. device = rt_device_find("lcd");
  43. /* re-set graphic device */
  44. rtgui_graphic_set_device(device);
  45. rt_gui_demo_init();
  46. }
  47. #endif
  48. while(1)
  49. {
  50. GPIO_TG(GPIOD) = GPIO_PIN_4;
  51. rt_thread_delay(RT_TICK_PER_SECOND);
  52. }
  53. }
  54. int rt_application_init()
  55. {
  56. rt_thread_t tid;
  57. tid = rt_thread_create("init",
  58. rt_init_thread_entry, RT_NULL,
  59. 2048, RT_THREAD_PRIORITY_MAX/3, 20);
  60. if (tid != RT_NULL)
  61. rt_thread_startup(tid);
  62. return 0;
  63. }