微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 飞凌2440 lcd 调试

飞凌2440 lcd 调试

时间:11-21 来源:互联网 点击:

void Lcd_Port_Init(void)
{
GPCUP = 0xffffffff; // 禁止内部上拉
GPCCON = 0xaaaaaaaa; // GPIO管脚用于VD[7:0],LCDVF[2:0],VM,VFRAME,VLINE,VCLK,LEND
GPDUP = 0xffffffff; // 禁止内部上拉
GPDCON = 0xaaaaaaaa; // GPIO管脚用于VD[23:8]
}

void Tft_Lcd_Init(int type)
{
switch(type)
{
case MODE_TFT_8BIT_240320:

#if 0
LCDCON1 = (CLKVAL_TFT_240320<8) | (LCDTYPE_TFT<5) | \
(BPPMODE_8BPP<1) | (ENVID_DISABLE<0);
LCDCON2 = (VBPD_240320<24) | (LINEVAL_TFT_240320<14) | \
(VFPD_240320<6) | (VSPW_240320);
LCDCON3 = (HBPD_240320<19) | (HOZVAL_TFT_240320<8) | (HFPD_240320);
LCDCON4 = HSPW_240320;
LCDCON5 = (FORMAT8BPP_565<11) | (HSYNC_INV<9) | (VSYNC_INV<8) | \
(BSWP<1);
#endif
LCDCON1 = (8<8) | (3<5) | (0x0c<1);
LCDCON2 = (14<24) | (239<14) | (11<6) | (2<0);
LCDCON3 = (37<19) | (319<8) | (19<0);
LCDCON4 = 29;
LCDCON5 = (1<11) | (1<10) | (1<9) | (0<6) | (1<8) | (1<0);


LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);
LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+ \
(LINEVAL_TFT_240320+1)*(HOZVAL_TFT_240320+1)*1)>>1);
LCDSADDR3 = (0<11) | (LCD_XSIZE_TFT_240320/2);


TPAL = 0;

fb_base_addr = LCDFRAMEBUFFER;
bpp = 8;
// xsize = 240;
// ysize = 320;
xsize = 320;
ysize = 240;
break;

case MODE_TFT_16BIT_240320:

#if 0
LCDCON1 = (CLKVAL_TFT_240320<8) | (LCDTYPE_TFT<5) | \
(BPPMODE_16BPP<1) | (ENVID_DISABLE<0);
LCDCON2 = (VBPD_240320<24) | (LINEVAL_TFT_240320<14) | \
(VFPD_240320<6) | (VSPW_240320);
LCDCON3 = (HBPD_240320<19) | (HOZVAL_TFT_240320<8) | (HFPD_240320);
LCDCON4 = HSPW_240320;
LCDCON5 = (FORMAT8BPP_565<11) | (HSYNC_INV<9) | (VSYNC_INV<8) | \
(HWSWP<1);
#endif
LCDCON1 = (8<8) | (3<5) | (0x0c<1);
LCDCON2 = (14<24) | (239<14) | (11<6) | (2<0);
LCDCON3 = (37<19) | (319<8) | (19<0);
LCDCON4 = 29;
LCDCON5 = (1<11) | (1<10) | (1<9) | (0<6) | (1<8) | (1<0);



LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);
LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+ \
(239+1)*(319+1)*2)>>1);
LCDSADDR3 = (0<11) | (320*2/2);


TPAL = 0;

fb_base_addr = LCDFRAMEBUFFER;
bpp = 16;
// xsize = 240;
// ysize = 320;
xsize = 320;
ysize = 240;

break;

case MODE_TFT_8BIT_640480:

LCDCON1 = (CLKVAL_TFT_640480<8) | (LCDTYPE_TFT<5) | \
(BPPMODE_8BPP<1) | (ENVID_DISABLE<0);
LCDCON2 = (VBPD_640480<24) | (LINEVAL_TFT_640480<14) | \
(VFPD_640480<6) | (VSPW_640480);
LCDCON3 = (HBPD_640480<19) | (HOZVAL_TFT_640480<8) | (HFPD_640480);
LCDCON4 = HSPW_640480;
LCDCON5 = (FORMAT8BPP_565<11) | (HSYNC_INV<9) | (VSYNC_INV<8) | \
(BSWP<1);


LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);
LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+ \
(LINEVAL_TFT_640480+1)*(HOZVAL_TFT_640480+1)*1)>>1);
LCDSADDR3 = (0<11) | (LCD_XSIZE_TFT_640480/2);


TPAL = 0;

fb_base_addr = LCDFRAMEBUFFER;
bpp = 8;
xsize = 640;
ysize = 480;

break;

case MODE_TFT_16BIT_640480:

LCDCON1 = (CLKVAL_TFT_640480<8) | (LCDTYPE_TFT<5) | \
(BPPMODE_16BPP<1) | (ENVID_DISABLE<0);
LCDCON2 = (VBPD_640480<24) | (LINEVAL_TFT_640480<14) | \
(VFPD_640480<6) | (VSPW_640480);
LCDCON3 = (HBPD_640480<19) | (HOZVAL_TFT_640480<8) | (HFPD_640480);
LCDCON4 = HSPW_640480;
LCDCON5 = (FORMAT8BPP_565<11) | (HSYNC_INV<9) | (VSYNC_INV<8) | \
(HWSWP<1);


LCDSADDR1 = ((LCDFRAMEBUFFER>>22)<21) | LOWER21BITS(LCDFRAMEBUFFER>>1);
LCDSADDR2 = LOWER21BITS((LCDFRAMEBUFFER+ \
(LINEVAL_TFT_640480+1)*(HOZVAL_TFT_640480+1)*2)>>1);
LCDSADDR3 = (0<11) | (LCD_XSIZE_TFT_640480*2/2);


TPAL = 0;

fb_base_addr = LCDFRAMEBUFFER;
bpp = 16;
xsize = 640;
ysize = 480;

break;

default:
break;
}
}

void Lcd_Palette8Bit_Init(void)
{
int i;
volatile unsigned int *palette;
LCDCON1 &= ~0x01;// stop lcd controller

LCDCON5 |= (FORMAT8BPP_565<11); // 设置调色板中数据格式为5:6:5

palette = (volatile unsigned int *)PALETTE;
for (i = 0; i < 256; i++)
*palette++ = DEMO256pal[i];
LCDCON1 |= 0x01;// re-enable lcd controller
}

void ChangePalette(UINT32 color)
{
int i;
unsigned char red, green, blue;
UINT32 *palette;

red = (color >> 19) & 0x1f;
green = (color >> 10) & 0x3f;
blue = (color >> 3) & 0x1f;
color = (red < 11) | (green < 5) | blue; // 格式5:6:5

palette=(UINT32 *)PALETTE;
LCDCON1 &= ~0x01;// stop lcd controller
for (i = 0; i < 256; i++)
{
// while (((LCDCON5>>15) & 0x3) == 2); // 等待直到VSTATUS不为”有效”
*palette++ = color;
}
LCDCON1 |= 0x01;// re-enable lcd controller
}

void Lcd_PowerEnable(int invpwren, int pwren)
{
GPGCON = (GPGCON & (~(3<8))) | (3<8); // GPG4用作LCD_PWREN
GPGUP = (GPGUP & (~(1<4))) | (1<4); // 禁止内部上拉

LCDCON5 = (LCDCON5 & (~(1<5))) | (invpwren<5); // 设置LCD_PWREN的极性: 正常/反转
LCDCON5 = (LCDCON5 & (~(1<3))) | (pwren<3); // 设置是否输出LCD_PWREN
}

void Lcd_EnvidOnOff(int onoff)
{
if (onoff == 1)
{
LCDCON1 |= 1; // ENVID ON
GPBDAT |= (1<0);// Power on
}
else
{
LCDCON1 &= 0x3fffe; // ENVID Off
GPBDAT &= ~(1<0); // Power off
}
}

void ClearScrWithTmpPlt(UINT32 color)
{
TPAL = (1<24)|((color & 0xffffff)<0);
}

void DisableTmpPlt(void)
{
TPAL = 0;
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top