?? ra8803.c
字號:
/*******************************************************************************
*
* Filename: RA8803.c
*
* Author: Duke Chang
* Company: RAiO Technology Inc.
* Case:
* 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
*
********************************************************************************
*
* Function
*
********************************************************************************
*
* Pin assignemt:
* P0.0 : D0
* P0.1 : D1
* P0.2 : D2
* P0.3 : D3
* P0.4 : D4
* P0.5 : D5
* P0.6 : D6
* P0.7 : D7
*
* P2.0 : RS
* P2.5 : RSTZ
*
* P3.0 : X
* P3.1 : X
* P3.2 : X
* P3.3 : INTR
* P3.4 : CSZ
* P3.5 : X
* P3.6 : WRZ
* P3.7 : RDZ
*
*******************************************************************************/
#include "RA8803.h"
/******************************************************************************/
/*Sub program area */
/******************************************************************************/
//==============================================================================
//Subroutine: LCD_Reset
//Function:
//==============================================================================
void LCD_Reset(void)
{
bRST = 0;
Delay100ms(5);
bRST = 1;
Delay100ms(5);
}
//==============================================================================
//Subroutine: LCD_Initial
//Function:
//==============================================================================
void LCD_Initial(void)
{
LCD_CmdWrite(WLCR, B1100_0101); //Normal Power
LCD_CmdWrite(MISC, B0000_0011); //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_1100); //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(FNCR, B1001_0000); //GB Code
LCD_CmdWrite(LCCR, B0000_0000); //DAC Off
}
//==============================================================================
//Subroutine: LCD_CmdWrite
//Function:
//==============================================================================
void LCD_CmdWrite(uchar Addr, uchar Data)
{
#ifdef Parallel_8080
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
#ifdef Parallel_6800
bCSZ = 0;
bRS = 0;
bWRZ = 0;
DATA_BUS = Addr; //Reg Addr
bRDZ = 1;
bRDZ = 0;
DATA_BUS = Data; //Reg Data
bRDZ = 1;
bRDZ = 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
#ifdef Parallel_6800
bCSZ = 0;
bRS = 0;
bWRZ = 0;
DATA_BUS = Addr; //Reg Addr
bRDZ = 1;
bRDZ = 0;
DATA_BUS = 0xff;
bWRZ = 1;
bRDZ = 1;
Data = DATA_BUS;
bRDZ = 0;
bCSZ = 1;
#endif
return Data;
}
//==============================================================================
//Subroutine: LCD_DataWrite
//Function:
//==============================================================================
void LCD_DataWrite(uchar Data)
{
LCD_ChkBusy();
LCD_ChkBusy();
#ifdef Parallel_8080
bCSZ = 0;
bRS = 1;
DATA_BUS = Data;
bWRZ = 0;
bWRZ = 1;
bCSZ = 1;
DATA_BUS = 0xff;
#endif
#ifdef Parallel_6800
bCSZ = 0;
bRS = 1;
DATA_BUS = Data;
bRDZ = 1;
bRDZ = 0;
bCSZ = 1;
DATA_BUS = 0xff;
#endif
}
//==============================================================================
//Subroutine: LCD_DataRead
//Function:
//==============================================================================
uchar LCD_DataRead(void)
{
uchar Data;
LCD_ChkBusy();
#ifdef Parallel_8080
bCSZ = 0;
bRS = 1;
bRDZ = 0;
Data = DATA_BUS;
bRDZ = 1;
bCSZ = 1;
#endif
#ifdef Parallel_6800
bCSZ = 0;
bRS = 1;
bRDZ = 1;
Data = DATA_BUS;
bRDZ = 0;
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
//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: 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:
//==============================================================================
void ADC_On(void)
{
LCD_CmdWrite(TPCR, 0xC0);
}
void ADC_Off(void)
{
LCD_CmdWrite(TPCR, 0x10);
}
//==============================================================================
//Subroutine: Get Panel Touch
//Function:
//==============================================================================
uchar ADC_Touch(void)
{
uchar temp, tempT;
temp = LCD_CmdRead(TPCR);
temp &= cClrb0;
temp &= cClrb1;
temp &= cClrb2;
temp |= cSetb3;
LCD_CmdWrite(TPCR, temp);
Delay10ms(1);
tempT=LCD_CmdRead(TPSR);
temp &= cClrb3;
LCD_CmdWrite(TPCR, temp);
tempT = tempT & B0100_0000;
if(tempT == 0x40) return 0x01;
else return 0x00;
}
//==============================================================================
//Subroutine: Get ADC X/Y
//Function:
//==============================================================================
uchar ADC_X(void)
{
uchar temp, tempX;
temp = LCD_CmdRead(TPCR);
temp &= cClrb0;
LCD_CmdWrite(TPCR, temp);
temp &= cClrb1;
LCD_CmdWrite(TPCR, temp);
temp |= cSetb2;
LCD_CmdWrite(TPCR, temp);
temp |= cSetb3;
LCD_CmdWrite(TPCR, temp);
Delay1ms(1);
tempX=LCD_CmdRead(TPXR);
return tempX;
}
uchar ADC_Y(void)
{
uchar temp, tempY;
temp = LCD_CmdRead(TPCR);
temp &= cClrb2;
LCD_CmdWrite(TPCR, temp);
temp &= cClrb3;
LCD_CmdWrite(TPCR, temp);
temp |= cSetb0;
LCD_CmdWrite(TPCR, temp);
temp |= cSetb1;
LCD_CmdWrite(TPCR, temp);
Delay1ms(1);
tempY=LCD_CmdRead(TPYR);
return tempY;
}
//==============================================================================
//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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -