📄 displaylib.c
字号:
PutPixel(i,j,(i*j)&0xffffff);
lprintf(0,0,0xffffff,"24BPP(888) Non-paletteized mode.");
break;
case WINCONx_24BPP_A887:
if (win_num==0)
{
printf("This mode is not supported in window 0!!!\n");
return;
}
else
{
for(i=0;i<screen_width;i++)
for(j=0;j<screen_height;j++)
PutPixel(i,j,(i*j)&0xffffff);
lprintf(0,0,0xffffff,"24BPP(A887) Non-paletteized mode.");
}
break;
case WINCONx_25BPP_A888:
if (win_num==0)
{
printf("This mode is not supported in window 0!!!\n");
return;
}
else
{
for(i=0;i<screen_width;i++)
for(j=0;j<screen_height;j++)
PutPixel(i,j,(i*j)&0x1ffffff);
lprintf(0,0,0x1ffffff,"25BPP(A888) Non-paletteized mode.");
}
break;
default:
break;
}
}
void Prepare_Pallet(int8 win_num, int8 bpp)
{
uint32 *pallet_ptr, i;
//pallet format => 16bit(565)
rWPALCON = (6<<3)|(6<<0);
// palette can be updated
rWPALCON |= (1<<9);
pallet_ptr =(uint32 *)WINxPalletBase[win_num];
switch(bpp)
{
case WINCONx_1BPP_PALLET:
*(pallet_ptr+0) = 0x0000;
*(pallet_ptr+1) = 0xffff;
break;
case WINCONx_2BPP_PALLET:
*(pallet_ptr+0) = 0x0000;
*(pallet_ptr+1) = 0xf800;
*(pallet_ptr+2) = 0x07e0;
*(pallet_ptr+3) = 0x001f;
break;
case WINCONx_4BPP_PALLET:
*(pallet_ptr+0) = 0x0000;
*(pallet_ptr+1) = 0xf800;
*(pallet_ptr+2) = 0x07e0;
*(pallet_ptr+3) = 0x001f;
*(pallet_ptr+4) = 0xf81f;
*(pallet_ptr+5) = 0xffe0;
*(pallet_ptr+6) = 0x07ff;
*(pallet_ptr+7) = 0xffff;
*(pallet_ptr+8) = 0x18e3;
*(pallet_ptr+9) = 0x7800;
*(pallet_ptr+10) = 0x03e0;
*(pallet_ptr+11) = 0x000f;
*(pallet_ptr+12) = 0x780f;
*(pallet_ptr+13) = 0x7be0;
*(pallet_ptr+14) = 0x03ef;
*(pallet_ptr+15) = 0x7bef;
break;
case WINCONx_8BPP_PALLET:
if(lcd_type == LCD_MODULE_LTS222) // Portrait
{
for(i=0;i<256;i++)
*(pallet_ptr+i) = (uint32)DEMO256pal[i];
}
else if(lcd_type == LCD_MODULE_LTV350 || lcd_type == LCD_MODULE_LTE480WV) // Landscape
{
for(i=0;i<256;i++) // 332 to 565 convert(higher value weight)
{
if( (i & 0x3)|(i & 0x1c)|(i & 0xe0) )
*(pallet_ptr+i) = (i&0xe0)<<8 | (i&0x1c)<<6 | (i&0x3)<<3;
// *(pallet_ptr+i) = (i&0xe0)<<8 | ((i&0x1c)>>2)<<8 | (i&0x3)<<3;
else
*(pallet_ptr+i) = 0;
// printf("%02x=%04x, ", i,*(pallet_ptr+i));
}
#if 0
for(i=0;i<256;i++) // 332 to 565 convert(lower value weight)
{
if( (i & 0x3)|(i & 0x1c)|(i & 0xe0) )
*(pallet_ptr+i) = ((i&0xe0)>>5)<<11 | ((i&0x1c)>>2)<<5 | (i&0x3);
else
*(pallet_ptr+i) = 0;
printf("%02x=%04x, ", i,*(pallet_ptr+i));
}
#endif
}
break;
default :
break;
}
rWPALCON &= ~(1<<9);
}
void LcdEnvidOnOff(uint8 onoff)
{
if(onoff==LCD_ON)
rVIDCON0 |= (3); // ENVID On using Per Frame method
else
{
rVIDCON0 &= (~1); // ENVID Off using Per Frame method
if(lcd_if==I80_IF)
rCPUTRIGCON2=1;
while( rVIDCON0 & 1); // Check end of frame
}
}
void LcdWindowOnOff(uint8 num, uint8 onoff)
{
switch(num)
{
case LCD_WIN_0:
if(onoff==LCD_ON)
rWINCON0 |= 0x01;
else
rWINCON0 &= ~0x01;
break;
case LCD_WIN_1:
if(onoff==LCD_ON)
rWINCON1 |= 0x01;
else
rWINCON1 &= ~0x01;
break;
case LCD_WIN_ALL:
if(onoff==LCD_ON)
{
rWINCON0 |= 0x01;
rWINCON1 |= 0x01;
}
else
{
rWINCON0 &= ~0x01;
rWINCON1 &= ~0x01;
}
default:
break;
}
return;
}
//
//===================================================
//===================================================
// functions related to LDI initialization
//
// 0: LTE480WV-800x480(WVGA, 4.80\", Landscape)
// 1: LTV350 -320x240(QVGA, 3.50\", Landscape)
// 2: LTS222 -240x320(QVGA, 2.22\", Portrait) RGB Parallel I/F
// 3: LTS222 -240x320(QVGA, 2.22\", Portrait) RGB Serial I/F
// 4: LTS222 -240x320(QVGA, 2.22\", Portrait) i80 I/F
void Init_LDI(void)
{
switch(lcd_module)
{
case LCD_MODULE_LTE480WV:
lcd_horizon_value = LTE480_HOZVAL;
lcd_line_value = LTE480_LINEVAL;
lcd_vbpd = LTE480_VBPD;
lcd_vfpd = LTE480_VFPD;
lcd_vspw = LTE480_VSPW;
lcd_hbpd = LTE480_HBPD;
lcd_hfpd = LTE480_HFPD;
lcd_hspw = LTE480_HSPW;
printf("Enter Frame Rate..\n");
lcd_frame_rate = GetIntNum();
//lcd_frame_rate = LTE480_FRAME_RATE;
//InitLDI_LTE480();
break;
case LCD_MODULE_LTV350:
lcd_horizon_value = LTV350_HOZVAL;
lcd_line_value = LTV350_LINEVAL;
lcd_vbpd = LTV350_VBPD;
lcd_vfpd = LTV350_VFPD;
lcd_vspw = LTV350_VSPW;
lcd_hbpd = LTV350_HBPD;
lcd_hfpd = LTV350_HFPD;
lcd_hspw = LTV350_HSPW;
lcd_frame_rate = LTV350_FRAME_RATE;
InitLDI_LTV350();
break;
case LCD_MODULE_LTS222:
lcd_horizon_value = LTS222_HOZVAL;
lcd_line_value = LTS222_LINEVAL;
lcd_vbpd = LTS222_VBPD;
lcd_vfpd = LTS222_VFPD;
lcd_vspw = LTS222_VSPW;
lcd_hbpd = LTS222_HBPD;
lcd_hfpd = LTS222_HFPD;
lcd_hspw = LTS222_HSPW;
lcd_frame_rate = LTS222_FRAME_RATE;
InitLDI_LTS222();
break;
case LCD_MODULE_LTS222_SERIAL:
lcd_horizon_value = LTS222_HOZVAL_SERIAL;
lcd_line_value = LTS222_LINEVAL_SERIAL;
lcd_vbpd = LTS222_VBPD_SERIAL;
lcd_vfpd = LTS222_VFPD_SERIAL;
lcd_vspw = LTS222_VSPW_SERIAL;
lcd_hbpd = LTS222_HBPD_SERIAL;
lcd_hfpd = LTS222_HFPD_SERIAL;
lcd_hspw = LTS222_HSPW_SERIAL;
lcd_frame_rate = LTS222_FRAME_RATE;
InitLDI_LTS222();
break;
case LCD_MODULE_LTS222_CPUIF:
lcd_horizon_value = LTS222_HOZVAL;
lcd_line_value = LTS222_LINEVAL;
lcd_cs_setup = LTS222_CS_SETUP;
lcd_wr_setup = LTS222_WR_SETUP;
lcd_wr_act = LTS222_WR_ACT;
lcd_wr_hold = LTS222_WR_HOLD;
lcd_frame_rate = LTS222_FRAME_RATE;
InitLDI_LTS222_CPUIF();
break;
default:
break;
}
printf("LDI Initialization is finished...\n\n");
LCDC_Common_Init();
}
void Temp_forDebug(uint32 i,uint32 j)
{
uint8 ch=0;
printf(" * Write_LDI(0x%02x, 0x%04x) *\n",i,j);
while(!ch)
ch = Uart_GetKey();
if(ch=='x')
debug_continue=FALSE;
}
void InitLDI_LTE480(void)
{
uFrameCount=0;
pISR_LCD = (unsigned)Display_ISR_FrameCount;
rVIDINTCON = (1<<15)|(1<<12)|(1<<0); //frame
rVIDINTCON |= (1<<0); //frame
rINTSUBMSK &= ~(1<<16);//RGB I/F
rINTMSK &= ~(1<<16);
Display_Start(LCD_WIN_ALL);
while(1)
{
if(uFrameCount == 8) // for tvsync-don time in LTE480WV spec
{
rINTMSK |= (1<<16);
break;
}
}
rGPBDAT |= (1<<1); // PCI High
LcdWindowOnOff(LCD_WIN_ALL, LCD_OFF);
LcdEnvidOnOff(LCD_OFF);
}
void __irq Display_ISR_FrameCount(void)
{
rINTSUBMSK |= (1<<16);
rINTMSK |= (1<<16);
rVIDINTCON &= ~(1<<0); //frame
printf(".");
if(uFrameCount<8)
uFrameCount++;
rSUBSRCPND |= (1<<16);
rSUBSRCPND = 0xffffffff;
ClearPending(BIT_LCD);
rINTMSK &= ~(1<<16);
rINTSUBMSK &= ~(1<<16);
rVIDINTCON |= (1<<0); //frame
}
void InitLDI_LTS222(void)
{
// LCD module reset
rGPBDAT |= (1<<1);
rGPBDAT &= ~(1<<1); // goes to LOW
// delay about 5ms
delayLoop(LCD_DELAY_1MS*10);
rGPBDAT |= (1<<1); // goes to HIGH
//debug_continue = TRUE;
debug_continue = FALSE;
// delay about 10ms
delayLoop(LCD_DELAY_1MS*10);
LCD_DEN_Hi;
LCD_DCLK_Hi;
LCD_DSERI_Hi;
///////////////////////////////////////////////////////////////////
// Power Setting Function 1
//////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x22,0x01); // PARTIAL 2 DISPLAY AREA RASTER-ROW NUMBER REGISTER 1
Write_LDI_LTS222(0x03,0x01); // RESET REGISTER
///////////////////////////////////////////////////////////////////
// Initializing Function 1
///////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x00,0xa0); // CONTROL REGISTER 1
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x01,0x10); // CONTROL REGISTER 2
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x02,0x00); // RGB INTERFACE REGISTER
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x05,0x00); // DATA ACCESS CONTROL REGISTER
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x0D,0x00); //
// delay about 40ms
delayLoop(LCD_DELAY_1MS*40);
///////////////////////////////////////////////////////////////////
// Initializing Function 2
///////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x0E,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x0F,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x10,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x11,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x12,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x13,0x00); // DISPLAY SIZE CONTROL REGISTER
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x14,0x00); // PARTIAL-OFF AREA COLOR REGISTER 1
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x15,0x00); // PARTIAL-OFF AREA COLOR REGISTER 2
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x16,0x00); // PARTIAL 1 DISPLAY AREA STARTING REGISTER 1
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x17,0x00); // PARTIAL 1 DISPLAY AREA STARTING REGISTER 2
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x34,0x01); // POWER SUPPLY SYSTEM CONTROL REGISTER 14
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x35,0x00); // POWER SUPPLY SYSTEM CONTROL REGISTER 7
// delay about 40ms
delayLoop(LCD_DELAY_1MS*40);
////////////////////////////////////////////////////////////////////
// Initializing Function 3
////////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x8D,0x01); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x8B,0x28); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x4B,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x4C,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x4D,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x4E,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x4F,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x50,0x00); // ID CODE REGISTER 2 Check it out
// delay about 50 us
delayLoop(LCD_DELAY_50US);
Write_LDI_LTS222(0x86,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x87,0x26); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x88,0x02); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x89,0x05); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x33,0x01); // POWER SUPPLY SYSTEM CONTROL REGISTER 13
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x37,0x06); // POWER SUPPLY SYSTEM CONTROL REGISTER 12 Check it out
// delay about 50 us
delayLoop(LCD_DELAY_50US);
Write_LDI_LTS222(0x76,0x00); // SCROLL AREA START REGISTER 2
// delay about 40ms
delayLoop(LCD_DELAY_1MS*40);
/////////////////////////////////////////////////////////////////////
// Initializing Function 4
/////////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x42,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x43,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x44,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x45,0x00); // CALIBRATION REGISTER
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x46,0xef); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x47,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x48,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x49,0x01); // ID CODE REGISTER 1 check it out
// delay about 50 us
delayLoop(LCD_DELAY_50US);
Write_LDI_LTS222(0x4A,0x3f); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x3C,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x3D,0x00); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x3E,0x01); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x3F,0x3f); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x40,0x01); // horizontal back porch //050105 Boaz.Kim
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x41,0x0a); // horizontal back porch //050105 Boaz.Kim
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x8F,0x05); //
// delay about 40ms
delayLoop(LCD_DELAY_1MS*40);
/////////////////////////////////////////////////////////////////////
// Initializing Function 5
/////////////////////////////////////////////////////////////////////
Write_LDI_LTS222(0x90,0x05); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x91,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x92,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x93,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x94,0x33); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x95,0x05); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x96,0x05); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x97,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x98,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x99,0x44); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x9A,0x33); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x9B,0x33); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
Write_LDI_LTS222(0x9C,0x33); //
delayLoop(LCD_DELAY_300NS); // delay about 300ns
if(lcd_module== LCD_MODULE_LTS222_SERIAL)
Write_LDI_LTS222(0x9D,0x81); // 6bit RGB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -