📄 tp_td018fl_lcd.c
字号:
/*
**********************************************************************************************************
* TD018THEF1 function
* TD018F1 C File
*
* Copyright 2005-2006, SONiX Technology Co.,LTD.
* 9F, No. 8, Lane32, Hsien Cheng 5th St, Chupei City, Hsinchu, Taiwan R.O.C.
*
* Project : ST53100
* Microprocessor : R8032TTE (RDC Semiconductor)
* File : TP_TD018F1_LCD.C
* Version : V1120a
* Engineer : Justin Chen
* Update : 2007/11/20
**********************************************************************************************************
*/
//==========================================================
// |
// INCLUDE FILES |
// |
//==========================================================
#include "LCD.H"
#if (LCD_TYPE==LCD_TD018F1)
//----------------------------------------------------------
// |
// LCD Initial Setting Function |
// |
//----------------------------------------------------------
void TP_TD018F1_LCD_Init(void)
{
aLCD_MODE =7;
LCD_CS_ = TRUE;
LCD_ISDA = FALSE;
LCD_ISCL = FALSE;
aLCDO_OE11 = TRUE;
aLCDO_OE12 = TRUE;
aLCDO_OE13 = TRUE;
LCD_3Wire_Write_TP(0x02,0x08);//RGB Dummy Timing
LCD_3Wire_Write_TP(0x03,0x31);//CrYCbY Sequence 0x38
LCD_3Wire_Write_TP(0x04,0x0F);
LCD_3Wire_Write_TP(0x05,0x13);
LCD_3Wire_Write_TP(0x06,0x18);
LCD_3Wire_Write_TP(0x07,0x08);
LCD_3Wire_Write_TP(0x08,0x00);
LCD_3Wire_Write_TP(0x09,0x20);
//LCD_3Wire_Write_TP(0x09,0x3F);
LCD_3Wire_Write_TP(0x0A,0x20);
LCD_3Wire_Write_TP(0x0B,0x20);
LCD_3Wire_Write_TP(0x0C,0x10);
LCD_3Wire_Write_TP(0x10,0x3A);
LCD_3Wire_Write_TP(0x11,0x3A);
LCD_3Wire_Write_TP(0x12,0x1D);
LCD_3Wire_Write_TP(0x13,0x17);
LCD_3Wire_Write_TP(0x14,0x98);
LCD_3Wire_Write_TP(0x15,0x9A);
LCD_3Wire_Write_TP(0x16,0xA9);
LCD_3Wire_Write_TP(0x17,0x99);
LCD_3Wire_Write_TP(0x18,0x08);
aLCDO_OE11 = FALSE;
aLCDO_OE12 = FALSE;
aLCDO_OE13 = FALSE;
aLCD_PCK_SPEED=2;
aLCD_HO_SIZE[0]=0x66;
//aLCD_HO_SIZE[0]=0x40;
aLCD_HO_SIZE[1]=1;
aLCD_VO_SIZE[0]=240;
aLCD_VO_SIZE[1]=0;
aLCD_HS_WIDTH=1;
aLCD_VS_WIDTH=1;
aLCD_RGB_REVERSE=0;
aLCD_EVEN_RGB=0;
aLCD_ODD_RGB=0;
aLCD_HT_START[0]=0xF4;
aLCD_HT_START[1]=0;
aLCD_VT_START=21;
aLCD_HT_SIZE[0]=0xB4;
aLCD_HT_SIZE[1]=6;
aLCD_VT_SIZE[0]=7;
aLCD_VT_SIZE[1]=1;
aLCD_PCK_RIS=1;
aLCD_HSYNC_HIGH=0;
aLCD_VSYNC_HIGH=0;
aLCD_WR_WIDTH=2;
aLCD_RD_WIDTH=4;
//aLCD_Y_W04=0x05;
//aLCD_Y_W2=0xA0;
//aLCD_Y_W13=0x15;
aLCD_Y_W04=0x10;
aLCD_Y_W2=0xA0;
aLCD_Y_W13=0x20;
LCD_SetGamma(50); //Gamma = 0.5
}
//----------------------------------------------------------
// |
// LCD Brightness Setting Function |
// |
//----------------------------------------------------------
void TP_TD018F1_BrightSet(SBYTE sbvar)
{
aLCD_MODE =7;
LCD_CS_ = TRUE;
LCD_ISDA = FALSE;
LCD_ISCL = FALSE;
aLCDO_OE11 = TRUE;
aLCDO_OE12 = TRUE;
aLCDO_OE13 = TRUE;
if (sbvar>0)
LCD_3Wire_Write_TP(0x0C,0x3F);
else if (sbvar<0)
LCD_3Wire_Write_TP(0x0C,0x00);
else
LCD_3Wire_Write_TP(0x0C,0x10);
aLCDO_OE11 = FALSE;
aLCDO_OE12 = FALSE;
aLCDO_OE13 = FALSE;
}
//----------------------------------------------------------
// |
// LCD Contrast Setting Function |
// |
//----------------------------------------------------------
void TP_TD018F1_ContraSet(SBYTE sbvar)
{
aLCD_MODE =7;
LCD_CS_ = TRUE;
LCD_ISDA = FALSE;
LCD_ISCL = FALSE;
aLCDO_OE11 = TRUE;
aLCDO_OE12 = TRUE;
aLCDO_OE13 = TRUE;
if (sbvar>0)
LCD_3Wire_Write_TP(0x09,0x3F);
else if (sbvar<0)
LCD_3Wire_Write_TP(0x09,0x00);
else
LCD_3Wire_Write_TP(0x09,0x20);
aLCDO_OE11 = FALSE;
aLCDO_OE12 = FALSE;
aLCDO_OE13 = FALSE;
}
//----------------------------------------------------------
// |
// Toppoly 3 Wire WRITE Function |
// |
//----------------------------------------------------------
void LCD_3Wire_Write_TP(UINT8 Addr,UINT8 Data)
{
UINT8 i=0;
UINT16 Bit[16];
for(i=0; i<=5; i++)
{
if(((Addr>>(5-i))&0x01)==0 )
Bit[i] = 0;
else
Bit[i] = 1;
}
for(i=8; i<=15; i++)
{
if(((Data>>(15-i))&0x01)==0 )
Bit[i] = 0;
else
Bit[i] = 1;
}
LCD_CS_=0;
Delay_10us(1);
for(i=0; i<=5; i++)
{
if(Bit[i] == 0)
LCD_ISDA=0;
else
LCD_ISDA=1;
Delay_10us(1);
LCD_ISCL = 1 ;
Delay_10us(2);
LCD_ISCL = 0 ;
}
//Write Bit
LCD_ISDA=0;
Delay_10us(1);
LCD_ISCL = 1;
Delay_10us(2);
//Hiz
LCD_ISCL = 0;
aLCDO_OE11=0;
if(LCD_OSDA == 0)
LCD_ISDA=0;
else
LCD_ISDA=1;
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
LCD_ISCL=0;
aLCDO_OE11=1;
//Data
for(i=8; i<=15; i++)
{
if(Bit[i] == 0)
LCD_ISDA=0;
else
LCD_ISDA=1;
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
LCD_ISCL=0;
}
LCD_ISDA=0;
LCD_ISCL=0;
Delay_10us(1);
LCD_CS_=1;
}
//----------------------------------------------------------
// |
// Toppoly 3 Wire READ Function |
// |
//----------------------------------------------------------
void LCD_3Wire_Read_TP(UINT8 Addr)
{
UINT8 i=0;
UINT8 Wire_Data;
UINT16 Bit[16];
for(i=0; i<=5; i++) //bit0~bit5 : A5~A0
{
if(((Addr>>(5-i))&0x01)==0 )
Bit[i] = 0x00;
else
Bit[i] = 0x01;
}
LCD_CS_=0;
Delay_10us(1);
for(i=0; i<=5; i++)
{
if(Bit[i] == 0x00)
LCD_ISDA=0;
else
LCD_ISDA=1;
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
LCD_ISCL=0;
}
//Read Bit
LCD_ISDA=1;
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
LCD_ISCL=0;
//HiZ
aLCDO_OE11=0;
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
LCD_ISCL=0;
for(i=8; i<=15; i++)
{
Delay_10us(1);
LCD_ISCL=1;
Delay_10us(2);
if(LCD_OSDA == 0)
Bit[i] = 0x00;
else
Bit[i] = 0x01;
LCD_ISCL=0;
}
LCD_CS_=1;
LCD_ISDA=0;
aLCDO_OE11=1;
Wire_Data = (((UINT8)Bit[8] << 7)&0x80)+(((UINT8)Bit[9] << 6)&0x40)
+(((UINT8)Bit[10] << 5)&0x20)+(((UINT8)Bit[11] << 4)&0x10)
+(((UINT8)Bit[12] << 3)&0x08)+(((UINT8)Bit[13] << 2)&0x04)
+(((UINT8)Bit[14] << 1)&0x02)+((UINT8)Bit[15] &0x01);
//printf("3WIRE_DATA =%lx",(UINT32)Wire_Data);
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -