新聞中心

S3C2440-LCD字符顯示

作者: 時(shí)間:2016-12-02 來源:網(wǎng)絡(luò) 收藏
void Init_LCD(){
rLCDCON1=(CLKVAL<<8)|(MMODE<<7)|(PNRMODE<<5)|(BPPMODE<<1)|0; //設(shè)置CLKVAL,VCLK=HCLK/[(CLKVAL+1)*2],決定VM的觸發(fā)方式,選擇顯示模式和BPP模式,暫時(shí)不要開啟LCD,因?yàn)檫€沒有設(shè)置好
rLCDCON2=(VBPD<<24)|(LINEVAL<<14)|(VFPD<<6)|(VSPW); //rLCDCON2,rLCDCON3和rLCDCON4主要設(shè)置時(shí)序
rLCDCON3=(HBPD<<19)|(HOZVAL<<8)|(HFPD);
rLCDCON4=(HSPW);
rLCDCON5 = (BPP24BL<<12) | (INVVCLK<<10) | (INVVLINE<<9) | (INVVFRAME<<8) | (0<<7) | (INVVDEN<<6) | (PWREN<<3) |(BSWP<<1) | (HWSWP); //INVVLINE和INVVFRAME需要進(jìn)行翻轉(zhuǎn),因?yàn)镃PU發(fā)出的是正脈沖,LCD使用的是負(fù)脈沖,所以要改變極性,PWREN使能電源信號(hào)
rLCDSADDR1=(((U32)LCD_BUFFER>>22)<<21)|M5D((U32)LCD_BUFFER>>1);
rLCDSADDR2=M5D(((U32)LCD_BUFFER+(SCR_XSIZE*SCR_YSIZE*4))>>1 );
rLCDSADDR3=PAGEWIDTH*32/16;
rLCDINTMSK|=(3);
rTCONSEL = 0;
rGPCUP = 0x0;
rGPDCON = 0xaaaaaaaa;
rGPCCON = 0xaaaa02a9;
rGPDUP = 0x0;
rGPGUP=rGPGUP&("(1<<4))|(1<<4);
rGPGCON=rGPGCON&("(3<<8))|(3<<8);
rLCDCON1 |= 1; //使能數(shù)據(jù)輸出和LCD控制信號(hào)
}
void Paint_text16(U32 x, U32 y, U32 color, unsigned char ch[]){
int i, j, test, t = 0;
for(i = 0; i < 16; i++){
test = 0x80;
for(j = 0; j < 16; j++){
if(j == 8){
test = 0x80;
t++;
}
if(ch[t] & test)
LCD_BUFFER[x+i][y+j] = color;
test >>= 1;
}
t++;
}
}
void Paint_Ascii(U32 x, U32 y, U32 color, unsigned char ch[]){
int i, j, test;
for(i = 0; i < 16; i++){
test = 0x80;
for(j = 0; j < 8; j++){
if(test & ch[ i])
LCD_BUFFER[x+i][y+j] = color;
test >>= 1;
}
}
}
void Paint_background(U32 c){
unsigned int i, j;
for(j = 0; j < LCD_YSIZE; j++)
for(i = 0; i < LCD_XSIZE; i++)
LCD_BUFFER[j][ i] = c;
}
int LcdMain(){
int qu, wei, i, test = 0x80, t;
unsigned char * head;
unsigned char fuck[] = "李萬鵬專注于linux+arm";
Init_LCD();
Paint_background(0xFFFFFF);
for(i = 0,t = 0; i < sizeof(fuck); i++){
if(test & fuck[ i]){
qu = fuck[ i] - 0xA0;
wei = fuck[i+1] - 0xA0;
head = &__HZK[((qu-1)*94+wei-1)*32];
Paint_text16(100, 100+t*16, 0x000000, head);
i++;
}
else{
head = &__ASCII[fuck[ i]*16];
Paint_Ascii(100, 100+i*8 , 0x000000, head);
}
t++;
}
while(1);
}
上一頁 1 2 3 下一頁

關(guān)鍵詞: S3C2440LCD字符顯

評(píng)論


技術(shù)專區(qū)

關(guān)閉