📄 main.c
字号:
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);
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.
//
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;
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)S3C2443_HCLK/(float)(hcync_cnt*vclk_cnt*lcd_frame_rate*2))+0.5)-1;
s2443LCD->VIDCON0 |= (clkval <<VIDCON0_CLKVAL_F_SHIFT);
//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_4WORD_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->WIN0MAP = 0;
s2443LCD->WINCON0 |= (1<<WINCON_SWAP_S);
s2443LCD->WINCON0 |= 0x1;
s2443LCD->VIDCON0 |= 0x3;
memcpy((void *)IMAGE_FRAMEBUFFER_UA_BASE, prayer16bpp, LCD_ARRAY_SIZE_TFT_16BIT);
}
#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);
}
}
/*
@func void | SetDelay | Accepts an autoboot delay value from user input.
@rdesc N/A.
@comm
@xref
*/
static void SetDelay(PBOOT_CFG pBootCfg)
{
CHAR szCount[16];
USHORT cwNumChars = 0;
USHORT InChar = 0;
EdbgOutputDebugString("\r\nEnter maximum number of seconds to delay [1-255]: ");
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 >= '0' && InChar <= '9'))
{
if (cwNumChars < 16)
{
szCount[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)
{
szCount[cwNumChars] = '\0';
pBootCfg->BootDelay = atoi(szCount);
if (pBootCfg->BootDelay > 255)
{
pBootCfg->BootDelay = 255;
}
else if (pBootCfg->BootDelay < 1)
{
pBootCfg->BootDelay = 1;
}
}
}
static ULONG mystrtoul(PUCHAR pStr, UCHAR nBase)
{
UCHAR nPos=0;
BYTE c;
ULONG nVal = 0;
UCHAR nCnt=0;
ULONG n=0;
// fulllibc doesn't implement isctype or iswctype, which are needed by
// strtoul, rather than including coredll code, here's our own simple strtoul.
if (pStr == NULL)
return(0);
for (nPos=0 ; nPos < strlen(pStr) ; nPos++)
{
c = tolower(*(pStr + strlen(pStr) - 1 - nPos));
if (c >= '0' && c <= '9')
c -= '0';
else if (c >= 'a' && c <= 'f')
{
c -= 'a';
c = (0xa + c);
}
for (nCnt = 0, n = 1 ; nCnt < nPos ; nCnt++)
{
n *= nBase;
}
nVal += (n * c);
}
return(nVal);
}
static void CvtMAC(USHORT MacAddr[3], char *pszDottedD )
{
DWORD cBytes;
char *pszLastNum;
int atoi (const char *s);
int i=0;
BYTE *p = (BYTE *)MacAddr;
// Replace the dots with NULL terminators
pszLastNum = pszDottedD;
for(cBytes = 0 ; cBytes < 6 ; cBytes++)
{
while(*pszDottedD != '.' && *pszDottedD != '\0')
{
pszDottedD++;
}
if (pszDottedD == '\0' && cBytes != 5)
{
// zero out the rest of MAC address
while(i++ < 6)
{
*p++ = 0;
}
break;
}
*pszDottedD = '\0';
*p++ = (BYTE)(mystrtoul(pszLastNum, 16) & 0xFF);
i++;
pszLastNum = ++pszDottedD;
}
}
static void SetCS8900MACAddress(PBOOT_CFG pBootCfg)
{
CHAR szDottedD[24];
USHORT cwNumChars = 0;
USHORT InChar = 0;
memset(szDottedD, '0', 24);
EdbgOutputDebugString ( "\r\nEnter new MAC address in hexadecimal (hh.hh.hh.hh.hh.hh): ");
while(!((InChar == 0x0d) || (InChar == 0x0a)))
{
InChar = OEMReadDebugByte();
InChar = tolower(InChar);
if (InChar != OEM_DEBUG_COM_ERROR && InChar != OEM_DEBUG_READ_NODATA)
{
// If it's a hex number or a period, add it to the string.
//
if (InChar == '.' || (InChar >= '0' && InChar <= '9') || (InChar >= 'a' && InChar <= 'f'))
{
if (cwNumChars < 17)
{
szDottedD[cwNumChars++] = (char)InChar;
OEMWriteDebugByte((BYTE)InChar);
}
}
else if (InChar == 8) // If it's a backspace, back up.
{
if (cwNumChars > 0)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -