📄 main.c
字号:
/////////////////////////////////////////////////////////////////////
// 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
}
#if (BSP_TYPE == BSP_SMDK2443)
static void InitDisplay(void)
{
UINT8 pagewidth_in_byte=0,offsize_in_byte=0;
volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2450_LCD_REG *s2450LCD = (S3C2450_LCD_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE);
UINT8 clkval=0;
UINT16 hcync_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.
//
s2450IOP->MISCCR |= (1<<28); // select LCD controller for TFT lcd controller
//s2450IOP->GPCUDP = 0xFFFFFFFF;
s2450IOP->GPCCON = 0xAAAAAAAA;
//s2450IOP->GPDUDP = 0xFFFFFFFF;
s2450IOP->GPDCON = 0xAAAAAAAA;
#if 1 // tempory
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~(3<<8)) | (1<<8); // Backlight Pwm control
s2450IOP->GPBDAT |= (1<<8);
#else // control the backlight using pwm timer output
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~(3<<8)) | (2<<8); // set Timer out
#endif
// LCD _nRESET control
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~(3<<2)) |(1<<2);
s2450IOP->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);
s2450LCD->WINCON0 &= ~0x01;
s2450LCD->WINCON1 &= ~0x01;
//LcdEnvidOnOff(LCD_OFF);
s2450LCD->VIDCON0 &= (~3); // ENVID Off using Per Frame method
//Basic_Display_Setting(window,WINCONx_16BPP_565,lcd_horizon_value,0);
s2450LCD->VIDCON0 = VIDCON0_S_RGB_IF|VIDCON0_S_RGB_PAR|VIDCON0_S_VCLK_GATING_OFF|VIDCON0_S_CLKDIR_DIVIDED|VIDCON0_S_CLKSEL_HCLK;
hcync_cnt = (lcd_vbpd+lcd_vfpd+lcd_vspw+lcd_line_value);
vclk_cnt = (lcd_hbpd+lcd_hfpd+lcd_hspw+lcd_horizon_value);
clkval = (UINT8)(((float)S3C2450_HCLK/(float)(hcync_cnt*vclk_cnt*lcd_frame_rate))+0.5)-1;
s2450LCD->VIDCON0 |= (clkval <<VIDCON0_CLKVAL_F_SHIFT);
//check point
s2450LCD->VIDCON1 = VIDCON1_S_HSYNC_INVERTED|VIDCON1_S_VSYNC_INVERTED;
s2450LCD->VIDTCON0=((lcd_vbpd-1)<<VIDTCON0_BPD_S)|((lcd_vfpd-1)<<VIDTCON0_FPD_S)|(lcd_vspw-1);
s2450LCD->VIDTCON1=((lcd_hbpd-1)<<VIDTCON0_BPD_S)|((lcd_hfpd-1)<<VIDTCON0_FPD_S)|(lcd_hspw-1);
s2450LCD->VIDTCON2 = ((lcd_line_value-1)<<VIDTCON2_LINEVAL_S)|(lcd_horizon_value-1);
s2450LCD->WINCON0 = (0<<WINCON_SWAP_S)|(WINCONx_4WORD_BURST<<WINCON_BURSTLEN_S)|(WINCONx_16BPP_565<<WINCON_BPP_S); // 4word burst, 16bpp,
s2450LCD->VIDOSD0A = (0<<VIDOSDxAB_HORIZON_X_S)|(0);
s2450LCD->VIDOSD0B = ((lcd_horizon_value-1)<<VIDOSDxAB_HORIZON_X_S)|(lcd_line_value-1);
s2450LCD->VIDW00ADD0B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE;
// buffer end address
s2450LCD->VIDW00ADD1B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE + (LCD_XSIZE_TFT*LCD_YSIZE_TFT*2);
// buffer size
s2450LCD->VIDW00ADD2B0 = (offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|(LCD_XSIZE_TFT*2);
s2450LCD->WIN0MAP = 0;
s2450LCD->WINCON0 |= (1<<WINCON_SWAP_S);
s2450LCD->WINCON0 |= 0x1;
s2450LCD->VIDCON0 |= 0x3;
memcpy((void *)IMAGE_FRAMEBUFFER_UA_BASE, prayer16bpp, LCD_ARRAY_SIZE_TFT_16BIT);
}
#elif (BSP_TYPE == BSP_SMDK2450)
static void InitDisplay(void)
{
UINT8 pagewidth_in_byte=0,offsize_in_byte=0;
volatile S3C2450_IOPORT_REG *s2450IOP = (S3C2450_IOPORT_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_IOPORT, FALSE);
volatile S3C2450_LCD_REG *s2450LCD = (S3C2450_LCD_REG *)OALPAtoVA(S3C2450_BASE_REG_PA_LCD, FALSE);
volatile S3C2450_INTR_REG *s2450INTR = (S3C2450_INTR_REG *)OALPAtoVA(S3C2450_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;
int i;
unsigned short *pFB;
// Set up the LCD controller registers to display a power-on bitmap image.
//
s2450IOP->MISCCR |= (1<<28); // select LCD controller for TFT lcd controller
s2450IOP->GPCUDP = 0xFFFFFFFF;
s2450IOP->GPCCON = 0xAAAAAAAA;
s2450IOP->GPDUDP = 0xFFFFFFFF;
s2450IOP->GPDCON = 0xAAAAAAAA;
s2450IOP->GPLCON = s2450IOP->GPLCON & ~(0x3ff<<20) | (0x1<< 28) | (0x1<< 26) | (0x1<< 24) | (0x1<< 22) | (0x1<< 20);
s2450IOP->GPLDAT |= (0x1f<<10);
s2450IOP->GPBUDP &= ~0x3;
s2450IOP->GPBCON = (s2450IOP->GPBCON & ~((3<<6)|(3<<2)|(3<<0))) | ((1<<6)|(1<<2)|(1<<0)); // Backlight Pwm control
s2450IOP->GPBDAT |=((1<<0) |(1<<3));
s2450IOP->GPBDAT &= ~(1<<1);
#if (LCD_MODULE_TYPE == LCD_MODULE_LTE480WV)
// s2450IOP->GPFCON = (s2450IOP->GPFCON & ~(3<<4)) |(1<<4);
// s2450IOP->GPFDAT = (s2450IOP->GPFDAT & ~(1<<2)); // make low
lcd_horizon_value = LTE480_HOZVAL;
lcd_line_value = LTE480_LINEVAL;
lcd_vbpd = LTE480_VBPD;
lcd_vfpd = LTE480_VFPD;
lcd_vspw = LTE480_VSPW;
lcd_hbpd = LTE480_HBPD;
lcd_hfpd = LTE480_HFPD;
lcd_hspw = LTE480_HSPW;
lcd_frame_rate = LTE480_FRAME_RATE;
InitLDI_LTE480();
#elif (LCD_MODULE_TYPE == 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();
#endif
pagewidth_in_byte = lcd_horizon_value/8*16;
offsize_in_byte = 0;
//LcdWindowOnOff(LCD_WIN_ALL,LCD_OFF);
s2450LCD->WINCON0 &= ~0x01;
s2450LCD->WINCON1 &= ~0x01;
//LcdEnvidOnOff(LCD_OFF);
s2450LCD->VIDCON0 &= (~3); // ENVID Off using Per Frame method
//Basic_Display_Setting(window,WINCONx_16BPP_565,lcd_horizon_value,0);
s2450LCD->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)S3C2450_HCLK/(float)(hsync_cnt*vclk_cnt*lcd_frame_rate*2))+0.5)-1;
s2450LCD->VIDCON0 |= (clkval <<VIDCON0_CLKVAL_F_SHIFT);
s2450LCD->VIDCON1 = VIDCON1_S_HSYNC_INVERTED|VIDCON1_S_VSYNC_INVERTED;
s2450LCD->VIDTCON0=((lcd_vbpd-1)<<VIDTCON0_BPD_S)|((lcd_vfpd-1)<<VIDTCON0_FPD_S)|(lcd_vspw-1);
s2450LCD->VIDTCON1=((lcd_hbpd-1)<<VIDTCON0_BPD_S)|((lcd_hfpd-1)<<VIDTCON0_FPD_S)|(lcd_hspw-1);
s2450LCD->VIDTCON2 = ((lcd_line_value-1)<<VIDTCON2_LINEVAL_S)|(lcd_horizon_value-1);
s2450LCD->WINCON0 = (0<<WINCON_SWAP_S)|(WINCONx_16WORD_BURST<<WINCON_BURSTLEN_S)|(WINCONx_16BPP_565<<WINCON_BPP_S); // 4word burst, 16bpp,
s2450LCD->VIDOSD0A = (0<<VIDOSDxAB_HORIZON_X_S)|(0);
s2450LCD->VIDOSD0B = ((lcd_horizon_value-1)<<VIDOSDxAB_HORIZON_X_S)|(lcd_line_value-1);
s2450LCD->VIDW00ADD0B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE;
// buffer end address
s2450LCD->VIDW00ADD1B0 = (UINT32)IMAGE_FRAMEBUFFER_DMA_BASE + (LCD_WIDTH*LCD_HEIGHT*2);
// buffer size
s2450LCD->VIDW00ADD2B0 = (offsize_in_byte<<VIDWxADD2_OFFSET_SIZE_S)|(LCD_WIDTH*2);
s2450LCD->WINCON0 |= (1<<WINCON_SWAP_S);
//*WxKEYCON0_Reg_Addr[win_num] = 0;
//*WINxMAP_Reg_Addr[win_num] = 0;
s2450LCD->WINCON0 |= 0x1;
s2450LCD->VIDCON0 |= 0x3;
s2450INTR->INTSUBMSK |= (0xf << IRQ_SUB_LCD1); // MASK all LCD Sub Interrupt
if( LCD_MODULE_TYPE == LCD_MODULE_LTV350){
memcpy((void *)IMAGE_FRAMEBUFFER_UA_BASE, prayer16bpp, LCD_ARRAY_SIZE_TFT_16BIT);
}
else if(LCD_MODULE_TYPE == LCD_MODULE_LTE480WV){
pFB = (unsigned short *)IMAGE_FRAMEBUFFER_UA_BASE;
for (i=0; i<LCD_WIDTH*LCD_HEIGHT; i++)
*pFB++ = 0x001F; // Blue
}
}
#endif
/*
@func void | SetIP | Accepts IP address from user input.
@rdesc N/A.
@comm
@xref
*/
static void SetIP(PBOOT_CFG pBootCfg)
{
CHAR szDottedD[16]; // The string used to collect the dotted decimal IP address.
USHORT cwNumChars = 0;
USHORT InChar = 0;
EdbgOutputDebugString("\r\nEnter new IP address: ");
while(!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string.
//
if (InChar == '.' || (InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up.
//
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
//
if (cwNumChars)
{
szDottedD[cwNumChars] = '\0';
pBootCfg->EdbgAddr.dwIP = inet_addr(szDottedD);
}
}
/*
@func void | SetMask | Accepts subnet mask from user input.
@rdesc N/A.
@comm
@xref
*/
static void SetMask(PBOOT_CFG pBootCfg)
{
CHAR szDottedD[16]; // The string used to collect the dotted masks.
USHORT cwNumChars = 0;
USHORT InChar = 0;
EdbgOutputDebugString("\r\nEnter new subnet mask: ");
while(!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a number or a period, add it to the string.
//
if (InChar == '.' || (InChar >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
// If it's a backspace, back up.
//
else if (InChar == 8)
{
if (cwNumChars > 0)
{
cwNumChars--;
OEMWriteDebugByte((BYTE)InChar);
}
}
}
}
// If it's a carriage return with an empty string, don't change anything.
//
if (cwNumChars)
{
szDottedD[cwNumChars] = '\0';
pBootCfg->SubnetMask = inet_addr(szDottedD);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -