MSP430子程序(液晶控制器子程序)?
//作者:aileen?發(fā)表時(shí)間:2004-12-2?11:20:08?
//聲明:轉(zhuǎn)載請(qǐng)保留以上信息,用于商業(yè)用途,請(qǐng)聯(lián)系作者
//------------------------------------------------------------
//?Control?SED1335
//?Time?2003.01.15
//?Copyright?重慶東電
//?Function?show
//------------------------------------------------------------
#define?WC_ADD?XBYTE[0xC100]
#define?WD_ADD?XBYTE[0xC000]
#define?RD_ADD?XBYTE[0xC100]
#define?RB_ADD?XBYTE[0xC000]
void?INTR(void);
void?CLEAR(void);?/*?信號(hào)輸入?x?[0---319]?,y?[0---239]?*/
void?CCTW(unsigned?int?x,unsigned?char?y,unsigned?char?m,unsigned?char?n,unsigned?char?*p);
void?dot?(unsigned?int?x,unsigned?char?y,bit?c);?/*?c=1?劃點(diǎn)?c=0?取消點(diǎn)*/
?
void?INTR(void)
{
unsigned?char?code?SYSTAB[]={0x30,0x87,0x07,0x27,0x42,0xf0,0x28,0x00};?//?control?parameter
unsigned?char?code?SCRTAB[]={0x00,0x00,0xf0,0x00,0x40,0xf0,0x00,0x80,0x00,0x00};
unsigned?char?i=0x0;
WC_ADD?=?0x40;
for(i?=?0?;i?8;?i++)
{
WD_ADD?=?SYSTAB[i];
}
WC_ADD?=?0x44;
for(i?=?0;i?10;i++)
{
WD_ADD?=?SCRTAB[i];
}
WC_ADD?=?0x5a;
WD_ADD?=?0x0;
WC_ADD?=?0x5b;
WD_ADD?=?0x0;
WC_ADD?=?0x59;
WD_ADD?=?0x54;
}
void?CLEAR(void)
{
unsigned?char?i=0,j=0;
WC_ADD?=?0x4c;
WC_ADD?=?0x46;
WD_ADD?=?0x0;
WD_ADD?=?0x0;
WC_ADD?=?0x42;
for(i?=?0;i?255;i++)
{
for(j?=?0;j?255;j++)
{?WD_ADD?=?0x0;
}
}
}
void?CCTW(unsigned?int?x,unsigned?char?y,unsigned?char?m,unsigned?char?n,unsigned?char?*p)
{
unsigned?char?ap=0x28,i,j,k,tt=0,uu=0,rr=0,ee=0,ff=0,gg=0;?/*ap?修改?P7,?行字符個(gè)數(shù)?*/
unsigned?int?l;
tt?=?x%8;
x=x/8;
l?=?y*ap?+?x+0x4000;
x?=?(unsigned?char)(l&0x00ff);
y?=?(unsigned?char)((l&0xff00)>>8);
WC_ADD=0x4c;?/*設(shè)置光標(biāo)“右”移動(dòng)方式?*/
for(i=0;i{
WC_ADD?=?0x46;?/*?光標(biāo)指針設(shè)置?*/
WD_ADD?=?x;?/*?光標(biāo)地址16位?*/
WD_ADD?=?y;
if(tt==0)
{
WC_ADD?=?0x42;?/*?連續(xù)寫入數(shù)據(jù)*/
for?(j=0;j
WD_ADD?=?*p;
p++?;
}
}?/*?0?1?2?3?*/
else?{?/*?0---7?8---16?17---24?25---32*/
for(j=0;j
RD_ADD=0x43;?/*?讀數(shù)據(jù)?*/
uu=RD_ADD;
rr=RD_ADD;
/*-----------------------------------------------------*/
gg=*p;?/*?處理數(shù)據(jù)*/
p++;
k=uu>>(8-tt);
k=k<<(8-tt);?//?高位
ee=k;
k=gg>>tt;?//?移高位作為低位
ee=ee|k;
/*-----------*/
k=rr<k=k>>tt;?//?低位
ff=k;
k=gg<<(8-tt);
ff=ff|k;
/*--------------------------------------------------------------*/
WC_ADD=0x4d;?/*改變光標(biāo)“左”移動(dòng)方式?*/
RD_ADD=0x43;
k=RD_ADD;
k=RD_ADD;
WC_ADD=0x4c;?/*非復(fù)光標(biāo)“右”移動(dòng)方式?*/
WC_ADD?=?0x42;?/*?送數(shù)據(jù)兩個(gè)?*/
WD_ADD?=ee;
WD_ADD?=ff;
/*本送一個(gè)數(shù)據(jù),前面送了兩個(gè),需要返回一個(gè)*/
WC_ADD=0x4d;?/*改變光標(biāo)“左”移動(dòng)方式?*/
RD_ADD=0x43;
k=RD_ADD;
k=RD_ADD;
WC_ADD=0x4c;?/*非復(fù)光標(biāo)“右”移動(dòng)方式?*/
RD_ADD=0x43;
k=RD_ADD;
}
}
l=(ap+x+(y<<8));
x=(unsigned?char)(l&0x00ff);
y=(unsigned?char)((l&0xff00)>>8);
}
}
void?dot?(unsigned?int?x,unsigned?char?y,bit?c)
{
unsigned?char?ap=0x28,tt=0,uu=0,gg=0,k=0;?/*ap?修改?P7,?行字符個(gè)數(shù)?*/
unsigned?int?l=0;
tt?=?x%8;
x?=?x/8;
l?=?y*ap?+?x+0x4000;
x?=?(unsigned?char)(l&0x00ff);
y?=?(unsigned?char)((l&0xff00)>>8);
WC_ADD?=?0x4c;
WC_ADD?=?0x46;?/*?光標(biāo)指針設(shè)置?*/
WD_ADD?=?x;?/*?光標(biāo)地址16位?*/
WD_ADD?=?y;
RD_ADD=0x43;?/*?讀數(shù)據(jù)?*/
uu=RD_ADD;
if(c)
{
gg?=?1;
gg?=gg<<(7-tt);
uu=uu|gg;
}
else?{
gg?=?1;
gg?=gg<<(7-tt);
gg?=?~gg;
uu=uu≫
}
WC_ADD=0x4d;
RD_ADD=0x43;
k=RD_ADD;
WC_ADD?=?0x4c;?/*非復(fù)光標(biāo)“右”移動(dòng)方式?*/
WC_ADD?=?0x42;?/*?送數(shù)據(jù)兩個(gè)?*/
WD_ADD?=?uu;
}
SED1335 是日本SEIKO EPSON 公司出品的液晶顯示控制器,它在同類產(chǎn)品中是功能最強(qiáng)的.
評(píng)論
查看更多