📄 display.c
字号:
delayLoop(30000000);
/* Ending Test */
Display_End(LCD_WIN_ALL);
}
#endif
//==========================================
// ColorMap Test function
//==========================================
void Test_ColorMap(void)
{
int8 window=-1;
uint32 color_map=0;
Make_Image(0,0,1);
Display_Start(0);
while(1)
{
printf("\nColor Map test: Select the window # which you want to test\n");
printf("(If you want to stop this test, press enter key)\n");
printf(" 0: Window 0 1: Window 1 \n");
window = GetIntNum();
if( window==(-1) ) return;
else
{
switch(window)
{
case 0:
color_map = 0xffff00;
break;
case 1:
color_map = 0x00ffff;
break;
default:
color_map = 0;
break;
}
LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
LcdEnvidOnOff(LCD_OFF);
Basic_Display_Setting(window,LCD_BUF_0,WINCONx_24BPP_888,lcd_horizon_value,lcd_line_value);
LCD_ClearScr(0);
*WINxMAP_Reg_Addr[window] = (1<<24)|(color_map); //color map enable
Display_Start(window);
Display_End(window);
}
}
}
//==========================================
// Framebuffer auto change Test function
//==========================================
void Test_Buffer_Autochange(void)
{
char i;
if(lcd_if==I80_IF)
{
printf("\ni80 I/F Frame buffer auto change test\n");
printf("Press any key to start\n");
// Window0, Framebuffer0
Basic_Display_Setting(0,0,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);
LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xf800);
LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x7e0);
LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x1f);
LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xffff);
lprintf(50,20,0xffff,"Win0 Buf0");
// Window0, Framebuffer1
Basic_Display_Setting(0,1,WINCONx_16BPP_565,lcd_horizon_value,lcd_line_value);
LCD_FilledRectangle(0, 0, screen_width-1, screen_height/4*1-1, 0xffff);
LCD_FilledRectangle(0, screen_height/4*1, screen_width-1, screen_height/4*2-1, 0x1f);
LCD_FilledRectangle(0, screen_height/4*2, screen_width-1, screen_height/4*3-1, 0x7e0);
LCD_FilledRectangle(0, screen_height/4*3, screen_width-1, screen_height-1, 0xf800);
lprintf(50,20,0x0,"Win0 Buf1");
rWINCON0 |= 1<<22; // Auto change enable
Display_Start(0);
Uart_getc();
printf("Press \"1\" to change Frame buffer\n\n");
while (1)
{
if( rWINCON0 & 1<<24 )
printf("Buffer 1\n");
else
printf("Buffer 0\n");
printf("If you want to exit press any key\n");
rCPUTRIGCON2 = 1;
i=Uart_getc();
if(i!='1')
break;
}
LcdBacklightCon(LCD_OFF);
LcdWindowOnOff(0,LCD_OFF);
LcdEnvidOnOff(LCD_OFF);
}
else
printf("Frame buffer auto-change function supports only i80 I/F\n");
rWINCON0 &= ~(1<<22); // Auto change disable
return;
}
//==========================================
// Interrupt Test function(window 1)
//==========================================
#define SRAM_Low 0x40000000
#define SRAM_High 0x40001000
volatile U16 *active_addr;
volatile U16 *inactive_addr;
volatile int wait, pre_wait;
void __irq Exit(void)
{
printf("wait=%d\n", wait);
wait=0;
ClearPending(BIT_EINT0);
rEINTPEND=(1<<0);
}
void Test_Interrupt(void)
{
int8 interrupt=-1;
uint8 frame_int_type=0;
uint8 fifo_level=0;
uint8 burst_length=0;
int i;
rGPBCON &= ~(0x3<<10); // GPB5 output
rGPBCON |= (1<<10); // GPB5 output
rGPBDAT &= ~(1<<5); // low
rGPFCON = (rGPFCON & ~0x3)|(2<<0); //GPF0 = EINT0
rGPFUDP= (rGPFUDP & ~0x3); //GPF0 up down disable
rEXTINT0 = (rEXTINT0 & ~(7<<0)) | (0x2<<0) ; //EINT0=falling edge triggered
pISR_EINT0= (U32)Exit;
rEINTPEND = 0xffffff;
rSRCPND = BIT_EINT0;
rINTPND = BIT_EINT0;
rEINTMASK &= ~(1<<0);
rINTMSK &= ~(BIT_EINT0);
Make_Image(0, 0, 0);
Make_Image(1, 0, 1);
*VIDOSDxC_Reg_Addr[1] = (0x9<<20)|(0x9<<16)|(0x9<<12)|(0x9<<8)|(0x9<<4)|(0x9<<0);
while(1)
{
printf("\nSelect Frame-Interrupt or FIFO-Interrupt\n");
printf("(If you want to stop this test, press enter key)\n");
printf(" 1: Frame-Interrupt 2: FIFO-Interrupt\n");
LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
LcdEnvidOnOff(LCD_OFF);
interrupt = GetIntNum();
if( interrupt==(-1) )
return;
else
{
if(interrupt == 1)
{
pISR_LCD = (unsigned)Display_ISR;
rINTMSK &= ~(1<<16);
if(lcd_if==I80_IF)
{
printf("\nSending interrupt will be occured one time. Enter any key\n");
rVIDINTCON = (0x3f<<20)|(1<<19)|(1<<17)|(1<<0);
rINTSUBMSK &= ~(1<<17);//i80 I/F Tx complete
}
else
{
printf("\nSelect the Frame-Interrupt type which you want to test\n");
printf(" 0: Back Porch 1: VSYNC 2: ACTIVE 3: Front Porch\n");
frame_int_type = GetIntNum();
rVIDINTCON = (0x3f<<20)|(frame_int_type<<15)|(1<<12)|(1<<0);
rINTSUBMSK &= ~(1<<16);//RGB I/F Frame
}
}
else if(interrupt == 2)
{
active_addr = (U16 *)SRAM_Low;
inactive_addr = (U16 *)SRAM_High;
for(i=0;i<700;i++)
*active_addr++=0xffff;
for(i=0;i<700;i++)
*inactive_addr++=0xffff;
active_addr = (U16 *)SRAM_Low;
inactive_addr = (U16 *)SRAM_High;
wait=700;pre_wait=0;
printf("\nFIFO Interrupt: Window 0\n");
printf("\nSelect DMA burst length\n");
printf(" 0: 16-word 1: 8-word 2: 4-word\n");
burst_length = GetIntNum();
*WINCONx_Reg_Addr[LCD_WIN_0] &= ~(3<<WINCON_BURSTLEN_S);
*WINCONx_Reg_Addr[LCD_WIN_0] |= (burst_length<<WINCON_BURSTLEN_S);
*WINCONx_Reg_Addr[LCD_WIN_1] &= ~(3<<WINCON_BURSTLEN_S);
*WINCONx_Reg_Addr[LCD_WIN_1] |= (burst_length<<WINCON_BURSTLEN_S);
printf("\nSelect the FIFO-level\n");
printf(" 0: 1/4 left 1: 1/2 left 2: 3/4 left 3: empty 4: full\n");
fifo_level = GetIntNum();
rVIDINTCON = (0x0<<20)|(3<<5)|(fifo_level<<2)|(3<<0);
pISR_LCD = (unsigned)Display_ISR;
rINTMSK &= ~(1<<16);
rINTSUBMSK &= ~(1<<15);//FIFO interrupt
}
else
break;
printf("\nSelect Display windows\n");
printf(" 0: Window 0 only 1: Window 1 only 2: All blended Windows\n");
Display_Start(GetIntNum());
//Display_Start(LCD_WIN_0);
if(interrupt == 2)
{
while(wait)
{
if(pre_wait != wait)
printf("%d ",wait);
pre_wait=wait;
}
}
Display_End(LCD_WIN_ALL);
rVIDINTCON = (0x3f<<20)|0; //disable interrupt
rINTMSK |= 1<<16;
rINTSUBMSK |= 7<<15;
*WINCONx_Reg_Addr[LCD_WIN_0] &= ~(3<<WINCON_BURSTLEN_S);
*WINCONx_Reg_Addr[LCD_WIN_0] |= (lcd_burst_mode<<WINCON_BURSTLEN_S);
if(interrupt == 2)
{
active_addr = (U16 *)SRAM_Low;
inactive_addr = (U16 *)SRAM_High;
printf("Active\n");
for(i=1;i<701;i++)
{
printf("%03d \t",*active_addr++);
if((i%10)==0)
printf("\n");
}
printf("Inactive\n");
for(i=1;i<701;i++)
{
printf("%03d \t",*inactive_addr++);
if((i%10)==0)
printf("\n");
}
active_addr = (U16 *)SRAM_Low;
inactive_addr = (U16 *)SRAM_High;
}
}
}
rEINTMASK=0xffffff;
rINTMSK=BIT_ALLMSK;
}
void __irq Display_ISR(void)
{
rGPBDAT |= (1<<5); // high
if((rVIDCON1&0x7800)==0x5800) // Active area
*active_addr++=((rVIDCON1&0x7ff0000)>>16);
else // Inactive area
*inactive_addr++=((rVIDCON1&0x7ff0000)>>16);
if(wait>0)
wait--;
rSUBSRCPND |= (1<<15);
ClearPending(BIT_LCD);
rGPBDAT &= ~(1<<5); // low
}
#if 0
void __irq Display_ISR(void)
{
int lcdpend;
lcdpend= rSUBSRCPND & (3<<15);
if( lcdpend == (1<<15) ) // FIFO interrupt
{
/*
if((rVIDCON1&0x7800)==0x5800)// Real under-run(active area)
printf("x:%03d ", (rVIDCON1&0x7ff0000)>>16 );
printf("<%03d> ", (rVIDCON1&0x7ff0000)>>16 );
*/
if((rVIDCON1&0x7800)==0x5800) // Active area
*active_addr++=((rVIDCON1&0x7ff0000)>>16);
else // Inactive area
*inactive_addr++=((rVIDCON1&0x7ff0000)>>16);
if(wait>0)
wait--;
rSUBSRCPND |= (1<<15);
}
else if( lcdpend == (1<<16) )// Frame interrupt
{
// To do
printf("*");
rSUBSRCPND |= (1<<16);
}
else // i80 I/F sending complete
{
// To do
printf("i80\n");
rSUBSRCPND |= (1<<17);
}
ClearPending(BIT_LCD);
}
#endif
//==========================================
// Virtual Screen Test Function
//==========================================
void Test_Virtual_Screen(void)
{
uint32 i;
uint32 byte_pixel;
LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
LcdEnvidOnOff(LCD_OFF);
Basic_Display_Setting(LCD_WIN_0,LCD_BUF_0,WINCONx_24BPP_888,lcd_horizon_value*2,lcd_line_value*2);
LCD_ClearScr(0);
lprintf(0,0,0xffffff,"123456789012345678901234567890123456789012345678901234567890");
lprintf(0,50,0xffffff,"123456789012345678901234567890123456789012345678901234567890");
lprintf(0,100,0xffffff,"123456789012345678901234567890123456789012345678901234567890");
lprintf(0,150,0xffffff,"123456789012345678901234567890123456789012345678901234567890");
Display_Start(LCD_WIN_0);
printf("Press any key to start.\n");
getchar();
byte_pixel = lcd_bit_order[WINCONx_24BPP_888]/8;
for(i=0;i<100;i++) {
*VIDWxADD0_Reg_Addr[LCD_WIN_0][LCD_BUF_0] = (uint32)lcd_framebuffer + i*byte_pixel + i*lcd_horizon_value*2*byte_pixel;
*VIDWxADD1_Reg_Addr[LCD_WIN_0][LCD_BUF_0] = (uint32)lcd_framebuffer + i*byte_pixel + i*lcd_horizon_value*2*byte_pixel + lcd_horizon_value*2*byte_pixel*lcd_line_value;
*VIDWxADD2_Reg_Addr[LCD_WIN_0][LCD_BUF_0] = ((lcd_horizon_value*byte_pixel)<<13)|(lcd_horizon_value*byte_pixel);
if(lcd_if==I80_IF)
rCPUTRIGCON2=1;
delayLoop(1000000);
}
Display_End(LCD_WIN_0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -