📄 lcdinit.c
字号:
#include "def.h"
#include "2440addr.h"
#include "2440lib.h"
#include "2440slib.h"
#include "bootpara.h"
#include "lcdlib.h"
#include <string.h>
LCD_CONFIG lcd_config;
U16 (*frameBuffer16Bit240X320Tft)[SCR_XSIZE_TFT_240320];
U16 (*frameBuffer16Bit320240Tft)[SCR_XSIZE_TFT_320240];
U16 (*frameBuffer16Bit480272Tft)[SCR_XSIZE_TFT_480272];
U16 (*frameBuffer16Bit640480Tft)[SCR_XSIZE_TFT_640480];
void lcd240320_init(void)
{
int x;
int y;
frameBuffer16Bit240X320Tft=(U16 (*)[SCR_XSIZE_TFT_240320])LCDFRAMEBUFFER;
rLCDCON1 = lcd_config.lcdcon1;
rLCDCON2 = lcd_config.lcdcon2;
rLCDCON3 = lcd_config.lcdcon3;
rLCDCON4 = lcd_config.lcdcon4;
rLCDCON5 = lcd_config.lcdcon5;
rLCDSADDR1=(((U32)frameBuffer16Bit240X320Tft>>22)<<21)|M5D((U32)frameBuffer16Bit240X320Tft>>1);
rLCDSADDR2=M5D( ((U32)frameBuffer16Bit240X320Tft+(lcd_config.scr_xsize*lcd_config.ysize*2))>>1 );
rLCDSADDR3=(((lcd_config.scr_xsize-lcd_config.xsize)/1)<<11)|(lcd_config.xsize/1);
rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
rTCONSEL&=~((1<<4)|1); // Disable LCC3600, LPC3600
rTPAL=0; // Disable Temp Palette
rLCDCON1|=1; // ENVID=ON
#if 0
Uart_Printf( "\nrGPBCON=0x%x\n", rGPBCON );
Uart_Printf( "\trGPBUP=0x%x\n", rGPBUP );
Uart_Printf( "rGPCCON=0x%x\n", rGPCCON );
Uart_Printf( "\trGPCUP=0x%x\n", rGPCUP );
Uart_Printf( "rGPDCON=0x%x\n", rGPDCON );
Uart_Printf( "\trGPDUP=0x%x\n", rGPDUP );
Uart_Printf( "rGPGCON=0x%x\n", rGPGCON );
Uart_Printf( "\trGPGUP=0x%x\n\n", rGPGUP );
Uart_Printf( "rLCDCON1=0x%x\n", rLCDCON1 );
Uart_Printf( "rLCDCON2=0x%x\n", rLCDCON2 );
Uart_Printf( "rLCDCON3=0x%x\n", rLCDCON3 );
Uart_Printf( "rLCDCON4=0x%x\n", rLCDCON4 );
Uart_Printf( "rLCDCON5=0x%x\n\n", rLCDCON5 );
Uart_Printf( "rLCDSADDR1=0x%x\n", rLCDSADDR1 );
Uart_Printf( "rLCDSADDR2=0x%x\n", rLCDSADDR2 );
Uart_Printf( "rLCDSADDR3=0x%x\n\n", rLCDSADDR3 );
Uart_Printf( "rLCDINTMSK=0x%x\n", rLCDINTMSK );
Uart_Printf( "rTCONSEL=0x%x\n", rTCONSEL );
Uart_Printf( "rTPAL=0x%x\n\n", rTPAL );
Uart_Printf( "lcd_config.ysize=0x%x\n\n", lcd_config.ysize );
Uart_Printf( "lcd_config.xsize=0x%x\n\n", lcd_config.xsize );
#endif
#if 1
for(y=0; y<lcd_config.ysize; y++)
for(x=0; x<lcd_config.xsize; x++)
frameBuffer16Bit240X320Tft[y][x] = COLOR_RED_TFT16;
for(y=10; y<lcd_config.ysize-10; y++)
for(x=10; x<lcd_config.xsize-10; x++)
frameBuffer16Bit240X320Tft[y][x] = COLOR_GREEN_TFT16;
for(y=20; y<lcd_config.ysize-20; y++)
for(x=20; x<lcd_config.xsize-20; x++)
frameBuffer16Bit240X320Tft[y][x] = COLOR_BLUE_TFT16;
#endif
}
void lcd320240_init(void)
{
int x;
int y;
frameBuffer16Bit320240Tft=(U16 (*)[SCR_XSIZE_TFT_320240])LCDFRAMEBUFFER;
rLCDCON1 = lcd_config.lcdcon1;
rLCDCON2 = lcd_config.lcdcon2;
rLCDCON3 = lcd_config.lcdcon3;
rLCDCON4 = lcd_config.lcdcon4;
rLCDCON5 = lcd_config.lcdcon5;
rLCDSADDR1=(((U32)frameBuffer16Bit320240Tft>>22)<<21)|M5D((U32)frameBuffer16Bit320240Tft>>1);
rLCDSADDR2=M5D( ((U32)frameBuffer16Bit320240Tft+(lcd_config.scr_xsize*lcd_config.ysize*2))>>1 );
rLCDSADDR3=(((lcd_config.scr_xsize-lcd_config.xsize)/1)<<11)|(lcd_config.xsize/1);
rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
rTCONSEL&=~((1<<4)|1); // Disable LCC3600, LPC3600
rTPAL=0; // Disable Temp Palette
rLCDCON1|=1; // ENVID=ON
#if 0
Uart_Printf( "\nrGPBCON=0x%x\n", rGPBCON );
Uart_Printf( "\trGPBUP=0x%x\n", rGPBUP );
Uart_Printf( "rGPCCON=0x%x\n", rGPCCON );
Uart_Printf( "\trGPCUP=0x%x\n", rGPCUP );
Uart_Printf( "rGPDCON=0x%x\n", rGPDCON );
Uart_Printf( "\trGPDUP=0x%x\n", rGPDUP );
Uart_Printf( "rGPGCON=0x%x\n", rGPGCON );
Uart_Printf( "\trGPGUP=0x%x\n\n", rGPGUP );
Uart_Printf( "rLCDCON1=0x%x\n", rLCDCON1 );
Uart_Printf( "rLCDCON2=0x%x\n", rLCDCON2 );
Uart_Printf( "rLCDCON3=0x%x\n", rLCDCON3 );
Uart_Printf( "rLCDCON4=0x%x\n", rLCDCON4 );
Uart_Printf( "rLCDCON5=0x%x\n\n", rLCDCON5 );
Uart_Printf( "rLCDSADDR1=0x%x\n", rLCDSADDR1 );
Uart_Printf( "rLCDSADDR2=0x%x\n", rLCDSADDR2 );
Uart_Printf( "rLCDSADDR3=0x%x\n\n", rLCDSADDR3 );
Uart_Printf( "rLCDINTMSK=0x%x\n", rLCDINTMSK );
Uart_Printf( "rTCONSEL=0x%x\n", rTCONSEL );
Uart_Printf( "rTPAL=0x%x\n\n", rTPAL );
Uart_Printf( "lcd_config.ysize=0x%x\n\n", lcd_config.ysize );
Uart_Printf( "lcd_config.xsize=0x%x\n\n", lcd_config.xsize );
#endif
#if 1
for(y=0; y<lcd_config.ysize; y++)
for(x=0; x<lcd_config.xsize; x++)
frameBuffer16Bit320240Tft[y][x] = COLOR_RED_TFT16;
for(y=10; y<lcd_config.ysize-10; y++)
for(x=10; x<lcd_config.xsize-10; x++)
frameBuffer16Bit320240Tft[y][x] = COLOR_GREEN_TFT16;
for(y=20; y<lcd_config.ysize-20; y++)
for(x=20; x<lcd_config.xsize-20; x++)
frameBuffer16Bit320240Tft[y][x] = COLOR_BLUE_TFT16;
#endif
}
void lcd480272_init(void)
{
int x;
int y;
frameBuffer16Bit480272Tft=(U16 (*)[SCR_XSIZE_TFT_480272])LCDFRAMEBUFFER;
rLCDCON1 = lcd_config.lcdcon1;
rLCDCON2 = lcd_config.lcdcon2;
rLCDCON3 = lcd_config.lcdcon3;
rLCDCON4 = lcd_config.lcdcon4;
rLCDCON5 = lcd_config.lcdcon5;
rLCDSADDR1=(((U32)frameBuffer16Bit480272Tft>>22)<<21)|M5D((U32)frameBuffer16Bit480272Tft>>1);
rLCDSADDR2=M5D( ((U32)frameBuffer16Bit480272Tft+(lcd_config.scr_xsize*lcd_config.ysize*2))>>1 );
rLCDSADDR3=(((lcd_config.scr_xsize-lcd_config.xsize)/1)<<11)|(lcd_config.xsize/1);
rLCDINTMSK|=(3); // MASK LCD Sub Interrupt
rTCONSEL&=~((1<<4)|1); // Disable LCC3600, LPC3600
rTPAL=0; // Disable Temp Palette
rLCDCON1|=1; // ENVID=ON
#if 0
Uart_Printf( "\nrGPBCON=0x%x\n", rGPBCON );
Uart_Printf( "\trGPBUP=0x%x\n", rGPBUP );
Uart_Printf( "rGPCCON=0x%x\n", rGPCCON );
Uart_Printf( "\trGPCUP=0x%x\n", rGPCUP );
Uart_Printf( "rGPDCON=0x%x\n", rGPDCON );
Uart_Printf( "\trGPDUP=0x%x\n", rGPDUP );
Uart_Printf( "rGPGCON=0x%x\n", rGPGCON );
Uart_Printf( "\trGPGUP=0x%x\n\n", rGPGUP );
Uart_Printf( "rLCDCON1=0x%x\n", rLCDCON1 );
Uart_Printf( "rLCDCON2=0x%x\n", rLCDCON2 );
Uart_Printf( "rLCDCON3=0x%x\n", rLCDCON3 );
Uart_Printf( "rLCDCON4=0x%x\n", rLCDCON4 );
Uart_Printf( "rLCDCON5=0x%x\n\n", rLCDCON5 );
Uart_Printf( "rLCDSADDR1=0x%x\n", rLCDSADDR1 );
Uart_Printf( "rLCDSADDR2=0x%x\n", rLCDSADDR2 );
Uart_Printf( "rLCDSADDR3=0x%x\n\n", rLCDSADDR3 );
Uart_Printf( "rLCDINTMSK=0x%x\n", rLCDINTMSK );
Uart_Printf( "rTCONSEL=0x%x\n", rTCONSEL );
Uart_Printf( "rTPAL=0x%x\n\n", rTPAL );
Uart_Printf( "lcd_config.ysize=0x%x\n\n", lcd_config.ysize );
Uart_Printf( "lcd_config.xsize=0x%x\n\n", lcd_config.xsize );
#endif
#if 1
for(y=0; y<lcd_config.ysize; y++)
for(x=0; x<lcd_config.xsize; x++)
frameBuffer16Bit480272Tft[y][x] = COLOR_RED_TFT16;
for(y=10; y<lcd_config.ysize-10; y++)
for(x=10; x<lcd_config.xsize-10; x++)
frameBuffer16Bit480272Tft[y][x] = COLOR_GREEN_TFT16;
for(y=20; y<lcd_config.ysize-20; y++)
for(x=20; x<lcd_config.xsize-20; x++)
frameBuffer16Bit480272Tft[y][x] = COLOR_BLUE_TFT16;
#endif
}
//优龙LCD驱动夏普DH01液晶屏
void Lcd_Init(void)
{
switch(lcd_config.lcd_id)
{
case LCD_240X320:
lcd240320_init();
break;
case LCD_320X240:
lcd320240_init();
break;
case LCD_480x272:
lcd480272_init();
break;
default:
break;
}
}
void Lcd_Port_Init(void)
{
rGPBUP =0x7ff;
rGPBCON = 0x154;/*PWM*/
switch(lcd_config.lcd_id)
{
case LCD_480x272:
rGPBDAT |=0x2;
break;
case LCD_240X320:
rGPBDAT &=~0x2;
break;
case LCD_320X240:
rGPBDAT &=~0x2;
break;
}
rGPCUP=0xffff; // Disable Pull-up register
rGPCCON=0xaaaa56a9; //Initialize VD[7:0],LCDVF[2:0],VM,VFRAME,VLINE,VCLK,LEND
rGPDUP=0xffff; // Disable Pull-up register
rGPDCON=0xaaaaaaaa; //Initialize VD[15:8]
rGPGUP =0xffff;
rGPGCON |=0x300; /*PWREN*/
//rGPGDAT &= ~0x10;
rGPGDAT |= 0x10;
//Uart_Printf("rGPGDAT=%x\n",rGPGDAT);
}
void Lcd_EnvidOnOff(int onoff)
{
if(onoff==1)
rLCDCON1|=1; // ENVID=ON
else
rLCDCON1 =rLCDCON1 & 0x3fffe; // ENVID Off
}
void Lcd_config(void)
{
if(!strcmp(boot_params.string,"display=shp240"))
{
lcd_config = tft_240x320;
//Uart_Printf("display=shp240\n");
}
else if(!strcmp(boot_params.string,"display=shp320"))
{
lcd_config = tft_320X240;
//Uart_Printf("display=shp320\n");
}
else if(!strcmp(boot_params.string,"display=shp480"))
{
lcd_config = tft_480x272;
//Uart_Printf("display=shp480\n");
}
else
{
lcd_config = tft_240x320;
//Uart_Printf("unknown display type !\n");
}
}
void LcdDisplay(void)
{
#ifdef DEBUG
printf("\nTest LTS350Q1_PE1 (TFT LCD)!\n");
#endif
//Lcd_EnvidOnOff(0);
Lcd_config();
Lcd_Port_Init(); //LCD端口初始化
// LcdBkLtSet(70);
Lcd_Init(); //LCD初始化
Lcd_EnvidOnOff(1); //turn on vedio
// Lcd_PowerEnable(1,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -