📄 task.c
字号:
//******************************************************************************
// File Name : Task.c
// Author : Steaven
// Created : 2008-06-09
// Modified :
// Revision : V0.0
//******************************************************************************
#include "app.h"
//local function declaration
void Task1_Init(void);
void Task2_Init(void);
void Task3_Init(void);
void Task4_Init(void);
void Task1(void);
void Task2(void);
void Task3(void);
void Task4(void);
//******************************************************************************
// Function : Task1_Init
// Input : none
// Output : none
// Description : Initialization of task1,off LED1
//******************************************************************************
void Task1_Init(void)
{
LED_OFF(cLED1);
}
//******************************************************************************
// Function : Task2_Init
// Input : none
// Output : none
// Description : Initialization of task2,off LED2
//******************************************************************************
void Task2_Init(void)
{
LED_OFF(cLED2);
}
//******************************************************************************
// Function : Task3_Init
// Input : none
// Output : none
// Description : Initialization of task3,off LED3
//******************************************************************************
void Task3_Init(void)
{
LED_OFF(cLED3);
}
//******************************************************************************
// Function : Task4_Init
// Input : none
// Output : none
// Description : Initialization of task4,off LED4
//******************************************************************************
void Task4_Init(void)
{
LED_OFF(cLED4);
}
//******************************************************************************
// Function : Task1
// Input : none
// Output : none
// Description : Task1 process,Control LED1
//******************************************************************************
void Task1(void)
{
INT16U wTask_Event;
static INT8U bKey_Status = cOFF_Status;
while(1)
{
//task switch
if(OS_Task_Switch(cPrioTask1) == true)
{
return;
}
//get event
wTask_Event = OS_Event_Pend(cPrioTask1);
//event check
if(wTask_Event == 0)
{
return;
}
//event parsing : timer event
if(wTask_Event & (1 << eTask1_Timer))
{
if(bKey_Status == cOFF_Status)
{
LED_OFF(cLED1);
}
else if(bKey_Status == cON_Status)
{
LED_ON(cLED1);
}
else if(bKey_Status == cTOGGLE_Status)
{
LED_TOGGLE(cLED1);
}
}
//event parsing : key event
if(wTask_Event & (1 << eTask1_Key))
{
if(bKey_Status == cOFF_Status)
{
bKey_Status = cTOGGLE_Status;
}
else if(bKey_Status == cTOGGLE_Status)
{
bKey_Status = cOFF_Status;
}
else if(bKey_Status == cON_Status)
{
bKey_Status = cOFF_Status;
}
}
}
}
//******************************************************************************
// Function : Task2
// Input : none
// Output : none
// Description : Task2 process,Control LED2
//******************************************************************************
void Task2(void)
{
INT16U wTask_Event;
static INT8U bKey_Status = cOFF_Status;
while(1)
{
//task switch
if(OS_Task_Switch(cPrioTask2) == true)
{
return;
}
//get event
wTask_Event = OS_Event_Pend(cPrioTask2);
if(wTask_Event == 0)
{
return;
}
//event parsing : timer event
if(wTask_Event & (1 << eTask2_Timer))
{
if(bKey_Status == cOFF_Status)
{
LED_OFF(cLED2);
}
else if(bKey_Status == cON_Status)
{
LED_ON(cLED2);
}
else if(bKey_Status == cTOGGLE_Status)
{
LED_TOGGLE(cLED2);
}
}
//event parsing : key event
if(wTask_Event & (1 << eTask2_Key))
{
if(bKey_Status == cOFF_Status)
{
bKey_Status = cTOGGLE_Status;
}
else if(bKey_Status == cTOGGLE_Status)
{
bKey_Status = cOFF_Status;
}
}
}
}
//******************************************************************************
// Function : Task3
// Input : none
// Output : none
// Description : Task3 process,Control LED3
//******************************************************************************
void Task3(void)
{
INT16U wTask_Event;
static INT8U bKey_Status = cOFF_Status;
while(1)
{
//task switch
if(OS_Task_Switch(cPrioTask3) == true)
{
return;
}
//get event
wTask_Event = OS_Event_Pend(cPrioTask3);
//event parsing : timer event
if(wTask_Event & (1 << eTask3_Timer))
{
if(bKey_Status == cOFF_Status)
{
LED_OFF(cLED3);
}
else if(bKey_Status == cON_Status)
{
LED_ON(cLED3);
}
else if(bKey_Status == cTOGGLE_Status)
{
LED_TOGGLE(cLED3);
}
}
//event parsing : key event
if(wTask_Event & (1 << eTask3_Key))
{
if(bKey_Status == cOFF_Status)
{
bKey_Status = cTOGGLE_Status;
}
else if(bKey_Status == cTOGGLE_Status)
{
bKey_Status = cOFF_Status;
}
}
}
}
//******************************************************************************
// Function : Task4
// Input : none
// Output : none
// Description : Task4 process,Control LED4
//******************************************************************************
void Task4(void)
{
INT16U wTask_Event;
static INT8U bKey_Status = cOFF_Status;
while(1)
{
//task switch
if(OS_Task_Switch(cPrioTask4) == true)
{
return;
}
//get event
wTask_Event = OS_Event_Pend(cPrioTask4);
//event check
if(wTask_Event == 0)
{
return;
}
//event parsing : timer event
if(wTask_Event & (1 << eTask4_Timer))
{
if(bKey_Status == cOFF_Status)
{
LED_OFF(cLED4);
}
else if(bKey_Status == cON_Status)
{
LED_ON(cLED4);
}
else if(bKey_Status == cTOGGLE_Status)
{
LED_TOGGLE(cLED4);
}
}
//event parsing : key event
if(wTask_Event & (1 << eTask4_Key))
{
if(bKey_Status == cOFF_Status)
{
bKey_Status = cTOGGLE_Status;
}
else if(bKey_Status == cTOGGLE_Status)
{
bKey_Status = cOFF_Status;
}
}
}
}
//******************************************************************************
// Function : Task_Start
// Input : none
// Output : none
// Description : Standard function format,put all tasks into while(1)
//******************************************************************************
void Task_Start(void)
{
while(1)
{
Task1();
Task2();
Task3();
Task4();
}
}
//******************************************************************************
// Function : Task_Init
// Input : none
// Output : none
// Description : Standard function format,put all tasks Initialization here
//******************************************************************************
void Task_Init(void)
{
Task1_Init();
Task2_Init();
Task3_Init();
Task4_Init();
}
//===============================END OF FILE==================================//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -