⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 task.c

📁 AVR单片机 C语言程序设计经典实用
💻 C
字号:
//***************************************************************
// File Name : Task.c
// Author    : Steaven
// Created   : 2008-06-09
// Modified  : 
// Revision  : V0.0
//***************************************************************

#include "app.h"

//constant definition
#define cLcdWindowMax 5       //Max of Display Page

//LCD Display Window List
const struct lcdwindowfunc      
{
	INT8U bLcdWindowIndex;
	void (*WinExe)();
}LcdWindowFunc[cLcdWindowMax]=    
{
	0,LCD_Window0_Process,
	1,LCD_Window1_Process,
	2,LCD_Window2_Process,
	3,LCD_Window3_Process,
	4,LCD_Window4_Process,
};

//globla variables
INT16U wLCD_Event;            //Event for LCD Task
INT16U wGEN_Event;            //Event for GEN Task
INT8U bWindowIndex = 0;       //Current Window Index
INT8U bWindowIndexPre = 0xFF; //Last Window Index

//***************************************************************
// Function    : LCD_Task_Init
// Input       : none
// Output      : none
// Description : LCD Task Initialization
//***************************************************************
void LCD_Task_Init(void)
{
	//LCD Display Initialization
	LCD_Init();
	//Get Database Length
	wDataBaseLength = Initial_DataBaseLength();
}

//***************************************************************
// Function    : GEN_Task_Init
// Input       : none
// Output      : none
// Description : GEN Task Initialization
//***************************************************************
void GEN_Task_Init(void)
{
	//Set Initial Time
	sInit_Calendar();
}

//***************************************************************
// Function    : LCD_Task
// Input       : none
// Output      : none
// Description : LCD Task Process
//***************************************************************
void LCD_Task(void)
{
	LcdWindowFunc[bWindowIndex].WinExe();
}

//***************************************************************
// Function    : GEN_Task
// Input       : none
// Output      : none
// Description : GEN Task Process
//***************************************************************
void GEN_Task(void)
{
	static INT8U bCount0 = 0;
	while(1)   
	{
		if(OS_Task_Switch(cPrioGEN) == true) 
		{
			return;                            
		}
		wGEN_Event = OS_Event_Pend(cPrioGEN);
		if(wGEN_Event == 0)                    
		{
			return;                          
		}
		if(wGEN_Event & (1 << eGENTimer))
		{
			//Key Detection
			Key_Detection(); 
			//Calendar Update
			if(bCount0++ >= 50)
			{
				bCount0 = 0;
				Calendar_Update();
			}     
		}
	}
}

//******************************************************************************
// Function    : Task_Init
// Input       : none
// Output      : none
// Description : Standard function format,put all tasks Initialization here
//******************************************************************************
void Task_Init(void)
{
	LCD_Task_Init();
	GEN_Task_Init();
}

//******************************************************************************
// Function    : Task_Start
// Input       : none
// Output      : none
// Description : Standard function format,put all tasks into while(1)
//******************************************************************************
void Task_Start(void)
{
	while(1)
	{
	    LCD_Task();
	    GEN_Task();
	}
}

//===============================END OF FILE==================================//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -