stdlf
分类:
2010-04-06 22:23:20
续上
/*
*********************************************************
* *
* LCD_On *
* LCD_Off *
* *
*********************************************************
*/
//关闭逆变电源ELLCD
void LCD_Off (void) {
Delay(100);
rPDATE = ( rPDATE & (~(1<<7)) );
Delay(100);
rPDATE = ( rPDATE | (1<<4) );
Delay(100);
rPDATE = ( rPDATE & (~(1<<5)) );
Delay(100);
}
//启动逆变电源LCDEL
void LCD_On (void) {
Delay(100);
rPDATE = ( rPDATE | (1<<7) );
Delay(100);
rPDATE = ( rPDATE | (1<<5) );
Delay(100);
rPDATE = ( rPDATE & (~(1<<4)) );
Delay(100);
}
void LCD_Init_Controler() {
int i,j;
#ifdef LCDMONO
//320x240 1bit/1pixel LCD
if((U32)frameBuffer1==0)
{
frameBuffer1=(unsigned int (*)[SCR_XSIZE/32])malloc(ARRAY_SIZE_MONO);
}
for(j=0;j<240;j++)
for(i=0;i<10;i++)
{
frameBuffer1[j][i]=0x0;
}
rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// disable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(10<<21);
// LINEBLANK=10
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);
// LCDBASSEL, MVAL
rLCDSADDR3= (LCD_XSIZE/16) | ( ((SCR_XSIZE-LCD_XSIZE)/16)<<9 );
// PAGEWIDTH, OFFSIZE (the number of halfwords)
// No virtual screen.
rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_MONO<<12);
// enable,4B_SNGL_SCAN,WDLY=16clk,WLH=16clk,
#endif
//********************************************************************************
#ifdef LCDG4
if((U32)frameBuffer4==0)
{
frameBuffer4=(unsigned int (*)[SCR_XSIZE/16])malloc(ARRAY_SIZE_G4);
}
for(j=0;j<240;j++)
for(i=0;i<20;i++)
{
frameBuffer4[j][i]=0x0;
}
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,
#endif
//********************************************************************************
#ifdef LCDG16
if((U32)frameBuffer16==0)
{
frameBuffer16=(unsigned int (*)[SCR_XSIZE/8])malloc(ARRAY_SIZE_G16);
}
for(j=0;j<320;j++)
for(i=0;i<30;i++)
{
frameBuffer16[j][i]=0;//字空间
}
//The following value has to be changed for better display.
/* rDITHMODE=0x1223a; //philips
rDP1_2 =0x5a5a;
rDP4_7 =0x366cd9b;
rDP3_5 =0xda5a7;
rDP2_3 =0xad7;
rDP5_7 =0xfeda5b7;
rDP3_4 =0xebd7;
rDP4_5 =0xebfd7;
rDP6_7 =0x7efdfbf;*/
rDITHMODE=0x12210;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
//rBLUELUT=0xfa50;
rLCDCON1=(0)|(1<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_G16<<12);
// disable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL<<10)|(20<<21);
//LINEBLANK=20 (without any calculation)
rLCDSADDR1= (0x2<<27) | ( ((U32)frameBuffer16>>22)<<21 ) | M5D((U32)frameBuffer16>>1);
// 16-gray, LCDBANK, LCDBASEU
rLCDSADDR2= M5D((((U32)frameBuffer16+(SCR_XSIZE*LCD_YSIZE/2))>>1)) | (MVAL<<21) | (0<<29);//(1<<29)时存储显示空间不对应
rLCDSADDR3= (LCD_XSIZE/4) | ( ((SCR_XSIZE-LCD_XSIZE)/4)<<9 );
rLCDCON1=(1)|(1<<5)|(MVAL_USED<<7)|(0x1<<8)|(0x1<<10)|(CLKVAL_G16<<12);
// enable,4B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
#endif
//
#ifdef LCDC256
//The following value has to be changed for better display.
rDITHMODE=0x12210;
rDP1_2 =0xa5a5;
rDP4_7 =0xba5da65;
rDP3_5 =0xa5a5f;
rDP2_3 =0xd6b;
rDP5_7 =0xeb7b5ed;
rDP3_4 =0x7dbe;
rDP4_5 =0x7ebdf;
rDP6_7 =0x7fdfbfe;
//Setup the LUT,add by lds
rREDLUT=0xfdca8520;
rGREENLUT=0xfdca8520;
rBLUELUT=0xfa50;
rLCDCON1=(0)|(0x2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_C256<<12);
// disable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
rLCDCON2=(LINEVAL)|(HOZVAL_COLOR<<10)|(10<<21);
//LINEBLANK=10 (without any calculation)
rLCDSADDR1= (0x3<<27) | ( ((U32)frameBuffer256>>22)<<21 ) | M5D((U32)frameBuffer256>>1);
// color mode, LCDBANK, LCDBASEU
rLCDSADDR2= M5D((((U32)frameBuffer256+ARRAY_SIZE_C256)>>1)) | (MVAL<<21);
rLCDSADDR3= (LCD_XSIZE/2) | ( ((SCR_XSIZE-LCD_XSIZE)/2)<<9 );
rLCDCON1=(1)|(0x2<<5)|(MVAL_USED<<7)|(0x3<<8)|(0x3<<10)|(CLKVAL_C256<<12);
// enable,8B_SNGL_SCAN,WDLY=8clk,WLH=8clk,
#endif
}
unsigned int LCD_L0_GetPixelIndex(int x, int y) {
return GetPixelIndex(x,y);
}
/*
*********************************************************
* *
* LCD_L0_SetLUTEntry *
* *
*********************************************************
*/
void LCD_L0_SetLUTEntry(U8 Pos, LCD_COLOR color) {
}
/*
*********************************************************
* *
* LCD_L0_ReInit : Re-Init the display *
* *
*********************************************************
ReInit contains all of the code that can be re-executed at any point without
changing or even disturbing what can be seen on the LCD.
Note that it is also used as a subroutine by LCD_Init().
*/
void LCD_L0_ReInit(void) {
LCD_Init_Controler(); /* macro defined in config */
}
/*
*********************************************************
* *
* LCD_Init : Init the display *
* *
*********************************************************
*/
int LCD_L0_Init(void) {
GUI_DEBUG_LOG("\nLCD_Init()");
/* Init controllers (except lookup table) */
LCD_L0_ReInit();
LCD_Off();
return 0; /* Init successfull ! */
}
/*
*********************************************************
* *
* LCD_L0_CheckInit *
* *
* Check if display controller(s) is/are still *
* properly initialized *
* *
*********************************************************
Return value: 0 => No error, init is O.K.
*/
int LCD_L0_CheckInit(void) {
return 0;
}
#else
void LCD13XX(void) { } /* avoid empty object files */
#endif /* (LCD_CONTROLLER == 0) */
3在UCGUI应用中有很多时间相关的函数,始终节拍变量OS_TimeMS必须及时更新,在我的应用中我利用了44B0X 的TIMER5计时中断来实现0S_TimeMS的自动更新
至此UCGUI 的基本移植完毕,可以写些简单程序调试了^_^