?? ili9320.c
字號:
// PROGRAM FOR S06007
//TFT 240*320DOTS ILI9320+CPT2.4 16BITS 2.8V
#include <reg52.h>
#include <math.h>
#include <intrins.h>
//=====================================
sbit CS = P1^7;
sbit RS = P1^6;
sbit WRITE = P3^6;
sbit READ = P3^7;
sbit REST = P3^4;
sbit G = P1^5;
sbit CE1 = P1^3;
sbit OE = P1^4;
//sbit CE2 = P1^4;
sbit NEXT5 = P3^3;
sbit A16 = P1^0;
sbit A17 = P1^1;
sbit A18 = P1^2;
#define DP_L P0
#define DP_H P2
//=============================================
//=============================================
void Delay(unsigned int t)
{
unsigned int n,m;
for(n=0;n<t;n++)
for(m=0;m<1000;m++);
}
//========================================
/*void wr_comm(unsigned int index)
{
G=0;
READ=1;
RS = 0;
CS = 0;
DP_H = 00;//index;
WRITE = 0;
_nop_();
WRITE = 1;
DP_H = index;
WRITE = 0;
_nop_();
WRITE = 1;
CS = 1;
}
//========================================
void wr_dat(unsigned int data15)
{
unsigned int data1;
G=0;
READ=1;
RS = 1;
CS = 0;
data1=data15;
DP_H = data15>>8;
WRITE = 0;
_nop_();
WRITE = 1;
DP_H = data1;
WRITE=0;
_nop_();
WRITE=1;
CS = 1;
}
*/
//========================================
void wr_comm(unsigned int index)
{
G=0;
READ=1;
RS = 0;
CS = 0;
DP_L = index;//index;
DP_H = index>>8;
WRITE = 0;
_nop_();
WRITE = 1;
CS = 1;
}
//========================================
void wr_dat(unsigned int data15)
{
G=0;
READ=1;
RS = 1;
CS = 0;
DP_L = data15;
DP_H = data15>>8;
WRITE = 0;
_nop_();
WRITE = 1;
CS = 1;
}
//==============================================================================
//========================================
//========================================
void lcd_int(void)
{
CS =0;
REST = 1;
Delay(1);
REST = 0;
Delay(10);
REST = 1;
Delay(50);
//=======2.8v=============
wr_com(0x00E5,0x8000);
wr_com(0x0000,0x0001);
wr_com(0x0001,0x0100);
wr_com(0x0002,0x0700);
wr_com(0x0003,0x1030);
wr_com(0x0004,0x0000);
wr_com(0x0008,0x0202);
wr_com(0x0009,0x0000);
wr_com(0x000A,0x0000);
wr_com(0x000C,0x0000);
wr_com(0x000D,0x0000);
wr_com(0x000F,0x0000);
wr_com(0x0010,0x0000);
wr_com(0x0011,0x0007);
wr_com(0x0012,0x0000);
wr_com(0x0013,0x0000);
Delay(100);//200
wr_com(0x0010,0x17B0);
wr_com(0x0011,0x0007);
Delay(50);
wr_com(0x0012,0x013A);
Delay(50);
wr_com(0x0013,0x1A00);
Delay(50);
wr_com(0x0029,0x000C);
Delay(50);
wr_com(0x0020,0x0000);
wr_com(0x0021,0x0000);
wr_com(0x0030,0x0000);
wr_com(0x0031,0x0505);
wr_com(0x0032,0x0004);
//wr_com(0x0033,0x0203);
//wr_com(0x0034,0x0207);
wr_com(0x0035,0x0006);
wr_com(0x0036,0x0707);
wr_com(0x0037,0x0105);
wr_com(0x0038,0x0002);
wr_com(0x0039,0x0707);
wr_com(0x003C,0x0704);
wr_com(0x003D,0x0807);
wr_com(0x0050,0x0000);
wr_com(0x0051,0x00EF);
wr_com(0x0052,0x0000);
wr_com(0x0053,0x013F);
wr_com(0x0060,0x2700);
wr_com(0x0061,0x0001);
wr_com(0x006A,0x0000);
wr_com(0x0080,0x0000);
wr_com(0x0081,0x0000);
wr_com(0x0082,0x0000);
wr_com(0x0083,0x0000);
wr_com(0x0084,0x0000);
wr_com(0x0085,0x0000);
wr_com(0x0090,0x0000);
wr_com(0x0092,0x0000);
wr_com(0x0093,0x0003);
wr_com(0x0095,0x0110);
wr_com(0x0097,0x0000);
wr_com(0x0098,0x0000);
wr_com(0x0007,0x0173);
}
//========================================
void Switch()
{
repeat:
if (NEXT5&0x01) goto repeat;
else Delay(1);
if (NEXT5&0x01) goto repeat;
else
NEXT5=1;
wr_com(0x0020,0x0000);
wr_com(0x0021,0x0000);
wr_comm(0x0022);
}
/*void pause()
{
while(PAUSE);
}*/
//========================================
void dis_color1(unsigned int j)
{
unsigned int i,m;
wr_com(0x0020,0x0000);
wr_com(0x0021,0x0000);
wr_comm(0x0022);
for(i=0;i<320;i++)
for(m=0;m<240;m++)
{
wr_dat(j);
}
if(NEXT5==0)
{
Delay(5);
}
}
//========================================
//========================================
void dis_color2(unsigned int i,unsigned int j)
{
unsigned int n,m;
wr_com(0x0020,0x0000);
wr_com(0x0021,0x0000);
wr_comm(0x0022);
for(n=0;n<160;n++)
{
for(m=0;m<240;m++)
wr_dat(i);
for(m=0;m<240;m++)
wr_dat(j); }
//Delay(10);
}
//========================================
void dis_color3(unsigned int i,unsigned int j)
{
unsigned int n,m;
wr_com(0x0020,0x0000);
wr_com(0x0021,0x0000);
wr_comm(0x0022);
for(n=0;n<160;n++)
{
for(m=0;m<120;m++)
{wr_dat(i);
// for(m=0;m<240;m++)
wr_dat(j);
}
for(m=0;m<120;m++)
{wr_dat(j);
// for(m=0;m<240;m++)
wr_dat(i);
}
}
if(NEXT5==0)
{
Delay(5);
} //Delay(10);
}
//========================================
//========================================
void main(void)
{
//G=0;
//NEXT5 = 0;
lcd_int();
while(1)
{
dis_color1(0x0000);
dis_color1(0xffff);
dis_color3(0xffff,0x0000);
dis_color1(0xf800);
dis_color1(0x07e0);
dis_color1(0x001f);
// Switch();
//dis_colorn();
//Switch();
dis_bmp1();
Switch();
//dis_bmp2();
// Switch();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -