论坛元老
- 积分
- 10652
- 金钱
- 10652
- 注册时间
- 2017-4-14
- 在线时间
- 2780 小时
|
发表于 2022-12-7 18:01:40
|
显示全部楼层
- #include "Temp1_Task.h"
-
- void Temp1_Task(void *pvParameters); //任务函数
- #define Temp1_Task_Size (100)//任务堆栈大小
- #define Temp1_Task_Prio 1//任务优先级
- TaskHandle_t Temp1_Task_Handler; //任务句柄
-
- QueueHandle_t Test_Queue_Handler; //消息队列句柄
- #define Test_Queue_Handler_Num 100//消息队列的长度
- #define Test_Queue_Handler_Len 1//消息队列的字节数 byte
- void Temp1_Task_Start(void)
- {
- BaseType_t xReturn;
- Test_Queue_Handler=xQueueCreate(Test_Queue_Handler_Num,Test_Queue_Handler_Len);
- xReturn=xTaskCreate((TaskFunction_t )Temp1_Task,
- (const char* )"Temp1_Task",
- (uint16_t )Temp1_Task_Size,
- (void* )NULL,
- (UBaseType_t )Temp1_Task_Prio,
- (TaskHandle_t* )&Temp1_Task_Handler);
- if(xReturn==pdPASS)
- {
- FreeRtos_printf("Success Create Temp1_Task ...\r\n");
- }
- else
- {
- FreeRtos_printf("Failure Create Temp1_Task ...\r\n");
- while(1){};
- }
- }
- void Temp1_Task(void *pvParameters)
- {
- TickType_t xLastWakeTime = xTaskGetTickCount();
- u8 haha=0;
- BaseType_t err;
- while(1)
- {
- if(Test_Queue_Handler!=NULL)
- {
- err=xQueueSend(Test_Queue_Handler,(const void * const)&haha,( TickType_t ) 0);
- FreeRtos_printf("Temp1_Task=%d\r\n",haha);
- haha++;
- }
-
- vTaskDelayUntil(&xLastWakeTime,100);//vTaskDelay(1000);
- }
- }
-
复制代码- #include "Temp2_Task.h"
-
- void Temp2_Task(void *pvParameters); //任务函数
- #define Temp2_Task_Size (100)//任务堆栈大小
- #define Temp2_Task_Prio 1//任务优先级
- TaskHandle_t Temp2_Task_Handler; //任务句柄
-
- void Temp2_Task_Start(void)
- {
- BaseType_t xReturn;
-
- xReturn=xTaskCreate((TaskFunction_t )Temp2_Task,
- (const char* )"Temp2_Task",
- (uint16_t )Temp2_Task_Size,
- (void* )NULL,
- (UBaseType_t )Temp2_Task_Prio,
- (TaskHandle_t* )&Temp2_Task_Handler);
- if(xReturn==pdPASS)
- {
- FreeRtos_printf("Success Create Temp2_Task ...\r\n");
- }
- else
- {
- FreeRtos_printf("Failure Create Temp2_Task ...\r\n");
- while(1){};
- }
- }
- extern QueueHandle_t Test_Queue_Handler;
- void Temp2_Task(void *pvParameters)
- {
- BaseType_t err;
- u8 key=0;
-
- while(1)
- {
- if(Test_Queue_Handler!=NULL)
- {
- err=xQueueReceive(Test_Queue_Handler,&key,portMAX_DELAY);
- if(err==pdTRUE)
- {
- FreeRtos_printf("Temp2_Task=%d\r\n",key);
- }
- }
-
- vTaskDelay(1000);//vTaskDelay(1000)
- }
- }
-
复制代码- #include "Temp3_Task.h"
-
- void Temp3_Task(void *pvParameters); //任务函数
- #define Temp3_Task_Size (100)//任务堆栈大小
- #define Temp3_Task_Prio 1//任务优先级
- TaskHandle_t Temp3_Task_Handler; //任务句柄
-
- void Temp3_Task_Start(void)
- {
- BaseType_t xReturn;
-
- xReturn=xTaskCreate((TaskFunction_t )Temp3_Task,
- (const char* )"Temp3_Task",
- (uint16_t )Temp3_Task_Size,
- (void* )NULL,
- (UBaseType_t )Temp3_Task_Prio,
- (TaskHandle_t* )&Temp3_Task_Handler);
- if(xReturn==pdPASS)
- {
- FreeRtos_printf("Success Create Temp3_Task ...\r\n");
- }
- else
- {
- FreeRtos_printf("Failure Create Temp3_Task ...\r\n");
- while(1){};
- }
- }
- extern QueueHandle_t Test_Queue_Handler;
- void Temp3_Task(void *pvParameters)
- {
- BaseType_t err;
- u8 key=0;
-
- while(1)
- {
- if(Test_Queue_Handler!=NULL)
- {
- err=xQueueReceive(Test_Queue_Handler,&key,portMAX_DELAY);
- if(err==pdTRUE)
- {
- FreeRtos_printf("Temp3_Task=%d\r\n",key);
- }
- }
-
- vTaskDelay(1000);//vTaskDelay(1000)
- }
- }
-
复制代码
|
|