for(j=0;j<3000;++j);
}
/*******************************************************************************
*FunctionName:
STM3210B_LCD_Init
*Description:
InitializestheLCD.
*Input:
None
*Output:
None
*Return:
None
*******************************************************************************/
voidSTM3210B_LCD_Init(void)
{
vu16dummy=0;
//总线配置
LCD_CtrlLinesConfig();
LCD_WriteReg(0x0000,0x0001);
Delay_LCD(1000);
LCD_WriteReg(0x0001,0x0000);
LCD_WriteReg(0x0010,0x1790);
LCD_WriteReg(0x0060,0x2700);
LCD_WriteReg(0x0061,0x0001);
LCD_WriteReg(0x0046,0x0002);
LCD_WriteReg(0x0013,0x8010);
LCD_WriteReg(0x0012,0x80fe);
LCD_WriteReg(0x0002,0x0500);
LCD_WriteReg(0x0003,0x1030);
LCD_WriteReg(0x0030,0x0303);
LCD_WriteReg(0x0031,0x0303);
LCD_WriteReg(0x0032,0x0303);
LCD_WriteReg(0x0033,0x0300);
LCD_WriteReg(0x0034,0x0003);
LCD_WriteReg(0x0035,0x0303);
LCD_WriteReg(0x0036,0x0014);
LCD_WriteReg(0x0037,0x0303);
LCD_WriteReg(0x0038,0x0303);
LCD_WriteReg(0x0039,0x0303);
LCD_WriteReg(0x003a,0x0300);
LCD_WriteReg(0x003b,0x0003);
LCD_WriteReg(0x003c,0x0303);
LCD_WriteReg(0x003d,0x1400);
LCD_WriteReg(0x0092,0x0200);
LCD_WriteReg(0x0093,0x0303);
LCD_WriteReg(0x0090,0x080d);
LCD_WriteReg(0x0003,0x1018);
LCD_WriteReg(0x0007,0x0173);
dummy=LCD_ReadReg(0);
}
/*******************************************************************************
*FunctionName:
LCD_SetTextColor
*Description:
SetstheTextcolor.
*Input:
-Color:
specifiestheTextcolorcodeRGB(5-6-5).
*Output:
-TextColor:
TextcolorglobalvariableusedbyLCD_DrawChar
*andLCD_DrawPicturefunctions.
*Return:
None
*******************************************************************************/
voidLCD_SetTextColor(vu16Color)
{
TextColor=Color;
}
/*******************************************************************************
*FunctionName:
LCD_SetBackColor
*Description:
SetstheBackgroundcolor.
*Input:
-Color:
specifiestheBackgroundcolorcodeRGB(5-6-5).
*Output:
-BackColor:
Backgroundcolorglobalvariableusedby
*LCD_DrawCharandLCD_DrawPicturefunctions.
*Return:
None
*******************************************************************************/
voidLCD_SetBackColor(vu16Color)
{
BackColor=Color;
}
/*******************************************************************************
*FunctionName:
LCD_ClearLine
*Description:
Clearstheselectedline.
*Input:
-Line:
theLinetobecleared.
*Thisparametercanbeoneofthefollowingvalues:
*-Linex:
wherexcanbe0..9
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_ClearLine(u8Line)
{
LCD_DisplayStringLine(Line,"");
}
/*******************************************************************************
*FunctionName:
LCD_Clear
*Description:
ClearstheholeLCD.
*Input:
Color:
thecolorofthebackground.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_Clear(u16Color)
{
u32index=0;
LCD_SetCursor(0x00,0x0000);
LCD_WriteRAM_Prepare();/*PreparetowriteGRAM*/
for(index=0;index<76800;index++)
{
LCD_WriteRAM(Color);
}
}
/*******************************************************************************
*FunctionName:
LCD_SetCursor
*Description:
Setsthecursorposition.
*Input:
-Xpos:
specifiestheXposition.
*-Ypos:
specifiestheYposition.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_SetCursor(u8Xpos,u16Ypos)
{
LCD_WriteReg(R32,Xpos);
LCD_WriteReg(R33,Ypos);
}
/*******************************************************************************
*FunctionName:
LCD_DrawChar
*Description:
DrawsacharacteronLCD.
*Input:
-Xpos:
theLinewheretodisplaythecharactershape.
*Thisparametercanbeoneofthefollowingvalues:
*-Linex:
wherexcanbe0..9
*-Ypos:
startcolumnaddress.
*-c:
pointertothecharacterdata.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_DrawChar(u8Xpos,u16Ypos,uc16*c)
{
u32index=0,i=0;
u8Xaddress=0;
Xaddress=Xpos;
LCD_SetCursor(Xaddress,Ypos);
for(index=0;index<24;index++)
{
LCD_WriteRAM_Prepare();/*PreparetowriteGRAM*/
for(i=0;i<16;i++)
{
if((c[index]&(1<
{
LCD_WriteRAM(BackColor);
}
else
{
LCD_WriteRAM(TextColor);
}
}
Xaddress++;
LCD_SetCursor(Xaddress,Ypos);
}
}
/*******************************************************************************
*FunctionName:
LCD_DisplayChar
*Description:
Displaysonecharacter(16dotswidth,24dotsheight).
*Input:
-Line:
theLinewheretodisplaythecharactershape.
*Thisparametercanbeoneofthefollowingvalues:
*-Linex:
wherexcanbe0..9
*-Column:
startcolumnaddress.
*-Ascii:
characterasciicode,mustbebetween0x20and0x7E.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_DisplayChar(u8Line,u16Column,u8Ascii)
{
Ascii-=32;
LCD_DrawChar(Line,Column,&ASCII_Table[Ascii*24]);
}
/*******************************************************************************
*FunctionName:
LCD_DisplayStringLine
*Description:
Displaysamaximumof20charontheLCD.
*Input:
-Line:
theLinewheretodisplaythecharactershape.
*Thisparametercanbeoneofthefollowingvalues:
*-Linex:
wherexcanbe0..9
*-*ptr:
pointertostringtodisplayonLCD.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_DisplayStringLine(u8Line,u8*ptr)
{
u32i=0;
u16refcolumn=319;//319;
while((*ptr!
=0)&&(i<20))//20
{
LCD_DisplayChar(Line,refcolumn,*ptr);
refcolumn-=16;
ptr++;
i++;
}
}
/*******************************************************************************
*FunctionName:
LCD_SetDisplayWindow
*Description:
Setsadisplaywindow
*Input:
-Xpos:
specifiestheXbuttomleftposition.
*-Ypos:
specifiestheYbuttomleftposition.
*-Height:
displaywindowheight.
*-Width:
displaywindowwidth.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_SetDisplayWindow(u8Xpos,u16Ypos,u8Height,u16Width)
{
if(Xpos>=Height)
{
LCD_WriteReg(R80,(Xpos-Height+1));
}
else
{
LCD_WriteReg(R80,0);
}
LCD_WriteReg(R81,Xpos);
if(Ypos>=Width)
{
LCD_WriteReg(R82,(Ypos-Width+1));
}
else
{
LCD_WriteReg(R82,0);
}
/*VerticalGRAMEndAddress*/
LCD_WriteReg(R83,Ypos);
LCD_SetCursor(Xpos,Ypos);
}
/*******************************************************************************
*FunctionName:
LCD_WindowModeDisable
*Description:
DisablesLCDWindowmode.
*Input:
None
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_WindowModeDisable(void)
{
LCD_SetDisplayWindow(239,0x13F,240,320);
LCD_WriteReg(R3,0x1018);
}
/*******************************************************************************
*FunctionName:
LCD_DrawLine
*Description:
Displaysaline.
*Input:
-Xpos:
specifiestheXposition.
*-Ypos:
specifiestheYposition.
*-Length:
linelength.
*-Direction:
linedirection.
*Thisparametercanbeoneofthefollowingvalues:
Vertical
*orHorizontal.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_DrawLine(u8Xpos,u16Ypos,u16Length,u8Direction)
{
u32i=0;
LCD_SetCursor(Xpos,Ypos);
if(Direction==Horizontal)
{
LCD_WriteRAM_Prepare();/*PreparetowriteGRAM*/
for(i=0;i{
LCD_WriteRAM(TextColor);
}
}
else
{
for(i=0;i{
LCD_WriteRAM_Prepare();/*PreparetowriteGRAM*/
LCD_WriteRAM(TextColor);
Xpos++;
LCD_SetCursor(Xpos,Ypos);
}
}
}
/*******************************************************************************
*FunctionName:
LCD_DrawRect
*Description:
Displaysarectangle.
*Input:
-Xpos:
specifiestheXposition.
*-Ypos:
specifiestheYposition.
*-Height:
displayrectangleheight.
*-Width:
displayrectanglewidth.
*Output:
None
*Return:
None
*******************************************************************************/
voidLCD_DrawRect(u8Xpos,u16Ypos,u8Height,u16Width)
{
LCD_DrawLine(Xpos,Ypos,Width,Horizontal);
LCD_DrawLine((Xpos+Height),Ypos,Width,Horizontal);
LCD_DrawLine(Xpos,Ypos,Height,Vertical);
LCD_DrawLine(Xpos,(Ypos-Width+1),Height,Vertical);
}
/*******************************************************************************
*FunctionName:
LCD_DrawCircle
*Description:
Displaysacircle.
*Input:
-Xpos:
specifiestheXposition.
*-Ypos:
specifiestheYposition.
*-Height:
displayrectangleheight.
*-Width:
displayrectanglewidth.
*Output:
None
*Return:
None
***************************************************************