📄 3510lcd.c
字号:
/**********************************************************************************************
3510LCD.c file
作者:Computer-lov
建立日期:2006-5-2
修改日期:2006-5-3
版本:V1.0
版权所有,盗版必究。
任何技术问题可到我的博客上留言: http://computer00.21ic.org
Copyright(C) Computer-lov 2006-2016
All rights reserved
**********************************************************************************************/
#include <ADuC7027.H>
#include "My_type.h"
#include "3510LCD.h"
/*********************************************************************************************/
void LcdPortInit(void)
{
GP2CON &=~(uint32)(0x0F<<(LCD_RST*4));
GP2DAT |=1<<(LCD_RST+24);
GP2CON &=~(uint32)(0x0F<<(LCD_CS*4));
GP2DAT |=1<<(LCD_CS+24);
GP1CON &=~(uint32)(0x0F<<(LCD_SDATA*4));
GP1DAT &=~(uint32)(1<<(LCD_SDATA+24));
GP1CON &=~(uint32)(0x0F<<(LCD_SCLK*4));
GP1DAT |=1<<(LCD_SCLK+24);
SetLcdRst();
SetLcdCs();
SetLcdSclk();
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdReset(void)
{
ClrLcdRst();
DelayXms(5);
SetLcdRst();
DelayXms(5);
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdSendCommand(uint8 cmd)
{
uint8 i;
SetSdataOut();
ClrLcdCs();
ClrLcdSclk();
ClrLcdSdata();
SetLcdSclk();
for(i=0;i<8;i++)
{
ClrLcdSclk();
if(cmd & 0x80)
{
SetLcdSdata();
}
else
{
ClrLcdSdata();
}
SetLcdSclk();
cmd<<=1;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdSendData(uint32 Data)
{
uint32 i;
SetSdataOut();
ClrLcdCs();
ClrLcdSclk();
SetLcdSdata();
SetLcdSclk();
for(i=0;i<8;i++)
{
ClrLcdSclk();
if(Data & 0x80)
{
SetLcdSdata();
}
else
{
ClrLcdSdata();
}
SetLcdSclk();
Data<<=1;
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdReadDummy(void)
{
SetSdataIn();
ClrLcdCs();
ClrLcdSclk();
SetLcdSclk();
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
uint16 LcdReadData(void)
{
uint16 r = 0;
uint8 i;
SetSdataIn();
ClrLcdCs();
for(i=0;i<12;i++)
{
ClrLcdSclk();
SetLcdSclk();
r<<=1;
if(LCD_SDATA_IN)
{
r++;
}
}
return r;
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdInit(void)
{
uint8 i;
LcdPortInit();
LcdReset();
LcdSendCommand(0x01); //soft reset
SetLcdCs();
DelayXms(5);
LcdSendCommand(0xc6); //initial escape
SetLcdCs();
LcdSendCommand(0xb9); //refresh set
LcdSendData(0x00);
SetLcdCs();
LcdSendCommand(0xb6); //display control
LcdSendData(0x80);
LcdSendData(0x80);
LcdSendData(0x81);
LcdSendData(84);
LcdSendData(69);
LcdSendData(82);
LcdSendData(67);
SetLcdCs();
LcdSendCommand(0xb3); //gray scale position set
LcdSendData(1);
LcdSendData(2);
LcdSendData(4);
LcdSendData(8);
LcdSendData(16);
LcdSendData(30);
LcdSendData(40);
LcdSendData(50);
LcdSendData(60);
LcdSendData(70);
LcdSendData(80);
LcdSendData(90);
LcdSendData(100);
LcdSendData(110);
LcdSendData(127);
SetLcdCs();
LcdSendCommand(0xb5); //gamma curve set
LcdSendData(0x01);
SetLcdCs();
LcdSendCommand(0xbd); //common driver output select
LcdSendData(0x00);
SetLcdCs();
LcdSendCommand(0xbe); //power control
LcdSendData(0x04);
SetLcdCs();
LcdSendCommand(0x11); //sleep out
SetLcdCs();
LcdSendCommand(0xba); //voltage control
LcdSendData(127);
LcdSendData(3);
SetLcdCs();
LcdSendCommand(0xb7); //temperature gradient set
for(i=0; i<14; i++)
{
LcdSendData(0x00);
}
SetLcdCs();
LcdSendCommand(0x29); //display ON
SetLcdCs();
LcdSendCommand(0x03); //booster voltage ON
SetLcdCs();
DelayXms(5);
LcdSendCommand(0x20); //display inversion OFF
SetLcdCs();
LcdSendCommand(0x25); //write contrast
LcdSendData(62);
SetLcdCs();
}
void LcdClr(void)
{
uint8 x, y;
LcdSendCommand(0x2a); //column address set
LcdSendData(0);
LcdSendData(97);
SetLcdCs();
LcdSendCommand(0x2b); //page address set
LcdSendData(0);
LcdSendData(66);
SetLcdCs();
LcdSendCommand(0x2c); //memory write
for(y=0;y<67;y++)
{
for(x=0;x<98;x+=2)
{
LcdSendData(0);
LcdSendData(0);
LcdSendData(0);
}
}
SetLcdCs();
}
///////////////////////////////////////////////////////////////////////////////////////////////
/*********************************************************************************************/
void LcdBlockWrite(uint8 x1, uint8 y1, uint8 x2, uint8 y2, uint8 *b)
{
uint32 x, y;
LcdSendCommand(0x2a); //column address set
LcdSendData(x1);
LcdSendData(x2);
SetLcdCs();
LcdSendCommand(0x2b); //page address set
LcdSendData(y1);
LcdSendData(y2);
SetLcdCs();
LcdSendCommand(0x2c); //memory write
for(y=y1;y<=y2;y++)
{
for(x=x1;x<=x2;x+=2)
{
LcdSendData(*(b++));
LcdSendData(*(b++));
LcdSendData(*(b++));
}
}
SetLcdCs();
}
///////////////////////////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -