|
文件: | TFT_LCD_EK070.sch.rar |
大小: | 17KB |
下载: | 下载 |
|
初始化代码:
#define LCD_XSIZE 800
#define LCD_YSIZE 480
#define LCD_BPP 24
#define LCD_ROTATE 0
#if (LCD_BPP==16)
#define LCD_COLOR U16
#endif
#if (LCD_BPP==24)
#define LCD_COLOR U32
#endif
#define LCD_BUF_SIZE (LCD_XSIZE*LCD_YSIZE*sizeof(LCD_COLOR))
static LCD_COLOR LCD_Buffer[LCD_XSIZE*LCD_YSIZE];
static GDEV gdev;
/*============================================================================*/
/*============================================================================*/
static int lcd_init(void)
{
// s3c2450 AT070TN 7.0" (800x480)
#define VBPD (96)
#define VFPD (17)
#define VSPW (3)
#define HBPD (40)
#define HFPD (32)
#define HSPW (13)
/
#define FRAME_RATE 30
#define LCD_XSIZE_TFT (LCD_XSIZE)
#define LCD_YSIZE_TFT (LCD_YSIZE)
#define LCD_SCR_XSIZE (LCD_XSIZE) // virtual screen
#define LCD_SCR_YSIZE (LCD_YSIZE)
#define LCD_SCR_XSIZE_TFT (LCD_XSIZE) // virtual screen
#define LCD_SCR_YSIZE_TFT (LCD_YSIZE)
//* VIDCON0
#define VIDOUT (0)
#define L1_DATA16 (4)
#define L0_DATA16 (4)
#define PNRMODE (0)
#define CLKVALUP (1)
#define CLKVAL_F (6)
#define CLKDIR (1)
#define CLKSEL_F (0)
//* VIDCON1
#define VCLK_INVERTED (0)
#define HSYNC_INVERTED (0)
#define VSYNC_INVERTED (0)
#define VDEN_INVERTED (0)
//* WINCON1to4
#if(LCD_BPP==16)
#define BITSWP (0) //shift on basis of half-word swap
#define BYTSWP (0) //shift on basis of half-word swap
#define HAWSWP (1) //shift on basis of half-word swap
#endif
#if(LCD_BPP==24)
#define BITSWP (0) //shift on basis of half-word swap
#define BYTSWP (0) //shift on basis of half-word swap
#define HAWSWP (0) //shift on basis of half-word swap
#endif
#define WINCONx_4WORD_BURST (2)
#define WINCONx_8WORD_BURST (1)
#define WINCONx_16WORD_BURST (0)
#define WINCONx_PLANE_BLENDING (0)
#define WINCONx_PIXEL_BLENDING (1)
#define WINCONx_1BPP_PALLET (0)
#define WINCONx_2BPP_PALLET (1)
#define WINCONx_4BPP_PALLET (2)
#define WINCONx_8BPP_PALLET (3)
#define WINCONx_8BPP_NO_PALLET (4)
#define WINCONx_16BPP_565 (5)
#define WINCONx_16BPP_A555 (6)
#define WINCONx_16BPP_1555 (7)
#define WINCONx_18BPP_666 (8)
#define WINCONx_18BPP_A665 (9)
#define WINCONx_19BPP_A666 (10)
#define WINCONx_24BPP_888 (11)
#define WINCONx_24BPP_A887 (12)
#define WINCONx_25BPP_A888 (13)
#define WINCONx_ALPHA_MODE_0 (0)
#define WINCONx_ALPHA_MODE_1 (1)
//* VIDWxADD2
//bit shift
//#define VIDWxADD2_OFFSET_SIZE_S (13)
//#define VIDWxADD2_PAGE_WIDTH_S (0)
#define LCD_HOZVAL_TFT (LCD_XSIZE_TFT-1)
#define LCD_LINEVAL_TFT (LCD_YSIZE_TFT-1)
int x,y,m,n;
U8 pagewidth_in_byte=0,offsize_in_byte=0;
U8 clkval=0;
U16 hsync_cnt,vclk_cnt;
U16 lcd_horizon_value,lcd_line_value;
U8 lcd_vbpd,lcd_vfpd,lcd_vspw,lcd_hbpd,lcd_hfpd,lcd_hspw;
U8 lcd_frame_rate;
int i;
rMISCCR |= (1<<28); // select LCD controller for TFT lcd controller
rGPCUDP = 0xAAAAAAAA;
rGPCCON = 0xAAAAAAAA;
rGPDUDP = 0xAAAAAAAA;
rGPDCON = 0xAAAAAAAA;
rGPLCON = rGPLCON & ~(0x3ff<<20) | (0x1<< 28) | (0x1<< 26) | (0x1<< 24) | (0x1<< 22) | (0x1<< 20);
rGPLDAT |= (0x1f<<10);
rGPBUDP &= ~0x3;
rGPBCON = (rGPBCON & ~((3<<6)|(3<<2)|(3<<0))) | ((1<<6)|(1<<2)|(1<<0)); // Backlight Pwm control
rGPBDAT |=((1<<0) |(1<<3));
rGPBDAT &= ~(1<<1);
lcd_horizon_value = LCD_XSIZE;
lcd_line_value = LCD_YSIZE;
lcd_vbpd = VBPD;
lcd_vfpd = VFPD;
lcd_vspw = VSPW;
lcd_hbpd = HBPD;
lcd_hfpd = HFPD;
lcd_hspw = HSPW;
lcd_frame_rate = FRAME_RATE;
pagewidth_in_byte = lcd_horizon_value/8*16;
offsize_in_byte = 0;
hsync_cnt = (lcd_vbpd+lcd_vfpd+lcd_vspw+lcd_line_value);
vclk_cnt = (lcd_hbpd+lcd_hfpd+lcd_hspw+lcd_horizon_value);
//clkval = (U8)(((float)CPU_GetHclkHZ()/(float)(hsync_cnt*vclk_cnt*lcd_frame_rate*2))+0.5)-1;
clkval = 5;
rWINCON0 &= ~0x01;
rWINCON1 &= ~0x01;
rVIDCON0 &= (~3); // ENVID Off using Per Frame method
rVIDCON0 = (VIDOUT<<22)|(L1_DATA16<<19)|(L0_DATA16<<16)|(PNRMODE<<13)|(CLKVALUP<<12)|(clkval<<6)|(0<<5)|(CLKDIR<<4)|(CLKSEL_F<<2)|(0<<0);
rVIDCON1 = (VCLK_INVERTED<<7)|(HSYNC_INVERTED<<6)|(VSYNC_INVERTED<<5)|(VDEN_INVERTED<<4);
rVIDTCON0 = ((lcd_vbpd-1)<<16)|((lcd_vfpd-1)<<8)|(lcd_vspw-1);
rVIDTCON1 = ((lcd_hbpd-1)<<16)|((lcd_hfpd-1)<<8)|(lcd_hspw-1);
rVIDTCON2 = ((lcd_line_value-1)<<11)|(lcd_horizon_value-1);
#if(LCD_BPP==16)
rWINCON0 = (BITSWP<<18)|(BYTSWP<<17)|(HAWSWP<<16)|(WINCONx_16WORD_BURST<<9)|(WINCONx_16BPP_565<<2); // 16word burst, 16bpp,
#endif
#if(LCD_BPP==24)
rWINCON0 = (BITSWP<<18)|(BYTSWP<<17)|(HAWSWP<<16)|(WINCONx_16WORD_BURST<<9)|(WINCONx_24BPP_888<<2); // 16word burst, 24bpp,
#endif
rVIDOSD0A = (0<<11)|(0);
rVIDOSD0B = (lcd_horizon_value-1)<<11|(lcd_line_value-1);
rVIDW00ADD0B0 = (U32)LCD_Buffer;
rVIDW00ADD1B0 = (U32)LCD_Buffer + LCD_BUF_SIZE;
rVIDW00ADD2B0 = (offsize_in_byte<<13)|(LCD_XSIZE*sizeof(LCD_COLOR));
rDITHMODE = (1<<5)|(1<<3)|(1<<1)|(1<<0);
//rDITHMODE = 0;
rWINCON0 |= 0x1;
rVIDCON0 |= (1<<5)|0x3;
//? rINTSUBMSK |= (0xf << IRQ_SUB_LCD1); // MASK all LCD Sub Interrupt
DebugPrintf("S3C2450_LCDInit End(800x480)\n");
}