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

📄 ra8803.c

📁 RA8803液晶控制器的程序
💻 C
字号:
/*******************************************************************************
*                                                                            
*	Filename:	RA8803.c
* 
*   	Author:		Duke Chang
*   	Company:    	RAiO Technology Inc.
*	Case:		320x240
*	Device:		MXIC MX10E8050IQC at 18.432MHz
*   	Date:       	2005/10/1
*	Modifier:	Duke Chang
*	Modify Date:    2005/10/13
*   	Visions:   	1.0
*   	Compiled Using Keil C v7.50
*	
*******************************************************************************/

#include "RA8803.h"

/******************************************************************************/
/*Sub program area		  													  */
/******************************************************************************/

//==============================================================================
//Subroutine:	LCD_Reset
//Function:		
//==============================================================================
void LCD_Reset(void)
{
	bRST = 0;
	Delay100ms(5);
	bRST = 1;
	Delay100ms(2);
}

//==============================================================================
//Subroutine:	LCD_Initial
//Function:		
//==============================================================================
void LCD_Initial(void)
{
	LCD_CmdWrite(WLCR, B1100_0101);		//Normal Power 
	LCD_CmdWrite(MISC, B0000_0010);		//8Mhz
	
	LCD_CmdWrite(WCCR, B0110_1011);		//

	LCD_CmdWrite(AWRR, cAWRR);
	LCD_CmdWrite(AWBR, cAWBR);
	LCD_CmdWrite(AWLR, B0000_0000);
	LCD_CmdWrite(AWTR, B0000_0000);
	LCD_CmdWrite(DWRR, cDWRR);
	LCD_CmdWrite(DWBR, cDWBR);
	LCD_CmdWrite(DWLR, B0000_0000);
	LCD_CmdWrite(DWTR, B0000_0000);

	LCD_CmdWrite(SCCR, B0000_0111);		//Frame Rate
	LCD_CmdWrite(INTR, B0000_0000);
	LCD_CmdWrite(TPCR, B1100_0000);
	LCD_CmdWrite(TPSR, B0011_0101);

	LCD_CmdWrite(PNTR, B0000_0000);		//Fill Data=00
	LCD_CmdWrite(LCCR, B0000_0000);		//DAC Off

	LCD_CmdWrite(FNCR, cFNCR);		//GB Code or BIG5 Code
}

//==============================================================================
//Subroutine:	LCD_CmdWrite
//Function:		
//==============================================================================
void LCD_CmdWrite(uchar Addr, uchar Data)
{
	LCD_ChkBusy();	

#ifdef Parallel_8080
while(BUSY==1);
	bCSZ = 0;
	bRS = 0;
	DATA_BUS = Addr;		//Reg Addr
	bWRZ = 0;
	bWRZ = 1;

	DATA_BUS = Data;		//Reg Data
	bWRZ = 0;
	bWRZ = 1;
	bCSZ = 1;
	DATA_BUS = 0xff;	
#endif
}

//==============================================================================
//Subroutine:	CmdRead
//Function:		
//==============================================================================
uchar LCD_CmdRead(uchar Addr)
{
	uchar Data;
	
#ifdef Parallel_8080
	bCSZ = 0;
	bRS = 0;
	DATA_BUS = Addr;		//Reg Addr
	bWRZ = 0;
	bWRZ = 1;
	
	DATA_BUS = 0xff;
	bRDZ = 0;
	Data = DATA_BUS;
	bRDZ = 1;
	bCSZ = 1;
#endif
	return Data;
}

//==============================================================================
//Subroutine:	LCD_DataWrite
//Function:		
//==============================================================================
void LCD_DataWrite(uchar Data)
{
	
#ifdef Parallel_8080
    while(BUSY==1);
	bCSZ = 0;
	bRS = 1;
	DATA_BUS = Data;
	bWRZ = 0;
	bWRZ = 1;
	bCSZ = 1;
	DATA_BUS = 0xff;
#endif
}

//==============================================================================
//Subroutine:	LCD_DataRead
//Function:		
//==============================================================================
uchar LCD_DataRead(void)
{
	uchar Data;
	
#ifdef Parallel_8080
	bCSZ = 0;
	bRS = 1;
	bRDZ = 0;
	Data = DATA_BUS;
	bRDZ = 1;
	bCSZ = 1;
#endif

	return Data;
}

//==============================================================================
//Subroutine:	LCD_ChkBusy
//Function:		
//==============================================================================
void LCD_ChkBusy(void)
{
//	uchar temp;
	
//	do
//	{
//		temp = LCD_CmdRead(ISR);
//	}while(temp & cTestb7);
}

//==============================================================================
//Subroutine:	LCD_On
//Function:
//==============================================================================
void LCD_ON(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp |= cSetb2;
	LCD_CmdWrite(WLCR, temp);
}

void LCD_OFF(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp &= cClrb2;
	LCD_CmdWrite(WLCR, temp);
}

//==============================================================================
//Subroutine:	LCD_GotoXY
//Function:		LCD Cursor X-Y
//==============================================================================
void LCD_GotoXY(uchar x, uchar y)
{
	LCD_CmdWrite(CPXR, (x & B0011_1111));
	LCD_CmdWrite(CPYR, (y & B1111_1111));	
}

//==============================================================================
//Subroutine:	LCD_Graphic
//Function:
//==============================================================================
void LCD_Graphic(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp &= cClrb3;
	LCD_CmdWrite(WLCR, temp);
}

void LCD_Text(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp |= cSetb3;
	LCD_CmdWrite(WLCR, temp);
}

//==============================================================================
//Subroutine:	LCD_PrintStr 1
//Function:		
//==============================================================================
void LCD_PrintStrD100ms(uchar *ptr, uchar x, uchar y, uchar time)
{
	LCD_GotoXY(x, y);
	
	while(*ptr != 0)
	{
		LCD_DataWrite(*ptr);
		ptr++;
		Delay100ms(time);
	}
}

//==============================================================================
//Subroutine:	LCD_PrintStr 2
//Function:		
//==============================================================================
void LCD_PrintStr(uchar *ptr, uchar cXSize)
{
	uchar temp;

	for(temp=0 ; temp<cXSize ; temp++)
	{
		LCD_DataWrite(*ptr);
		ptr++;
	}
}

//==============================================================================
//Subroutine:	Bold
//Function:
//==============================================================================
void LCD_Bold(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp |= cSetb4;
	LCD_CmdWrite(WCCR, temp);
}

void LCD_NoBold(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp &= cClrb4;
	LCD_CmdWrite(WCCR, temp);
}

//==============================================================================
//Subroutine:	Inv
//Function:
//==============================================================================
void LCD_Inv(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp &= cClrb5;
	LCD_CmdWrite(WCCR, temp);
}

void LCD_NoInv(void)
{
	uchar temp;
	temp = LCD_CmdRead(WCCR);
	temp |= cSetb5;
	LCD_CmdWrite(WCCR, temp);
}

//==============================================================================
//Subroutine:	GInv
//Function:
//==============================================================================
void LCD_GInv(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp &= cClrb0;
	LCD_CmdWrite(WLCR, temp);
}

void LCD_NoGInv(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp |= cSetb0;
	LCD_CmdWrite(WLCR, temp);
}

//==============================================================================
//Subroutine:	Blk
//Function:
//==============================================================================
void LCD_Blk(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp |= cSetb1;
	LCD_CmdWrite(WLCR, temp);
}

void LCD_NoBlk(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp &= cClrb1;
	LCD_CmdWrite(WLCR, temp);
}

//==============================================================================
//Subroutine:	Blk Timer
//Function:
//==============================================================================
void LCD_BlkTim(uchar buf)
{
	uchar temp;
	
	temp = LCD_CmdRead(BTMR);
	temp |= buf;
	LCD_CmdWrite(BTMR, temp);
}

//==============================================================================
//Subroutine:	Cursor On
//Function:
//==============================================================================
void LCD_Cur(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp |= cSetb2;
	LCD_CmdWrite(WCCR, temp);
}

void LCD_NoCur(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp &= cClrb2;
	LCD_CmdWrite(WCCR, temp);
}

//==============================================================================
//Subroutine:	Align On
//Function:
//==============================================================================
void LCD_AlignOn(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp |= cSetb6;
	LCD_CmdWrite(WCCR, temp);
}

void LCD_AlignOff(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp &= cClrb6;
	LCD_CmdWrite(WCCR, temp);
}

//==============================================================================
//Subroutine:	Auto Fill 
//Function:
//==============================================================================
void LCD_FillOn(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(FNCR);
	temp |= cSetb3;
	LCD_CmdWrite(FNCR, temp);
}
//==============================================================================
//Subroutine:	Cursor Blink On
//Function:
//==============================================================================
void LCD_CurBlk(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp |= cSetb1;
	LCD_CmdWrite(WCCR, temp);
}

void LCD_NoCurBlk(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WCCR);
	temp &= cClrb1;
	LCD_CmdWrite(WCCR, temp);
}

//==============================================================================
//Subroutine:	Cursor Height
//Function:
//==============================================================================
void LCD_CurHei(uchar buf)
{
	uchar temp;
	buf = buf << 4;
	buf = buf & 0xF0; 	
	temp = LCD_CmdRead(DLCH);	
	temp = (temp & 0x0F) | buf;		
	LCD_CmdWrite(DLCH, temp);
}

//==============================================================================
//Subroutine:	Line Distance
//Function:
//==============================================================================
void LCD_LineDis(uchar buf)
{
	uchar temp;
	buf = buf & 0x0F; 	
	temp = LCD_CmdRead(DLCH);	
	temp = (temp & 0xF0) | buf;		
	LCD_CmdWrite(DLCH, temp);
}

//==============================================================================
//Subroutine:	Font Size
//Function:
//==============================================================================
void LCD_FontSize(uchar buf)
{
	uchar temp;
	buf = buf << 4;
	temp = (buf & 0xF0) | (0x0F);  	
	LCD_CmdWrite(FVHT, temp);
}

//==============================================================================
//Subroutine:	Software Reset
//Function:
//==============================================================================
void LCD_SWRst(void)
{
	uchar temp;
	
	temp = LCD_CmdRead(WLCR);
	temp |= cSetb5;
	LCD_CmdWrite(WLCR, temp);
}

//==============================================================================
//Subroutine:	LCD_Clear
//Function:		Clear LCD DDRAM
//==============================================================================
void LCD_Clear(void)
{
	LCD_CmdWrite(PNTR, 0x00);
	LCD_FillOn();
	Delay100ms(1);
}

//==============================================================================
//Subroutine:	ADC On/Off
//Function:
//==============================================================================

//==============================================================================
//Subroutine:	Get Panel Touch
//Function:		
//==============================================================================

//==============================================================================
//Subroutine:	Get ADC X/Y
//Function:		
//==============================================================================

//==============================================================================
//Subroutine:	Show Hex
//Function:		
//==============================================================================
void Print_Hex(uchar buf)
{
	uchar temp;
	temp=buf;
	temp = (temp >>4) & 0x0F;
	if(temp < 0x0A)
	{
		temp |= 0x30;
	}
	else temp = temp + 0x37;
	LCD_DataWrite(temp);

	temp=buf;
	temp = temp & 0x0F;
	if(temp < 0x0A)
	{
		temp |= 0x30;
	}
	else temp = temp + 0x37;
	LCD_DataWrite(temp);
}

⌨️ 快捷键说明

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