欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

qxj.c

TI5509A-DSP-192*64液晶显示驱动
C
字号:
/*****************************************************************************
  Filename:	    native.c
  Version:	    0.01
  Description:  calculate  measure  value
  Returns:     result
  Revision History:	 Wrdata
  EQH-01,  屈宵军  09/25/04, - Original release
*****************************************************************************/

#include<math.h>
#include <csl.h>
#include<tms320.h>
#include "LCD.h"
void DisEnableFun(void);
void LCDCLR(void);
void lcdbusyL(void);
void mytable(void);
void measure_data(void);
void Locate(void);
void name(void);
void MY_name(void);
void RTC_DISPLY(void);
void ReadR(void);
void ReadM(void);
void ReadL(void);
int Key_Val=0;
extern int key1,key2,key3;
unsigned char  CMISx,CMISy,Wrbyte;
uchar  temp;
uint x=0,m=0; 
extern  char  string[40];
extern  Uint16   newkey;
//extern  unsigned   Globle_var;
void Lcd_Driver(void)
{ 
  if(newkey==1)
     {  
         Key_Val=Get_Key();
         newkey=0;
         switch(Key_Val)
          {
           case 1:		{page_name();   Key_Val=0;break;}    
           case 2:		{measure_data();Key_Val=0;break;}
     	   case 3:		{measure_data();Key_Val=0;break;}
    	   case 4:		{mytable();     Key_Val=0;break;}
           default:     Key_Val=0;
          }
    }
}


page_name(void)
  { 
    col=0;
    row=0;
    LCDCLR(); 
    col=24;
	row=0;
	PutChar(Hzk,12);
	col=54;
	row=2;
	PutChar(china,2);
	col=90;
	row=2;
	PutChar(Hzk,2);
	col=34;
	row=6;
	Putstr(STR5,17);	/*第二行字符输出,12字节	*/
	col=34;
	row=4;
    PutChar(EQH,9);
  }  


void Putstr(char *puts,uchar i)
	{
		uchar j,X;
		for (j=0;j<i;j++)
		{
		X = puts[j];
	    Putedot(X-0x20);		/*ascii码表从0x20开始*/
		}
	}
void PutChar(char *puts,uchar i)
    {
      uchar j,X=0;
		for (j=0;j<i;j++)
		{
	
	    Putcdot(puts,X);		/*ascii码表从0x20开始*/
		X++;
		} 
   
    }
/****************************************/
void Wrdata(uchar X)
	{
	    Wrbyte=X;
    	Locatexy();	
	
	}



void Locatexy(void)
	{
	
	CMISx = (col&0x3F)|SETX;		/*  col.and.0x3f.or.setx=0x40	*/
	CMISy = (row&0x07)|SETY; 		/*  row.and.0x07.or.sety=b8	*/
	switch (col&0xc0)		/*  col.and.0xC0	*/
		{			/*条件分支执行		*/
		case 0:		{lcdbusyL();break;}	/*左区	*/
		case 0x40:	{lcdbusyM();break;}	/*中区	*/
		case 0x80:	{lcdbusyR();break;}	/*右区	*/
		}
	//	wtcom();	    	    /*  waitting for enable		*/
		
	}
/*   半角字符点阵码数据输出		*/
/****************************************/
void Putedot(uchar Order)
	{
	uchar bakerx,bakery;	/*共定义4个局部变量			*/
	uint i,x;		        	/*偏移量,字符量少的可以定义为uchar	*/
	bakerx = col;    		/*暂存x,y坐标,已备下半个字符使用	*/
	bakery = row;
	x=Order * 6;	    	/*半角字符,每个字符16字节	*/
/*上半个字符输出,8列	*/
	for(i=0;i<6;i++)
		{
		cbyte = Ezk[x];				/*取点阵码,rom数组	*/
		Wrdata(cbyte);				/*写输出一字节		*/
		x++;
		col++;
		if (col==LCMLIMIT){col=0;row=row+2;};	/*下一列,如果列越界换行*/
			if (row>7) row=0;		/*如果行越界,返回首行	*/
		}					/*上半个字符输出结束	*/

	col = bakerx;					/*列对齐		*/
	row = bakery+1;					/*指向下半个字符行	*/
/*下半个字符输出,8列	*/
	for(i=0;i<6;i++)
		{
		cbyte = Ezk[x];				/*取点阵码		*/
		Wrdata(cbyte);				/*写输出一字节		*/
		x++;
		col++;
		if (col==LCMLIMIT){col=0;row=row+2;};	/*下一列,如果列越界换行*/
			if (row>7) row=1;		/*如果行越界,返回首行	*/
		}					/*下半个字符输出结束	*/
	row=bakery;
	}						/*整个字符输出结束	*/

void Delay(uint MS)
	{
	//	uchar us,usn;
		while(MS!=0)
			{/* usn = 4;
				while(usn!=0)
					{
						us=0xf0;
						while (us!=0){us--;};
						usn--;
					}*/
				MS--;
			}
	}

void DisEnableFun(void)
  {
   uchar disenable=0;
   
   disenable=disenable|CS1_1;		/*CLR	CS1		*/
   disenable=disenable|CS2_1;		/*SETB	CS2		*/
   disenable=disenable|CS3_1;	
   disenable= disenable|(RWlcd_1);
   *str_port=disenable;
   //disenable=disenable|(Elcd_1);
   //*str_port=disenable;
  }
  void lcdbusyL(void)
	{ 
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步
	//    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
	    temp=temp&CS1_0;		
   //     temp=temp|CS2_1;		
   //     temp=temp|CS3_1;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISy;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
	    temp=temp&CS1_0;		
 //       temp=temp|CS2_1;		
 //       temp=temp|CS3_1;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISx;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
        temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
	    temp=temp&CS1_0;		
//        temp=temp|CS2_1;		
//        temp=temp|CS3_1;
//        temp= temp|DIlcd_1;			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	     *str_data= Wrbyte;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 	    
	}
    
void lcdbusyR(void)
	{ 
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
//        temp=temp|CS2_1;		
        temp=temp&CS3_0;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISy;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
//      temp=temp|CS2_1;		
        temp=temp&CS3_0;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISx;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
        temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
//        temp=temp|CS2_1;		
        temp=temp&CS3_0;
//        temp= temp|DIlcd_1;			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	     *str_data= Wrbyte;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 	    
	}		
/*************************************************************************/   
void lcdbusyM(void)
	{ 
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
        temp=temp&CS2_0;		
//        temp=temp|CS3_1;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISy;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
	    temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
        temp=temp&CS2_0;		
//        temp=temp|CS3_1;
        temp= temp&(DIlcd_0);			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	    *str_data= CMISx;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 
/**********************************************/
        temp=0x0FF;
	    *str_port=temp;
	    Delay(4);              
	    temp= temp&(Elcd_0);   // 第一步 
//	    temp= temp|(RWlcd_1); 
	    *str_port=temp;
	    Delay(4);              //第二步
//	    temp=temp|CS1_1;		
        temp=temp&CS2_0;		
//        temp=temp|CS3_1;
//        temp= temp|DIlcd_1;			
		temp= temp&(RWlcd_0); //第三步控制设置
		*str_port=temp;
		Delay(4);             //第四步			
		temp= temp|(Elcd_1);  //第五步
		*str_port=temp;
	//	Delay(4);             //第六步
	     *str_data= Wrbyte;     //第七步	
	    Delay(4);             //第八步
	    temp= temp&(Elcd_0);  //第九步 
	    *str_port=temp;       
	    Delay(2);             //第十步       
	    DisEnableFun();       //第十一步 
	    Delay(4);             //第十二步
	    temp= temp|(Elcd_1);  //第十三步
	    temp= temp|(RWlcd_1); 
		*str_port=temp;
		Delay(4); 	    
	}




void LCDCLR(void)
{
   for(row=0;row<8;row++)
   		for(col=0;col<LCMLIMIT;col++) Wrdata(0);


}
void Rollscreen(uchar x)
	{
		CMISy = DISPFIRST|x;	/*定义显示起始行为x

⌨️ 快捷键说明

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