main.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #include "gd32f4xx_libopt.h"
  2. #include "bsp_enet.h"
  3. #include "bsp_print.h"
  4. #include "bsp_flash.h"
  5. #include "bsp_rtc.h"
  6. #include "bsp_cas.h"
  7. #include "bsp_ctrl.h"
  8. #include "bsp_sensor.h"
  9. #include "bsp_lcd.h"
  10. #include "systick.h"
  11. #include "FreeRTOS.h"
  12. #include "task.h"
  13. #include "arch/netconf.h"
  14. #include "lfs_file.h"
  15. #include "modbus.h"
  16. #include "power.h"
  17. #include "snmp.h"
  18. #include "paras.h"
  19. #include "sensor.h"
  20. #include "beep.h"
  21. #include "cascade.h"
  22. #include "web.h"
  23. #include "menu.h"
  24. typedef uint8_t u8;
  25. #define START_TASK_PRIO 4 /* 任务优先级 */
  26. #define START_STK_SIZE 256 /* 任务堆栈大小 */
  27. TaskHandle_t StartTask_Handler; /* 任务句柄 */
  28. void start_task(void *pvParameters); /* 任务函数 */
  29. #define LWIP_DMEO_TASK_PRIO 5 /* 任务优先级 */
  30. #define LWIP_DMEO_STK_SIZE 2048 /* 任务堆栈大小 */
  31. TaskHandle_t LWIP_Task_Handler; /* 任务句柄 */
  32. void lwip_demo_task(void *pvParameters); /* 任务函数 */
  33. int main(void)
  34. {
  35. __IO int i = 0;
  36. nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);
  37. systick_config();
  38. bsp_print_init(115200);
  39. // bsp_rtc_init();
  40. // bsp_ctrl_init();
  41. // bsp_sensor_init();
  42. // bsp_lcd_init();
  43. // enet_phy_init();
  44. rcu_periph_clock_enable(RCU_GPIOE);
  45. gpio_mode_set(GPIOE, GPIO_MODE_OUTPUT, GPIO_PUPD_PULLUP,GPIO_PIN_6);
  46. gpio_output_options_set(GPIOE, GPIO_OTYPE_PP, GPIO_OSPEED_MAX, GPIO_PIN_6);
  47. gpio_bit_set(GPIOE,GPIO_PIN_6);
  48. W25qxx_Init();
  49. /* start_task任务 */
  50. xTaskCreate((TaskFunction_t )start_task,
  51. (const char * )"start_task",
  52. (uint16_t )START_STK_SIZE,
  53. (void * )NULL,
  54. (UBaseType_t )START_TASK_PRIO,
  55. (TaskHandle_t * )&StartTask_Handler);
  56. vTaskStartScheduler(); /* 开启任务调度 */
  57. while(1)
  58. {
  59. i ++;
  60. }
  61. return 0;
  62. }
  63. void start_task(void *pvParameters)
  64. {
  65. taskENTER_CRITICAL();
  66. xTaskCreate((TaskFunction_t )lwip_demo_task,
  67. (const char* )"lwip_demo_task",
  68. (uint16_t )LWIP_DMEO_STK_SIZE,
  69. (void* )NULL,
  70. (UBaseType_t )LWIP_DMEO_TASK_PRIO,
  71. (TaskHandle_t* )&LWIP_Task_Handler);
  72. vTaskDelete(StartTask_Handler);
  73. taskEXIT_CRITICAL();
  74. }
  75. void lwip_demo_task(void *pvParameters)
  76. {
  77. int i = 0;
  78. l_file_init();
  79. while(1)
  80. {
  81. i++;
  82. if(i % 2 == 0)
  83. {
  84. gpio_bit_reset(GPIOE,GPIO_PIN_6);
  85. }else
  86. {
  87. gpio_bit_set(GPIOE,GPIO_PIN_6);
  88. }
  89. vTaskDelay(1000);
  90. }
  91. vTaskDelete( LWIP_Task_Handler );
  92. }