📄 init.c
字号:
LCD_DCLK_Hi; // CLOCK = High
delayLoop(DELAY);
}
LCD_DEN_Hi; // EN = High
delayLoop(DELAY);
}
#define LTV350 (TRUE)
void InitLDI_LTV350(void)
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2443_LCD_REG *s2443LCD = (S3C2443_LCD_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_LCD, FALSE);
volatile S3C2443_CLKPWR_REG *s2443PWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);
// enable EPLL CLOCK for LCD
s2443PWR->SCLKCON |= (1<<10);
// LCD module reset
s2443IOP->GPBDAT |= (1<<(LCD_nRESET*2));
s2443IOP->GPBDAT &= ~(1<<(LCD_nRESET*2)); // goes to LOW
// delay about 5ms
delayLoop(LCD_DELAY_1MS*10);
s2443IOP->GPBDAT |= (1<<(LCD_nRESET*2)); // goes to HIGH
//SET_CONFIG_PORT( spi1)
s2443IOP->GPLCON &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));
s2443IOP->GPLCON |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));
// pull-up pull-down disable
s2443IOP->GPLUDP &= ~(((3<<(LCD_DEN_BIT*2))) | ((3<<(LCD_DCLK_BIT*2))) | ((3<<(LCD_DSERI_BIT*2))));
s2443IOP->GPLUDP |= (((1<<(LCD_DEN_BIT*2))) | ((1<<(LCD_DCLK_BIT*2))) | ((1<<(LCD_DSERI_BIT*2))));
// delay about 5ms
delayLoop(LCD_DELAY_1MS*10);
LCD_DEN_Hi;
LCD_DCLK_Hi;
LCD_DSERI_Hi;
///////////////////////////////////////////////////////////////////
// Init_Lcd_Function
//////////////////////////////////////////////////////////////////
#if LTV350
Write_LDI_LTV350(0x01,0x001d);
Write_LDI_LTV350(0x02,0x0000);
Write_LDI_LTV350(0x03,0x0000);
Write_LDI_LTV350(0x04,0x0000);
Write_LDI_LTV350(0x05,0x50a3);
Write_LDI_LTV350(0x06,0x0000);
Write_LDI_LTV350(0x07,0x0000);
Write_LDI_LTV350(0x08,0x0000);
Write_LDI_LTV350(0x09,0x0000);
Write_LDI_LTV350(0x0a,0x0000);
Write_LDI_LTV350(0x10,0x0000);
Write_LDI_LTV350(0x11,0x0000);
Write_LDI_LTV350(0x12,0x0000);
Write_LDI_LTV350(0x13,0x0000);
Write_LDI_LTV350(0x14,0x0000);
Write_LDI_LTV350(0x15,0x0000);
Write_LDI_LTV350(0x16,0x0000);
Write_LDI_LTV350(0x17,0x0000);
Write_LDI_LTV350(0x18,0x0000);
Write_LDI_LTV350(0x19,0x0000);
#else
Write_LDI_LTV350(0x09,0x0000);
#endif
///////////////////////////////////////////////////////////////////
// Power On Reset Display off State
//////////////////////////////////////////////////////////////////
//Write_LDI_LTV350(0x09,0x0000);
// delay about 10ms
delayLoop(LCD_DELAY_1MS*10);
///////////////////////////////////////////////////////////////////
// Power Setting Function 1
//////////////////////////////////////////////////////////////////
#if LTV350
Write_LDI_LTV350(0x09,0x4055);
Write_LDI_LTV350(0x0a,0x0000);
#else
Write_LDI_LTV350(0x09,0x4055);
Write_LDI_LTV350(0x0a,0x2000);
#endif
// delay about 10ms
delayLoop(LCD_DELAY_1MS*10);
/////////////////////////////////////////////////////////////////////
// Power Setting 2
/////////////////////////////////////////////////////////////////////
#if LTV350
Write_LDI_LTV350(0x0a,0x2000);
#else
Write_LDI_LTV350(0x09,0x4055);
#endif
// delay about 50ms
delayLoop(LCD_DELAY_1MS*50);
///////////////////////////////////////////////////////////////////
// Instruction Setting
///////////////////////////////////////////////////////////////////
#if LTV350
Write_LDI_LTV350(0x01,0x409d);
Write_LDI_LTV350(0x02,0x0204);
Write_LDI_LTV350(0x03,0x2100);
Write_LDI_LTV350(0x04,0x1000);
Write_LDI_LTV350(0x05,0x5003);
Write_LDI_LTV350(0x06,0x0009); //vbp
Write_LDI_LTV350(0x07,0x000f); //hbp
Write_LDI_LTV350(0x08,0x0800);
Write_LDI_LTV350(0x10,0x0000);
Write_LDI_LTV350(0x11,0x0000);
Write_LDI_LTV350(0x12,0x000f);
Write_LDI_LTV350(0x13,0x1f00);
Write_LDI_LTV350(0x14,0x0000);
Write_LDI_LTV350(0x15,0x0000);
Write_LDI_LTV350(0x16,0x0000);
Write_LDI_LTV350(0x17,0x0000);
Write_LDI_LTV350(0x18,0x0000);
Write_LDI_LTV350(0x19,0x0000);
#else
Write_LDI_LTV350(0x01,0x409d);
Write_LDI_LTV350(0x02,0x0204);
Write_LDI_LTV350(0x03,0x0100);
Write_LDI_LTV350(0x04,0x3000);
Write_LDI_LTV350(0x05,0x4003);
Write_LDI_LTV350(0x06,0x0009); //vbp
Write_LDI_LTV350(0x07,0x000f); //hbp
Write_LDI_LTV350(0x08,0x0c00);
Write_LDI_LTV350(0x10,0x0103);
Write_LDI_LTV350(0x11,0x0301);
Write_LDI_LTV350(0x12,0x1f0f);
Write_LDI_LTV350(0x13,0x1f0f);
Write_LDI_LTV350(0x14,0x0707);
Write_LDI_LTV350(0x15,0x0307);
Write_LDI_LTV350(0x16,0x0707);
Write_LDI_LTV350(0x17,0x0000);
Write_LDI_LTV350(0x18,0x0004);
Write_LDI_LTV350(0x19,0x0000);
#endif
// delay about 2 frames
delayLoop(LCD_DELAY_1MS*50);
///////////////////////////////////////////////////////////////////
// Display On Sequence
///////////////////////////////////////////////////////////////////
#if LTV350
Write_LDI_LTV350(0x09,0x4a55);
Write_LDI_LTV350(0x0a,0x2000);
#else
Write_LDI_LTV350(0x09,0x4a55);
Write_LDI_LTV350(0x05,0x5003);
#endif
}
static void InitDisplay(void)
{
UINT8 pagewidth_in_byte=0,offsize_in_byte=0;
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2443_LCD_REG *s2443LCD = (S3C2443_LCD_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_LCD, FALSE);
volatile S3C2443_INTR_REG *s2443INTR = (S3C2443_INTR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_INTR, FALSE);
UINT8 clkval=0;
UINT16 hsync_cnt,vclk_cnt;
UINT16 lcd_horizon_value,lcd_line_value;
UINT8 lcd_vbpd,lcd_vfpd,lcd_vspw,lcd_hbpd,lcd_hfpd,lcd_hspw;
UINT8 lcd_frame_rate;
UINT16 * pFB = NULL;
//int i,j;
// Set up the LCD controller registers to display a power-on bitmap image.
//
s2443IOP->MISCCR |= (1<<28); // select LCD controller for TFT lcd controller
s2443IOP->GPCUDP = 0xFFFFFFFF;
s2443IOP->GPCCON = 0xAAAAAAAA;
s2443IOP->GPDUDP = 0xFFFFFFFF;
s2443IOP->GPDCON = 0xAAAAAAAA;
#if 1 // tempory
s2443IOP->GPBCON = (s2443IOP->GPBCON & ~(3<<8)) | (1<<8); // Backlight Pwm control
s2443IOP->GPBDAT |= (1<<8);
#else // control the backlight using pwm timer output
s2443IOP->GPBCON = (s2443IOP->GPBCON & ~(3<<8)) | (2<<8); // set Timer out
#endif
// LCD _nRESET control
s2443IOP->GPBCON = (s2443IOP->GPBCON & ~(3<<2)) |(1<<2);
s2443IOP->GPBDAT |= (1<<1);
switch(LCD_MODULE_TYPE)
{
/*
case LCD_MODULE_LTS222:
lcd_horizon_value = LTS222_HOZVAL;
lcd_line_value = LTS222_LINEVAL;
lcd_vbpd = LTS222_VBPD;
lcd_vfpd = LTS222_VFPD;
lcd_vspw = LTS222_VSPW;
lcd_hbpd = LTS222_HBPD;
lcd_hfpd = LTS222_HFPD;
lcd_hspw = LTS222_HSPW;
lcd_frame_rate = LTS222_FRAME_RATE;
InitLDI_LTS222();
break;
*/
case LCD_MODULE_LTV350:
lcd_horizon_value = LTV350_HOZVAL;
lcd_line_value = LTV350_LINEVAL;
lcd_vbpd = LTV350_VBPD;
lcd_vfpd = LTV350_VFPD;
lcd_vspw = LTV350_VSPW;
lcd_hbpd = LTV350_HBPD;
lcd_hfpd = LTV350_HFPD;
lcd_hspw = LTV350_HSPW;
lcd_frame_rate = LTV350_FRAME_RATE;
InitLDI_LTV350();
break;
default:
break;
}
pagewidth_in_byte = lcd_horizon_value/8*16;
offsize_in_byte = 0;
//LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
s2443LCD->WINCON0 &= ~0x01;
s2443LCD->WINCON1 &= ~0x01;
//LcdEnvidOnOff(LCD_OFF);
s2443LCD->VIDCON0 &= (~3); // ENVID Off using Per Frame method
//Basic_Display_Setting(window,WINCONx_16BPP_565,lcd_horizon_value,0);
s2443LCD->VIDCON0 = VIDCON0_S_RGB_IF|VIDCON0_S_RGB_PAR|VIDCON0_S_VCLK_GATING_OFF|VIDCON0_S_CLKDIR_DIVIDED|VIDCON0_S_CLKSEL_HCLK;
hsync_cnt = (lcd_vbpd+lcd_vfpd+lcd_vspw+lcd_line_value);
vclk_cnt = (lcd_hbpd+lcd_hfpd+lcd_hspw+lcd_horizon_value);
clkval = (UINT8)(((float)S3C2443_SCLK/(float)(hsync_cnt*vclk_cnt*lcd_frame_rate*2))+0.5)-1;
s2443LCD->VIDCON0 |= (clkval <<VIDCON0_CLKVAL_F_SHIFT)|VIDCON0_S_CLKSEL_UPLL;
//check point
s2443LCD->VIDCON1 = VIDCON1_S_HSYNC_INVERTED|VIDCON1_S_VSYNC_INVERTED;
s2443LCD->VIDTCON0=((lcd_vbpd-1)<<VIDTCON0_BPD_S)|((lcd_vfpd-1)<<VIDTCON0_FPD_S)|(lcd_vspw-1);
s2443LCD->VIDTCON1=((lcd_hbpd-1)<<VIDTCON0_BPD_S)|((lcd_hfpd-1)<<VIDTCON0_FPD_S)|(lcd_hspw-1);
s2443LCD->VIDTCON2 = ((lcd_line_value-1)<<VIDTCON2_LINEVAL_S)|(lcd_horizon_value-1);
s2443LCD->WINCON0 = (0<<WINCON_SWAP_S)|(WINCONx_16WORD_BURST<<WINCON_BURSTLEN_S)|(WINCONx_16BPP_565<<WINCON_BPP_S); // 4word burst, 16bpp,
s2443LCD->VIDOSD0A = (0<<VIDOSDxAB_HORIZON_X_S)|(0);
s2443LCD->VIDOSD0B = ((lcd_horizon_value-1)<<VIDOSDxAB_HORIZON_X_S)|(lcd_line_value-1);
s2443LCD->VIDW00ADD0B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE;
// buffer end address
s2443LCD->VIDW00ADD1B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE + (LCD_XSIZE_TFT*LCD_YSIZE_TFT*2);
// buffer size
s2443LCD->VIDW00ADD2B0 = (offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|(LCD_XSIZE_TFT*2);
s2443LCD->WINCON0 |= (1<<WINCON_SWAP_S);
//*WxKEYCON0_Reg_Addr[win_num] = 0;
//*WINxMAP_Reg_Addr[win_num] = 0;
s2443LCD->WINCON0 |= 0x1;
s2443LCD->VIDCON0 |= 0x3;
s2443INTR->INTSUBMSK |= (0xf << IRQ_SUB_LCD1); // MASK all LCD Sub Interrupt
//memcpy((void *)IMAGE_FRAMEBUFFER_UA_BASE, prayer16bpp, LCD_ARRAY_SIZE_TFT_16BIT);
/*
pFB = (UINT16 *)IMAGE_FRAMEBUFFER_UA_BASE;
for (i=0; i<240; i++)
{
for (j=0; j<320; j++)
{
if (i < (240/2))
{
if (j < (320/2)) *(pFB + j + i * 320) = 0xF800;
else *(pFB + j + i * 320) = 0x07E0;
} else
{
if (j < (320/2)) *(pFB + j + i * 320) = 0x001F;
else *(pFB + j + i * 320) = 0xFFFF;
}
}
}*/
}
void ConfigureGPIO()
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2443_CLKPWR_REG *s2443CLKPWR = (S3C2443_CLKPWR_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_CLOCK_POWER, FALSE);
}
#ifdef DVS_EN
void ChangeVoltage(int vtg)
{
CurrVoltage = vtg;
Max1718_Set(ARM_VDD, vtg);
}
int GetCurrentVoltage()
{
return CurrVoltage;
}
#endif
//------------------------------------------------
// MAX1718 ARM core, internal regulator setting added 06.07.03 JJG
//------------------------------------------------
void Max1718_Set_o(int pwr, int voltage) // add 060624
{
volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)OALPAtoVA(S3C2443_BASE_REG_PA_IOPORT, FALSE);
// volatile S3C2443_IOPORT_REG *s2443IOP = (S3C2443_IOPORT_REG *)(S3C2443_BASE_REG_PA_IOPORT);
int vtg;
static con=1;
UINT32 backup_gpfdat;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -