?? lcdlib.c
字號:
#include <string.h>
#include "..\inc\44b.h"
#include "..\inc\44blib.h"
#include "..\inc\def.h"
#include "..\inc\lcd.h"
#include "..\inc\lcdlib.h"
#include "..\inc\glib.h"
unsigned int (*frameBuffer1)[SCR_XSIZE/32];
unsigned int (*frameBuffer4)[SCR_XSIZE/16];
void Lcd_Init(int depth)
{
//320x240 1bit/1pixel LCD
switch(depth)
{
case 1:
if((U32)frameBuffer1==0)
{
//The total frame memory should be inside 4MB.
//For example, if total memory is 8MB, the frame memory
//should be in 0xc000000~0xc3fffff or c400000~c7fffff.
//But, the following code doesn't meet this condition(4MB)
//if the code size & location is changed..
frameBuffer1=(unsigned int (*)[SCR_XSIZE/32])malloc(ARRAY_SIZE_MONO);
}
rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x0<<27) | ( ((U32)frameBuffer1>>22)<<21 ) | M5D((U32)frameBuffer1>>1);
// monochrome, LCDBANK, LCDBASEU
rLCDSADDR2= M5D( (((U32)frameBuffer1+(SCR_XSIZE*LCD_YSIZE/8))>>1) ) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 );
rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
break;
case 4:
if((U32)frameBuffer4==0)
{
//The total frame memory should be inside 4MB.
//For example, if total memory is 8MB, the frame memory
//should be in 0xc000000~0xc3fffff or c400000~c7fffff.
//But, the following code doesn't meet this condition(4MB)
//if the code size & location is changed..
frameBuffer4=(unsigned int (*)[SCR_XSIZE/16])malloc(ARRAY_SIZE_G4);
}
rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G4<<12);
// disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x1<<27) | ( ((U32)frameBuffer4>>22)<<21 ) | M5D((U32)frameBuffer4>>1);
// 4-gray, LCDBANK, LCDBASEU
rLCDSADDR2= M5D((((U32)frameBuffer4+(SCR_XSIZE*LCD_YSIZE/4))>>1)) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/8) | ( ((SCR_XSIZE-LCD_XSIZE)/8)<<9 );
//The following value has to be changed for better display.
//Select 4 levels among 16 gray levels.
rBLUELUT=0xfa40;
rDITHMODE=0x0;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_G4<<12);
// enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
break;
default:
break;
}
}
void Lcd_MoveViewPort(int vx,int vy,int depth)
{
U32 addr;
switch(depth)
{
case 1:
// LCDBASEU,LCDBASEL register has to be changed before 12 words before the end of VLINE.
// In mono mode, x=320 is 10 words, So, We can't change LCDBASEU,LCDBASEL
// during LINECNT=1~0 at mono mode.
//The processor mode should be superviser mode.
DisableInterrupt();
#if (LCD_XSIZE<512)
while((rLCDCON1>>22)<=1); // if x<512
#else
while((rLCDCON1>>22)==0); // if x>512 ((12+4)*32)
#endif
addr=(U32)frameBuffer1+(vx/8)+vy*(SCR_XSIZE/8);
rLCDSADDR1= (0x0<<27) | ( (addr>>22)<<21 ) | M5D(addr>>1);
// monochrome, LCDBANK, LCDBASEU
rLCDSADDR2= M5D( ((addr+(SCR_XSIZE*LCD_YSIZE/8))>>1) ) | (MVAL<<21);
EnableInterrupt();
break;
case 4:
//The processor mode should be superviser mode.
DisableInterrupt();
#if (LCD_XSIZE<256)
while((rLCDCON1>>22)<=1); // if x<256
#else
while((rLCDCON1>>22)==0); // if x>256
#endif
addr=(U32)frameBuffer4+(vx/4)+vy*(SCR_XSIZE/4);
rLCDSADDR1= (0x1<<27) | ( (addr>>22)<<21 ) | M5D(addr>>1);
// 4-gray, LCDBANK, LCDBASEU
rLCDSADDR2= M5D(((addr+(SCR_XSIZE*LCD_YSIZE/4))>>1)) | (MVAL<<21);
EnableInterrupt();
break;
}
}
void Lcd_Display(void)
{
int i,j;
for(j=0;j<240;j++)
for(i=0;i<20;i++)
{
//frameBuffer4[j][i]=(girl[i*4+0])<<24
// +(girl[i*4+1])<<16
// +(girl[i*4+2])<<8
// +(girl[i*4+3]);
frameBuffer4[j][i]=0xffff0000;
}
}
void Lcd_DispON(void)
{
Delay(5000);
rPDATC = ( rPDATC & (~(1<<8)) );
Delay(5000);
}
void Lcd_DispOFF(void)
{
Delay(5000);
rPDATC = ( rPDATC | (1<<8) );
Delay(5000);
}
void Lcd_PowerReset(void)
{
U8 i;
rPDATC = ( rPDATC | 3<<4 ); //crtl=1,adj=1
for(i=0;i<1;i++);
rPDATC = ( rPDATC & (~(1<<5)) ); //ctrl=0
for(i=0;i<2;i++);
rPDATC = ( rPDATC | 1<<5 ); //ctrl=1
for(i=0;i<1;i++);
rPDATC = ( rPDATC & (~(1<<4)) ); //adj=0
}
void Lcd_PowerUp(void)
{
U8 i;
rPDATC = ( rPDATC | 2<<4 ); //ctrl=1,adj=0
for(i=0;i<2;i++);
rPDATC = ( rPDATC | 1<<4 ); //adj=1
for(i=0;i<1;i++);
rPDATC = ( rPDATC & (~(1<<4)) ); //adj=0
for(i=0;i<2;i++);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -