📄 lcd.c
字号:
}
void Test_Lcd_SER_24Bit_240320(void)
{
int i,j,k;
unsigned int tempval;
Init_240X320_AMLCD();
LcdBGInit(MODE_SER_24BIT_240320);
GlibInit(MODE_SER_24BIT_240320, BGBUFFER1);
printf("[256K COLOR(18bit/1pixel) Parallel Mode LCD TEST]\n");
GlibClearScr(0); // Fill the LCD panel with Black Color
LcdEnvidOnOff(1); // Enable ENVID Bit
getchar();
GlibFilledRectangle(0, 0, BG_XSIZE_240320/2-1, BG_YSIZE_240320-1,0);
GlibFilledRectangle(BG_XSIZE_240320/2 , 0, BG_XSIZE_240320-1, BG_YSIZE_240320-1,0xfcfcfc);
printf("256K Color Parallel mode test 1. Press any key to continue!\n");
getchar();
GlibClearScr(0); // Fill the LCD panel with Black Color
GlibFilledRectangle(0, 0, BG_XSIZE_240320/2-1, BG_YSIZE_240320/2-1, 0xfc0000); //red
GlibFilledRectangle(BG_XSIZE_240320/2, 0, BG_XSIZE_240320-1, BG_YSIZE_240320/2-1, 0xfc00);//green
GlibFilledRectangle(0, BG_YSIZE_240320/2, BG_XSIZE_240320/2-1, BG_YSIZE_240320-1,0xfc);//blue
GlibFilledRectangle(BG_XSIZE_240320/2, BG_YSIZE_240320/2, BG_XSIZE_240320-1, BG_YSIZE_240320-1,0xfcfcfc);//white
printf("256K Color Parallel mode test 2. Press any key to continue!\n");
getchar();
GlibClearScr(0); // Fill the LCD panel with White Color
k=0;
for(j=0; j<BG_YSIZE_240320; j+=16)
for(i=0; i<BG_XSIZE_240320; i+=16) {
tempval = ((85*((k>>4)%4))<<16) +((85*((k>>2)%4))<<8)+((85*(k%4)));
k++;
GlibFilledRectangle(i, j, i+15, j+15, tempval);
}
printf("256K Color Parallel mode test 3. Press any key to continue!\n");
getchar();
GlibClearScr(0); // Fill the LCD panel with White Color
k=0;
for(j=0; j<BG_YSIZE_240320; j+=10)
for(i=0; i<BG_XSIZE_240320; i+=10) {
tempval = ((85*((k>>4)%4))<<16) +((85*((k>>2)%4))<<8)+((85*(k%4)));
k++;
GlibFilledRectangle(i, j, i+9, j+9, tempval);
}
printf("256K Color Parallel mode test 4. Press any key to continue!\n");
getchar();
GlibClearScr(0); // Fill the LCD panel with Black Color
//First Quarter
GlibRectangle(0, 0, BG_XSIZE_240320-1, BG_YSIZE_240320-1, 0xfc0000); //red
GlibLine(0, 0, BG_XSIZE_240320-1, BG_YSIZE_240320-1, 0xcfc);//red
GlibLine(0, BG_YSIZE_240320-1, BG_XSIZE_240320-1, 0, 0xcfc);//red
//Second Quarter
GlibFilledRectangle(BG_XSIZE_240320, 0, BG_XSIZE_240320+29, 29, 0xfc0000);
GlibFilledRectangle(BG_VXSIZE_240320-30, 0, BG_VXSIZE_240320-1, 29, 0xfc00);
GlibFilledRectangle(BG_XSIZE_240320, BG_YSIZE_240320-30, BG_XSIZE_240320+29, BG_YSIZE_240320-1, 0xfc);
GlibFilledRectangle(BG_VXSIZE_240320-30, BG_YSIZE_240320-30, BG_VXSIZE_240320-1, BG_YSIZE_240320-1, 0xfcfcfc);
GlibRectangle(BG_XSIZE_240320, 0, BG_VXSIZE_240320-1, BG_YSIZE_240320-1, 0xfc0000);
GlibLine(BG_XSIZE_240320, 0, BG_VXSIZE_240320-1, BG_YSIZE_240320-1, 0xcfc);
GlibLine(BG_XSIZE_240320, BG_YSIZE_240320-1, BG_VXSIZE_240320-1, 0, 0xcfc);
//Third Quarter
GlibRectangle(0, BG_YSIZE_240320, BG_XSIZE_240320-1, BG_VYSIZE_240320-1, 0xfc0000);
GlibLine(0, BG_YSIZE_240320, BG_XSIZE_240320-1, BG_YSIZE_240320+BG_YSIZE_240320/2, 0xfcf000);
GlibLine(0, BG_VYSIZE_240320-1, BG_XSIZE_240320-1, BG_YSIZE_240320+BG_YSIZE_240320/2, 0xfcf000);
GlibLine(0, BG_YSIZE_240320+BG_YSIZE_240320/2, BG_XSIZE_240320-1, BG_YSIZE_240320, 0xfcf000);
GlibLine(0, BG_YSIZE_240320+BG_YSIZE_240320/2, BG_XSIZE_240320-1, BG_VYSIZE_240320-1, 0xfcf000);
//Fourth Quarter
GlibRectangle(BG_XSIZE_240320, BG_YSIZE_240320, BG_VXSIZE_240320-1, BG_VYSIZE_240320-1, 0xfc0000);
GlibLine(BG_XSIZE_240320, BG_YSIZE_240320, BG_XSIZE_240320+BG_XSIZE_240320/2, BG_VYSIZE_240320-1, 0xfcf000);
GlibLine(BG_VXSIZE_240320-1, BG_YSIZE_240320, BG_XSIZE_240320+BG_XSIZE_240320/2, BG_VYSIZE_240320-1, 0xfcf000);
GlibLine(BG_XSIZE_240320, BG_VYSIZE_240320-1, BG_XSIZE_240320+BG_XSIZE_240320/2, BG_YSIZE_240320, 0xfcf000);
GlibLine(BG_VXSIZE_240320-1, BG_VYSIZE_240320-1, BG_XSIZE_240320+BG_XSIZE_240320/2, BG_YSIZE_240320, 0xfcf000);
printf("256K Color Parallel mode test for Virtual Screen. Press any key[ijkm\\r]!\n");
MoveViewPort(MODE_SER_24BIT_240320, BGBUFFER1);
LcdMoveViewPort(0, 0, MODE_SER_24BIT_240320, BGBUFFER1);
LcdEnvidOnOff(0);
}
void Test_Lcd_SER_Backlight(void)
{
int i;
while (i != (-1))
{
printf("Choose Backlight brightness 0(Low) ~ 255(High) : ");
i = GetIntNum();
LcdBacklightOnOff(i);
}
}
void Test_Lcd_PAR_24Bit_Interrupt(void)
{
unsigned int i;
unsigned char cFifoSel;
unsigned char cFifoLevel;
unsigned char cFrameSel0;
unsigned char cFrameSel1;
Test_Lcd_24Bit_240320_On();
rLCDINTCON |= (1); // LCD interrupt enable
printf("****** Interrupt test!****** \nSelect interrupt type 1.VSYNC 2.FIFO trig. :");
i = GetIntNum();
if (i == 2)
{
printf("Type fifo interrupt select bit : ");
cFifoSel = GetIntNum();
printf("Type fifo trigger level : ");
cFifoLevel = GetIntNum();
LcdEnableFifoInterrupt(cFifoSel, cFifoLevel);
}
else
{
printf("Type Frame select bit 0 : ");
cFrameSel0 = GetIntNum();
printf("Type Frame select bit 1 : ");
cFrameSel1 = GetIntNum();
LcdEnableFrameInterrupt(cFrameSel0, cFrameSel1);
}
pISR_LCD = (unsigned)Lcd_Int;
rINTMSK &= ~(BIT_LCD);
rINTSUBMSK &= ~(BIT_SUB_LCD_VSYNC|BIT_SUB_LCD_FIFO);
printf("Press any key to exit!!\n");
getchar();
}
void __irq Lcd_Int_Pal(void)
{
unsigned volatile *palette;
unsigned int temp;
int i;
rGPJDAT &= ~(1<<15); // S42 switch
for(i=0; i<50; i++);
rGPJDAT |= (1<<15);
LcdEnvidOnOff(0);
rINTSUBMSK |= BIT_SUB_LCD_VSYNC; // Unmask Frame int
rINTMSK |= (BIT_LCD);
rSUBSRCPND = BIT_SUB_LCD_VSYNC; // Clear LCD SUB Interrupt source pending
ClearPending(BIT_LCD);
palette=(unsigned int *)PALETTEBG;
for(i=0;i<256;i++)
*palette++=DEMO256pal[i];// correction is needed
palette=(unsigned int *)PALETTEBG;
for(i=0; i<256; i++) {
temp = *palette++;
if((temp&0xffff) != DEMO256pal[i]) printf("Error:0x%x\n", temp&0xffff);
}
rGPJDAT &= ~(1<<15);
for(i=0; i<150; i++);
rGPJDAT |= (1<<15);
LcdEnvidOnOff(1);
}
void Test_Lcd_SER_8Bit_240320_Pal(void)
{
unsigned i,j,k=0;
unsigned volatile *palette;
unsigned temp;
Init_240X320_AMLCD();
PaletteInit(PAL_565_8BPPBG); // Initialize 256 palette
LcdBGInit(MODE_SER_8BIT_240320);
GlibInit(MODE_SER_8BIT_240320, BGBUFFER1);
rLCDCON1=(rLCDCON1&~(3<<28))|(2<<28); // burst setting
printf("[TFT LCD(240x320 ,8bpp) Pallette read/write Test]\n");
GlibClearScr(0); // Fill the LCD panel with Black Color
pISR_LCD = (unsigned)Lcd_Int_Pal;
rGPJCON = (rGPJCON & ~(3<<30)) | (1<<30); //eint15 -> output(GPJ15)
rLCDINTCON = (3<<10)|(1<<7)|1; // front porch, frame int enable, int enable
// LcdEnableFrameInterrupt(3, 0);
for(j=0; j<BG_YSIZE_240320; j+=16)
for(i=0; i<BG_XSIZE_240320; i+=16)
GlibFilledRectangle(i,j,i+15,j+15,(k++)%255);
LcdEnvidOnOff(1);
#if 1
while (getchar() != '\n')
{
rSUBSRCPND = BIT_SUB_LCD_VSYNC; // Clear LCD SUB Interrupt source pending
ClearPending(BIT_LCD);
rINTSUBMSK &= ~BIT_SUB_LCD_VSYNC; // Unmask Frame int
rINTMSK &= ~(BIT_LCD);
}
#endif
#if 1
palette=(unsigned volatile *)PALETTEBG;
while(1)
{
LcdEnvidOnOff(1); //envid on
// write
while ( (rLCDCON2&(3<<13)) != (3<<13) ); // front porch Vsync
palette=(unsigned int *)PALETTEBG;
for(i=0;i<256;i++)
*palette++=DEMO256pal[i];// correction is needed
getchar();
printf("garmin start!\n");
LcdEnvidOnOff(1); //envid on
Delay(1);
// read
while ( (rLCDCON2&(3<<13)) != (3<<13) ); // front porch Vsync
palette=(unsigned int *)PALETTEBG;
for(i=0; i<256; i++) {
temp = *palette++;
if((temp&0xffff) != DEMO256pal[i]) printf("Error:0x%x\n", temp&0xffff);
}
printf("garmin read!\n");
}
#endif
rGPJCON = (rGPJCON & ~(3<<30)) | (2<<30); //eint15
}
#define DEBUG_LCD 0
void iot(int time) // interval of test
{
#if DEBUG_LCD
getchar();
#else
Delay(time);
#endif
}
void Test_Lcd_SER_Functions(void) // 24bpp
{
int i,j,k;
unsigned int tempval;
/*
Init_240X320_AMLCD();
LcdBGInit(MODE_SER_24BIT_240320);
GlibInit(MODE_SER_24BIT_240320, BGBUFFER1);
printf("[LCD controller's several function test]\n");
GlibClearScr(0); // Fill the LCD panel with Black Color
LcdEnvidOnOff(1); // Enable ENVID Bit
getchar();
printf("Now Serial RGB mode. Press any key to continue!\n");
GlibFilledRectangle(0, 0, BG_XSIZE_240320/2-1, BG_YSIZE_240320/2-1, 0xfc0000); //red
GlibFilledRectangle(BG_XSIZE_240320/2, 0, BG_XSIZE_240320-1, BG_YSIZE_240320/2-1, 0xfc00);//green
GlibFilledRectangle(0, BG_YSIZE_240320/2, BG_XSIZE_240320/2-1, BG_YSIZE_240320-1,0xfc);//blue
GlibFilledRectangle(BG_XSIZE_240320/2, BG_YSIZE_240320/2, BG_XSIZE_240320-1, BG_YSIZE_240320-1,0xfcfcfc);//white
getchar();
*/
// DMA Burst test
printf("DMA 16-word burst test. Press any key to continue!\n");
rLCDCON1 &= ~(3<<28); // 16 word burst
iot(2);
printf("DMA 8-word burst test. Press any key to continue!\n");
rLCDCON1 = rLCDCON1 & ~(3<<28) | (1<<28); // 8 word burst
iot(2);
printf("DMA 4-word burst test. final burst of this test is 4. Press any key to continue!\n");
rLCDCON1 = rLCDCON1 & ~(3<<28) | (2<<28); // 4 word burst
iot(2); // final burst is 4 word
// VCLK test
printf("VCLK divider counter disable(power saving). Press any key to continue!\n");
rLCDCON1 &= ~(1<<19);
iot(2);
printf("VCLK divider counter enable. Press any key to continue!\n");
rLCDCON1 |= (1<<19);
iot(2);
printf("Direct clock input to VCLK(HCLK or UPLL clock). Press any key to continue!\n");
rLCDCON1 &= ~(1<<12); // direct clock(HCLK or UPLL clock)
iot(2);
printf("Divided clock input to VCLK(regular). Press any key to continue!\n");
rLCDCON1 |= (1<<12);
iot(2);
#if 0
printf("UPLL clock input test \n ");
///////////////////////// for UPLL test ////////////////////////
// for(j=0; j<0xfffff; j++)
// *temp++ = 0xffffff;
/*
temp = (unsigned int *)(LCDFRAMEBUFFERBG1-0x4b000);
for(j=0; j<0xE1000; j++)
*temp++ = 0xffffff;
*/
/*
GlibLine(0,319,239,319, 0x0000ff);
GlibLine(0,0,0,319, 0x0000ff);
GlibLine(239,0,239,319, 0x0000ff);
GlibLine(119,0,119,319, 0x00ff00);
GlibLine(0,0,239,0, 0xffffff);
printf("start addr 0x%x\n", (unsigned int *)0x11600000);
*/
// GlibFilledRectangle(239, 0, 479, 20, 0xffffff); //red
// GlibFilledRectangle(0, 320, 239, 340, 0xffffff); //red
LcdEnvidOnOff(1); // Enable ENVID Bit
rLCDCON1 |= (1<<11)|(2<<28); // upll clock
SetUPLL( 42, 1, 2); // 50MHz
printf("50\n");
getchar();
SetUPLL( 72, 3, 1); // 96MHz
printf("96\n");
getchar();
SetUPLL( 93, 4, 1); // 101MHz
printf("101\n");
getchar();
SetUPLL( 93, 4, 0); // 202MHz
printf("202\n");
getchar();
SetUPLL( 42, 2, 0); // 200MHz
printf("200\n");
getchar();
SetUPLL( 46, 1, 1); // 108MHz
printf("108\n");
rLCDCON1 &= ~(1<<11); // upll clock
getchar();
//////////////////////////////////////////////////////////
#endif
// PNR mode test
printf("Now Serial BGR mode. Press any key to continue!\n");
rLCDCON1 |= (3<<9); // BGR mode
getchar();
rLCDCON1 = rLCDCON1 & ~(3<<9) | (2<<9); // return to RGB mode
printf("Dual buffer test\n");
getchar();
LcdEnvidOnOff(0);
}
//->
// Sue.060322
// added for testing a basic function with LTV350 module
void Test_Lcd_PAR_16Bit_320240(void)
{
unsigned int i,j,k=0;
SetLcdPort();
Init_320X240_AMLCD();
LcdBGInit(MODE_PAR_16BIT565_320240);
GlibInit(MODE_PAR_16BIT565_320240, BGBUFFER1);
GlibClearScr(0); // Fill the LCD panel with Black Color
LcdEnvidOnOff(1); // Enable ENVID Bit
k=0;
for(j=0; j<BG_YSIZE_320240; j++)
for(i=0; i<BG_XSIZE_320240; i++)
PutPixel(i,j,winterhouse16bpp[k++]);
printf("\nIf you want to end this test, press any key\n");
getchar();
LcdEnvidOnOff(0);
}
//<-
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -