123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- #include "sys.h"
- #include "delay.h"
- #include "usart.h"
- #include "led.h"
- #include "relay.h"
- #include "pwm.h"
- #include <SIM_EEPROM.h>
- #include "All_define.h"
- #include "modbus.h"
- #include "lcd_task.h"
- #include "led_task.h"
- #include "zigbee_task.h"
- #include "key_task.h"
- #include "MB_RTU_task.h"
- #include "MB_RTU_deal_task.h"
- #include "relay_task.h"
- #include "uart.h"
- #include "./mcu_sdk/zigbee.h"
- #include "HT16C22.h"
- #define START_TASK_PRIO 1
- #define START_STK_SIZE 128
- TaskHandle_t StartTask_Handler;
- void start_task(void *pvParameters);
- #define LED_TASK_PRIO 3
- #define LED_STK_SIZE 256
- TaskHandle_t LEDTask_Handler;
- #define LCD_TASK_PRIO 4
- #define LCD_STK_SIZE 512
- TaskHandle_t LCDTask_Handler;
- #define ZIGBEE_TASK_PRIO 2
- #define ZIGBEE_STK_SIZE 512
- TaskHandle_t ZIGBEETask_Handler;
- #define KEY_TASK_PRIO 5
- #define KEY_STK_SIZE 512
- TaskHandle_t KEYTask_Handler;
- #define MB_RTU_TASK_PRIO 16
- #define MB_RTU_STK_SIZE 512
- TaskHandle_t MB_RTUTask_Handler;
- #define MB_RTU_deal_TASK_PRIO 8
- #define MB_RTU_deal_STK_SIZE 512
- TaskHandle_t MB_RTU_dealTask_Handler;
- #define Relay_TASK_PRIO 18
- #define Relay_STK_SIZE 512
- TaskHandle_t RELAYTask_Handler;
- void BSP_init(void )
- {
- gpio_uart_config();
- usart_config();
- MemData_init();
- delay_init();
- BSP_PWMOUT_Init();
- BSP_modbus(dis_page_param.face_plate_param.Device_BaudRate);
- Relay_Init();
-
- zigbee_protocol_init();
- //zigbee_uart_write_frame(NULL,0);
- }
- int main(void)
- {
- nvic_priority_group_set(NVIC_PRIGROUP_PRE4_SUB0);
- BSP_init();
- xTaskCreate((TaskFunction_t )start_task,
- (const char* )"start_task",
- (uint16_t )START_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )START_TASK_PRIO,
- (TaskHandle_t* )&StartTask_Handler);
- vTaskStartScheduler();
- }
- QueueHandle_t MB_RTU_Rx_Queue;
- QueueHandle_t MB_RTU_Tx_Queue;
- SemaphoreHandle_t modebus_tx_semap;
- void start_task(void *pvParameters)
- {
- taskENTER_CRITICAL();
- MB_RTU_Rx_Queue=xQueueCreate(7,140);
- MB_RTU_Tx_Queue=xQueueCreate(7,140);
- modebus_tx_semap=xSemaphoreCreateBinary();
- xTaskCreate((TaskFunction_t )zigbee_task,
- (const char* )"zigbee_task",
- (uint16_t )ZIGBEE_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )ZIGBEE_TASK_PRIO,
- (TaskHandle_t* )&ZIGBEETask_Handler);
- xTaskCreate((TaskFunction_t )led_task,
- (const char* )"led_task",
- (uint16_t )LED_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )LED_TASK_PRIO,
- (TaskHandle_t* )&LEDTask_Handler);
-
- xTaskCreate((TaskFunction_t )lcd_task,
- (const char* )"lcd_task",
- (uint16_t )LCD_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )LCD_TASK_PRIO,
- (TaskHandle_t* )&LCDTask_Handler);
-
- xTaskCreate((TaskFunction_t )key_task,
- (const char* )"key_task",
- (uint16_t )KEY_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )KEY_TASK_PRIO,
- (TaskHandle_t* )&KEYTask_Handler);
-
- xTaskCreate((TaskFunction_t )mb_rtu_task,
- (const char* )"mb_rtu_task",
- (uint16_t )MB_RTU_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )MB_RTU_TASK_PRIO,
- (TaskHandle_t* )&MB_RTUTask_Handler);
-
- xTaskCreate((TaskFunction_t )mb_rtu_deal_task,
- (const char* )"mb_rtu_deal_task",
- (uint16_t )MB_RTU_deal_STK_SIZE,
- (void* )NULL,
- (UBaseType_t )MB_RTU_deal_TASK_PRIO,
- (TaskHandle_t* )&MB_RTU_dealTask_Handler);
-
- xTaskCreate((TaskFunction_t )relay_task,
- (const char* )"mb_rtu_deal_task",
- (uint16_t )Relay_TASK_PRIO,
- (void* )NULL,
- (UBaseType_t )Relay_STK_SIZE,
- (TaskHandle_t* )&RELAYTask_Handler);
-
- vTaskDelete(StartTask_Handler);
- taskEXIT_CRITICAL();
- }
|