?? nwesed1335.c
字號:
/********************************************************************
*文件名:lcdDriver.c
*文件描述:
*創(chuàng)建人:Sha zq
*創(chuàng)建日期: 2007年09月06日
*版本號:1.0.01
*E-mail:sasinop@hotmail.com
** 修改人: sha zq
** 日期:2007-9-20 11:10
** 描述修改記錄:
1) 修改WriteChar()函數(shù),詳細(xì)說明見函數(shù)描述部分。
********************************************************************/
#include "Board.h"
#include "lcddriver.h"
///////////////////////////////////////////////////////////
#define SYSTEM_SET 0x40 //初始化設(shè)置
#define SLEEP_IN 0x53 //休閑模式設(shè)置
#define DISP_ON 0x59 //顯示狀態(tài)設(shè)置
#define DISP_OFF 0x58 //顯示狀態(tài)設(shè)置
#define SCROLL 0x44 //顯示域設(shè)置
#define SCRFORM 0x5d //光標(biāo)形狀設(shè)置
#define CGRAM_ADR 0x5c //CGRAM首址設(shè)置
#define CSRDIR_RIGHT 0x4c //光標(biāo)移動方向設(shè)置
#define CSRDIR_LEFT 0x4d //光標(biāo)移動方向設(shè)置
#define CSRDIR_UP 0x4e //光標(biāo)移動方向設(shè)置
#define CSRDIR_DOWN 0x4f //光標(biāo)移動方向設(shè)置
#define HDOT_SCR 0x5a //電位移設(shè)置
#define OVLAY 0x5b //顯示合成設(shè)置
#define CSRW 0x46 //光標(biāo)指針設(shè)置
#define CSRR 0x47 //讀取光標(biāo)指針
#define MWRITE 0x42 //數(shù)據(jù)寫入
#define MREAD 0x43 //數(shù)據(jù)讀取
#define NOR 0x00 //不反白效果
#define INV 0xff //反白效果
///////////////////////////////////////////////////////////
const unsigned char C_SystemSetIni[8]={
0x30,//B0011_0100,
0x87,//B1000_0111,
0x07,
0x13,//0x27
0x4a,
0xf0,//f0
0x14,//0x28,
0x00,
};
const unsigned char C_ScrollIni[10]={0x00,0x00,0xf0,0x00,0x00,0xf0,0x00,0x00,0x00,0x00};
unsigned int scroll_ini1[10]={0x00,0x00,0xf0,0x00,0x00,0xf0,0x00,0x00,0x00,0x00};
unsigned int scroll_ini2[6]={0xb0,0x04,0x1e,0x60,0x09,0xf0};
unsigned char kb[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
unsigned char kai[]={
0x40,0x42,0x42,0x42,0x42,0xFE,0x42,0x42,0x42,0x42,0xFE,0x42,
0x42,0x42,0x42,0x00,0x00,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,
0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00};/*"開",0*/
unsigned char shi[]={
0x10,0x90,0x70,0x1F,0x12,0xF0,0x00,0x20,0x70,0x28,0x27,0x22,
0x28,0x70,0x20,0x00,0x40,0x21,0x12,0x0C,0x06,0x09,0x30,0x00,
0x7F,0x21,0x21,0x21,0x21,0x7F,0x00,0x00};/*"始",1*/
unsigned char du[]={
0x40,0x42,0xCC,0x04,0x00,0x50,0x94,0x34,0xD4,0x1F,0xD4,0x14,
0x54,0x34,0x10,0x00,0x00,0x00,0x7F,0x20,0x10,0x82,0x43,0x22,
0x12,0x0A,0x07,0x0A,0x12,0xE2,0x42,0x00};/*"讀",2*/
unsigned char ka[]={
0x00,0x40,0x40,0x40,0x40,0x40,0x40,0xFF,0x44,0x44,0x44,0x44,
0x44,0x44,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0x00,0x02,0x04,0x0C,0x38,0x10,0x00,0x00};/*"卡",3*/
unsigned char cha[]={
0x80,0x88,0x48,0xC8,0xA8,0x98,0x88,0xFF,0x88,0x98,0xA8,0xA8,
0x48,0xC8,0x48,0x00,0x00,0x40,0x40,0x5F,0x52,0x52,0x52,0x52,
0x52,0x52,0x52,0x5F,0x40,0x40,0x40,0x00};/*"查",0*/
unsigned char xun[]={
0x40,0x42,0xCC,0x04,0x00,0x10,0xE8,0x27,0x24,0x24,0xE4,0x04,
0x04,0xFC,0x00,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x1F,0x09,
0x09,0x09,0x1F,0x40,0x80,0x7F,0x00,0x00};/*"詢",1*/
unsigned char ji[]={
0x40,0x41,0x4E,0xC4,0x00,0x00,0x00,0xC2,0x42,0x42,0x42,0x42,
0x42,0x7E,0x00,0x00,0x00,0x00,0x00,0x7F,0x20,0x10,0x00,0x3F,
0x40,0x40,0x40,0x40,0x40,0x78,0x20,0x00};/*"記",2*/
unsigned char lu[]={
0x20,0x20,0x22,0xAA,0x2A,0x2A,0x2A,0xEA,0x2A,0x2A,0xAA,0xFE,
0x20,0x20,0x20,0x00,0x00,0x10,0x30,0x10,0x09,0x4A,0x84,0x7F,
0x02,0x05,0x08,0x18,0x30,0x10,0x00,0x00};/*"錄",3*/
unsigned char xi[]={
0x00,0x00,0x02,0x22,0xB2,0xAA,0x66,0x62,0x22,0x11,0x4D,0x81,
0x01,0x01,0x00,0x00,0x00,0x40,0x21,0x13,0x09,0x05,0x41,0x81,
0x7F,0x01,0x05,0x09,0x13,0x62,0x00,0x00};/*"系",0*/
unsigned char tong[]={
0x20,0x30,0x2C,0xA3,0x60,0x10,0x84,0xC4,0xA4,0x9D,0x86,0x84,
0xA4,0xC4,0x84,0x00,0x20,0x22,0x23,0x12,0x12,0x92,0x40,0x30,
0x0F,0x00,0x00,0x3F,0x40,0x41,0x70,0x00};/*"統(tǒng)",1*/
unsigned char she[]={
0x40,0x41,0xCE,0x04,0x00,0x80,0x40,0xBE,0x82,0x82,0x82,0xBE,
0xC0,0x40,0x40,0x00,0x00,0x00,0x7F,0x20,0x90,0x80,0x40,0x43,
0x2C,0x10,0x10,0x2C,0x43,0xC0,0x40,0x00};/*"設(shè)",2*/
unsigned char zhi[]={
0x00,0x20,0x2F,0xA9,0xA9,0xAF,0xE9,0xB9,0xA9,0xAF,0xA9,0xA9,
0x2F,0x20,0x00,0x00,0x80,0x80,0x80,0xFF,0xAA,0xAA,0xAA,0xAA,
0xAA,0xAA,0xAA,0xFF,0x80,0x80,0x80,0x00};/*"置",3*/
unsigned char de[]={
0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x01,0x07,0x08,0x08,0x0C,0x0D,0x0F,0x0F,0x0E,
0x0F,0x0F,0x07,0x07,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0xC0,0xE1,0xE1,0xE2,0x82,0x34,0xFD,0xBF,0xBF,0x7D,0xFD,0xDF,0xDA,0x9B,0xBB,
0xF9,0xF1,0x70,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE0,0xB0,0xB0,0xB0,
0x70,0x60,0x60,0xFC,0xFF,0xE3,0x83,0x03,0xC3,0xE3,0xE7,0x47,0x06,0x8E,0xFE,0xFC,
0x78,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x80,0x80,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//的
unsigned char li[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x08,0x00,0x01,0x03,0x3F,0x1F,0x0E,
0x00,0x01,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0C,0x1E,0x3E,0xF8,0xEC,0x9E,0x3E,0x78,0xF8,0xF8,0xB9,0x3B,0x7E,0xFC,0xF8,0xF0,
0xF0,0x30,0x30,0x10,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0C,0x0E,0x16,
0x16,0x96,0xE6,0xE6,0xE6,0xE4,0xE4,0xE4,0xC4,0x44,0x44,0x04,0x04,0x06,0xC6,0x7E,
0x3E,0x1E,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};//利
#define RSTLCD_H AT91C_BASE_PIOA->PIO_SODR=AT91C_PIO_PA0
#define CS_H AT91C_BASE_PIOA->PIO_SODR=AT91C_PIO_PA1
#define A0_H AT91C_BASE_PIOA->PIO_SODR=AT91C_PIO_PA17
#define WR_H AT91C_BASE_PIOA->PIO_SODR=AT91C_PIO_PA18
#define RD_H AT91C_BASE_PIOA->PIO_SODR=AT91C_PIO_PA19
#define RSTLCD_L AT91C_BASE_PIOA->PIO_CODR=AT91C_PIO_PA0
#define CS_L AT91C_BASE_PIOA->PIO_CODR=AT91C_PIO_PA1
#define A0_L AT91C_BASE_PIOA->PIO_CODR=AT91C_PIO_PA17
#define WR_L AT91C_BASE_PIOA->PIO_CODR=AT91C_PIO_PA18
#define RD_L AT91C_BASE_PIOA->PIO_CODR=AT91C_PIO_PA19
void SendCommand(unsigned char command)
{
A0_H;
AT91C_BASE_PIOA->PIO_OER = 0xff000000; // Configure in Output
AT91C_BASE_PIOA->PIO_ODSR=(unsigned int)command<<24;
WR_L;
WR_H;
}
void SendSingleData(unsigned char data)
{
A0_L;
AT91C_BASE_PIOA->PIO_OER = 0xff000000; // Configure in Output
AT91C_BASE_PIOA->PIO_ODSR=(unsigned int)data<<24;
WR_L;
WR_H;
}
void SendMulitData(unsigned char *pdata,unsigned char mode,unsigned char num)
{
unsigned int loop;
A0_L;
AT91C_BASE_PIOA->PIO_OER = 0xff000000; // Configure in Output
for (loop=0;loop<num;loop++)
AT91C_BASE_PIOA->PIO_ODSR=(unsigned int)data<<24;
WR_L;
WR_H;
}
void SendAddress(unsigned int address)
{
SendCommand(CSRW);
A0_L;
SendData(address&0xff);
SendData((address>>8)&0xff);
A0_H;
}
void WriteChinese(unsigned int address,unsigned char *word,unsigned char mode)
{
unsigned int loop;
SendCommand(CSRDIR_DOWN);
SendAddress(address);
SendCommand(MWRITE);
/*
A0_L;
for(loop=0;loop<16;loop++)
SendData((word[loop]^mode));
*/
SendMulitData(word,mode,16)
// A0_H; //08-05-08 add
SendAddress(address-1);
SendCommand(MWRITE);
A0_L;
for(loop=16;loop<32;loop++)
SendData(word[loop]^mode);
// A0_H; //08-05-08 add
}
void AdvWritechinese(unsigned int x,unsigned int y,unsigned char *word,unsigned char mode)
{
unsigned int position;
//position=x*20+(19-y);
position=(x<<4)+(x<<2)+(19-y);
WriteChinese(position,word,mode);
}
void ClearLcd()
{
int i,j;
for(i=0;i<20;i++)
{
for(j=0;j<240;j=j+16)
{
AdvWritechinese(j,i,kb,NOR);
}
}
}
void TestDisplay()
{
AdvWritechinese(16,0,kai,NOR);
AdvWritechinese(16,6,shi,INV);
AdvWritechinese(32,6,du,INV);
AdvWritechinese(0,6,ka,NOR);
}
void LcdInit()
{
unsigned int loop;
SendCommand(SYSTEM_SET);
A0_L;
for (loop=0;loop<8;loop++)
SendData(C_SystemSetIni[loop]);
SendCommand(SCROLL);
A0_L;
for (loop=0;loop<10;loop++)
SendData(C_ScrollIni[loop]);
SendCommand(HDOT_SCR);
A0_L;
SendData(0x00);
SendCommand(OVLAY);
A0_L;
SendData(0x0c);
SendCommand(DISP_ON);
A0_L;
SendData(0x55);
SendCommand(CSRDIR_DOWN);
}
/***************************************************************
* main program *
****************************************************************/
void LcdMain()
{
unsigned int delay;
RSTLCD_L;
//WR_H; ///add 05-08
//RD_H; //
//CS_H; //
delay=AT91C_BASE_PITC->PITC_PIIR;
while (AT91C_BASE_PITC->PITC_PIIR-delay<333)
{
}
RSTLCD_H;
CS_L;
LcdInit();
ClearLcd();
TestDisplay();
}
/*
void ClearLcd()
{
//unsigned int i=0;
//unsigned int temp;
unsigned int loop;
//sed1335_write(csrdir_right,null,1); //光標(biāo)移動方向設(shè)置
SendCommand(CSRDIR_RIGHT);
A0_L;
SendData(0x00);
SendCommand(CSRW);
A0_L;
for (loop=0;loop<2;loop++)
SendData(scroll_ini1[loop]);
SendCommand(MWRITE);
A0_L;
for (loop=0;loop<9600;loop++)
SendData(0x00);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -