#include "tft_driver.h"
void delay_SYS(unsigned int count)
{
for(count=0;count<200;count++);
}
select_16bit_reg(unsigned char reg) //select the register
{
RS_L; //À¸ßRS
CS_L; //ÀµÍCS
DATA_PORT = (unsigned char)0x00; //¸ß8λµØÖ·
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,LCD_IE_PIN);
DATA_PORT =(unsigned char)reg; //µÍ8λµØÖ·
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
CS_H; //À¸ßCS
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,0X00);
}
write_16bit_data(unsigned char adata) //write data to register
{
//unsigned int temp;
CS_L; //ÀµÍCS
RS_H; //À¸ßRS
//temp =adata;
DATA_PORT =(unsigned char)(adata>>8);
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,LCD_IE_PIN);
DATA_PORT =(unsigned char)adata;
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
CS_H; //À¸ßCS
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,0X00);
}
void write_to_reg(unsigned short adata,unsigned short reg)
{
/*select_16bit_reg(reg); //select the register
write_16bit_data(data); //write data to register*/
// unsigned int temp;
RS_L; //À¸ßRS
CS_L; //ÀµÍCS
DATA_PORT = (unsigned char)0x00; //¸ß8λµØÖ·
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,LCD_IE_PIN);
DATA_PORT =(unsigned char)reg; //µÍ8λµØÖ·
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
CS_H; //À¸ßCS
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,0);
CS_L; //ÀµÍCS
RS_H; //À¸ßRS
// temp =adata;
DATA_PORT =(unsigned char)(adata>>8);
WR_L; //ÀµÍWR
WR_H;
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,LCD_IE_PIN); //À¸ßWR
DATA_PORT =(unsigned char)adata;
WR_L; //ÀµÍWR
WR_H; //À¸ßWR
CS_H; //À¸ßCS
GPIOPinWrite(LCD_IE_BASE ,LCD_IE_PIN,0);
}
void initial_lcd()
{
SysCtlPeriEnable(LCD_PERIPH); /* ʹÄÜÏàÓ¦µÄGPIO */
GPIOPinTypeOut(LCD_CS_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄ¿ØÖƹܽÅΪÊä³ö */
GPIOPinTypeOut(LCD_WR_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄ¿ØÖƹܽÅΪÊä³ö */
GPIOPinTypeOut(LCD_RS_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄ¿ØÖƹܽÅΪÊä³ö */
GPIOPinTypeOut(LCD_RD_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄ¿ØÖƹܽÅΪÊä³ö */
GPIOPinTypeOut(LCD_RST_BASE_PIN);
GPIOPinTypeOut(LCD_IE_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄ¿ØÖƹܽÅΪÊä³ö */
GPIOPinTypeOut(DATA_PORT_BASE_PIN); /* ÉèÖÃÏàÓ¦µÄÊý¾Ý¹Ü½ÅΪÊä³ö */
CS_H; //³õʼ»¯CSΪ¸ß //³õʼ»¯RDΪ¸ß
RST_H; //³õʼ»¯RSTΪ¸ß
delay_SYS(10); //³õʼ»¯Êý¾Ý¶Ë¿ÚΪ¸ß
RST_L; //ÀµÍ¸´Î»¹Ü½Å
delay_SYS(10);
RST_H; //À¸ß¸´Î»¹Ü½Å
delay_SYS(50);
//write_to_reg(unsigned int data,unsigned int reg)
write_to_reg(0x0001,0x0100); //selet oscillation control register R00
//start oscillation;wait for 10ms at least
//----------------------------------------------------------------- //Power Control 1
write_to_reg(0x0002,0x0700);
write_to_reg(0x0003,0x1018);
write_to_reg(0x0004,0x0000);
write_to_reg(0x0008,0x0202);
write_to_reg(0x0009,0x0000);
write_to_reg(0x000A,0x0000);
write_to_reg(0x000C,0x0000);
write_to_reg(0x000d,0x0000);
write_to_reg(0x000f,0x0000);
for(i=50000;i>0;i--);
for(i=50000;i>0;i--);
LCD_WriteReg(0x07,0x0101);
for(i=50000;i>0;i--);
for(i=50000;i>0;i--);
write_to_reg(0x0010,0x0000);
write_to_reg(0x0011,0x0007);
write_to_reg(0x0012,0x0000);
write_to_reg(0x13,0x0000);
write_to_reg(0x29,0x0018);
write_to_reg(0x2b,0x000d);
//*SS = 1,the BGR shauld be 1;528 * 216 dot
/* write_to_reg(0x30,0x0004); //LCD wave form Control R02
delay_SYS(2); //3 filds
//write_to_reg(0x1230,0x0003);
write_to_reg(0x0031,0x0307); //Entry Mode Register
write_to_reg(0x0032,0x0002); //BGR = 1;ʹÓøßËÙģʽд GRAM;
write_to_reg(0x0035,0x0206); //I/D1-0=11:µØÖ·×Ô¶¯¼Ó1;AM=0:µØÖ·¸üÐÂΪˮƽ·½Ïò;LG2-0=0
write_to_reg(0x0036,0x0408);
write_to_reg(0x0037,0x0507); //Compare Register 1
write_to_reg(0x0038,0x0204); //Compare Register 2
//select_16bit_reg(0x0006); //reserved and disable
write_to_reg(0x0039,0x0707); //Display Control 1
delay_SYS(2); //Õý³£ÏÔʾ£»½ûÖ¹Òº¾§·ÖÆÁÏÔʾ¹¦ÄÜ,D1-0=11
write_to_reg(0x003C,0x0405); //Display Control 2
//Ç°ºó²»ÏÔʾµÄ¹âÕ¤À¸¾ùΪ8
write_to_reg(0x003D,0x0F02); //Display Control 3
//ÆÕͨ·½Ê½É¨Ãè²»ÏÔʾÇøÓò£»É¨ÃèƵÂÊ
delay_SYS(150);
//select_16bit_reg(0x000a); */ //reserved and disable
write_to_reg(0x0050,0);
write_to_reg(0x0051,239);
write_to_reg(0x0052,0x0000);
write_to_reg(0x0053,319);
write_to_reg(0x0060,0x2700);
write_to_reg(0x0061,0x0001);
write_to_reg(0x006a,0x0000);
write_to_reg(0x0080,0x0000);
write_to_reg(0x0081,0x0000);
write_to_reg(0x0082,0x0000);
write_to_reg(0x0083,0x0000);
write_to_reg(0x0084,0x0000);
write_to_reg(0x0085,0x0000);
write_to_reg(0x0090,(0<<7)|(16<<0));
//select_16bit_reg(0x0032);
write_to_reg(0x0092,0x0000);
write_to_reg(0x0093,0x0001);
write_to_reg(0x0095,0x0110);
write_to_reg(0x0097,(0<<8));
write_to_reg(0x0098,0x0000);
write_to_reg(0x0007,0x0173);
}
我用的lm3s2965想移植驱动为ili9320的TFT初始化程序,
上面是我的移植的驱动程序;请高手帮我看哈对不,还有以张TFT的原理图;