自己验证过的STM32的LCD程序_第1页
自己验证过的STM32的LCD程序_第2页
自己验证过的STM32的LCD程序_第3页
自己验证过的STM32的LCD程序_第4页
自己验证过的STM32的LCD程序_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

Illllllllllllllllllllllllllllllllllllll/*hhhhhhhhhh*/include,,lcd.hu#include"stdlib.h"//#include"font.h"〃画笔颜色,背景颜色#include"usartl.h"〃画笔颜色,背景颜色ul6POINT_COLOR,BACK_COLOR二WHITE;voidLCD_WR_DATA(ul6data) 〃写16位数据函数{LCD_RS_SET;LCD_CS_CLR;DATAOUT(data);LCD_WR_CLR;LCD_WR_SET;LCD_CS_SET;}**函数名称:LCD_RD_DATA**功能描述:写寄存器函数**返回值:读到的值voidLCD_WR_REG(u8data){LCD_RS_CLR;〃写地址LCD_CS_CLR;DATAOUT(data);LCD_WR_CLR;LCD_WR_SET;LCD_CS_SET;}**函数名称:LCD_RD_DATA**功能描述:读LCD数据**返回值:读到的值ul6LCD_RD_DATA(void){ul6t;LCD_GPIOB_Configuration(0);LCD_RS_SET;LCD_CS_CLR;〃读取数据(读寄存器时,并不需要读2次)LCD_RD_CLR;LCD_RD_SET;t=DATAIN;LCD_CS_SET;LCD_GPIOB_Configuration(l);returnt;}**p****4c*p**4c*4c*穴******穴*穴承***穴*p****穴***********^*^**穴*穴*穴**穴*穴*穴**穴******p**函数名称:LCD_WriteReg**功能描述:写寄存器**LCD_Reg:寄存器编号**LCD_RegValue:要写入的值****穴承***穴*穴****穴*穴****穴承***穴*穴*穴**承*穴******穴承***穴****穴*穴*穴**穴*******穴voidLCD_WriteReg(u8LCD_Reg,ul6LCD_RegValue){LCD_WR_REG(LCD_Reg);LCD_WR_DATA(LCD_RegValue);}〃开始写GRAMvoidLCD_WriteRAM_Prepare(void){LCD_WR_REG(0x22);}承沐穴******^******^********^****^*^****^**********电穴*穴******穴**穴*穴*穴**穴*穴****穴**函数名称:LCD_DisplayOn**功能描述:开启LCD显示**功能描述:关闭LCD显示voidLCD_Display(u8off_on)〃开启显示if(off_on==l)〃开启显示LCD_WriteReg(0x07,0x0173);elseLCD_WriteReg(0x07/0x0);//关闭显示}〃设置光标位置//Xpos:横坐标〃Ypos:纵坐标voidLCD_SetCursor(ul6Xpos,ul6Ypos){if(Horizontal_or_Vertical){〃横屏显示LCD_WriteReg(0x20,Ypos);LCD_WriteReg(0x21319-Xpos);}〃竖屏显示else{LCD_WriteReg(0x20,Xpos);LCD_WriteReg(0x21,Ypos);}**函数名称:LCD_Scan_Dir**功能描述:设置LCD的自动打描方向voidLCD_Scan(void){ul6regval=0;regval|=L2R_U2D;//从左到右,从上到下regval|=l«12;LCD_WriteReg(0X03zregval);}**函数名称:LCD_DrawPoint**功能描述:画点**x:0-239**y:0-319**POINT_COLOR:此点的颜色voidLCD_DrawPoint(ul6x,ul6y,ul6Color){LCD_SetCursor(x,y);//设置光标位置LCD_WriteRAM_Prepare();〃开始写入GRAMLCD_WR_DATA(Color);}**函数名称:LCD_GPIO_Configuration**功能描述:LCD_IO口配置voidLCD_GPIO_Configuration(void){GPIO」nitTypeDefGPIO」nitStructure;RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO,ENABLE);GPIO_PinRemapConfig(GPIO_Remap_SWJ_JTAGDisable,ENABLE);〃关闭jatg时钟GPIO」nitStructure.GPIO_PinGPIO_Pin_101GPIO_Pin_91GPIO_Pin_81GPIO_Pin_71GPIO_Pin_6; 〃GPIO_Pin_10GPIO」nitStructure・GPIO_Mode=GPIO_Mode_Out_PP;〃推挽输出GPIO」nitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO」nit(GPIOC,&GPIO」nitStructure);//GPIOCGPIO_SetBits(GPIOC,GPIO_Pin_101GPIO_Pin_91GPIO_Pin_8|GPIO_Pin_71GPIO_Pin_6);GPIO」nitStructure・GPIO_Pin=GPIO_Pin_All;//GPIO」nit(GPIOB,&GPIO」nitStructure);//GPIOBGPIO_SetBits(GPIOB,GPIO_Pin_All);

^*****************************************************************************函数名称:LCD_GPIOB_Configuration**功能描述:led数据传输用到的10配置voidLCD_GPIOB_Configuration(u8sei){GPIO」nitTypeDefGPIO」nitStructure;if(sel==l){GPIO」nitStructure・GPIO_Mode=GPIO_Mode_Out_PP;〃推挽输出GPIO」nitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO」nitStructure・GPIO_Pin=GPIO_Pin_All;//GPIO」nit(GPIOB,&GPIO」nitStructure);//GPIOBGPIO_SetBits(GPIOB,GPIO_Pin_AII);}else{GPIO」nitStructure・GPIO_Mode=GPIO_Mode_IPU;〃推挽输出GPIO」nitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO」nitStructure・GPIO_Pin=GPIO_Pin_All;//GPIO」nit(GPIOB,&GPIO」nitStructure);//GPIOB}}voidLCD_Configuration(void)LCD_GPIO_Configuration();LCD_WriteReg(0x0000,0x0001);//nJ以去掉LCD_WriteReg(0x00E5,0x78F0);LCD_WriteReg(0x0001,0x0100);LCD_WriteReg(0x0002,0x0700);LCD_WriteReg(OxOOO3,0x1030);LCD_WriteReg(0x0004,0x0000);LCD_WriteReg(0x0008,0x0202);LCD_WriteReg(0x0009,0x0000);LCD_WriteReg(OxOOOA,OxOOOO);LCD_WriteReg(OxOOOC,0x0000);LCD_WriteReg(0x000D,0x0000);LCD_WriteReg(0x000Fz0x0000);//poweronsequeneeVGHVGLLCD_WriteReg(0x0010,0x0000);LCD_WriteReg(0x0011,0x0007);LCD_WriteReg(0x0012,0x0000);LCD_WriteReg(0x0013,0x0000);LCD_WriteReg(0x0007,0x0000);//vghLCD_WriteReg(0x0010,0xl690);LCD_WriteReg(0x001X0x0227);//delayms(lOO);//vregioutLCD_WriteReg(0x0012,0x009D);//)x001b//delayms(lOO);//vomamplitudeLCD_WriteReg(0x0013,0xl900);//delayms(lOO);//vomHLCD_WriteReg(0x0029,0x0025);LCD_WriteReg(OxOO2B,OxOOOD);//gammaLCD_WriteReg(0x0030,0x0007);LCD_WriteReg(OxOO31,OxO3O3);LCD_WriteReg(OxOO32,OxOOO3);//0006LCD_WriteReg(OxOO35,OxO2O6);LCD_WriteReg(0x0036,0x0008);LCD_WriteReg(0x0037,0x0406);LCD_WriteReg(0x0038,0x0304);/A)200LCD_WriteReg(0x0039,0x0007);LCD_WriteReg(0x003C,0x0602);//0504LCD_WriteReg(OxOO3D,0x0008);//ramLCD_WriteReg(0x0050,0x0000);LCD_WriteReg(0x0051,0x00EF);LCD_WriteReg(OxOO52,OxOOOO);LCD_WriteReg(0x0053,0x013F);LCD_WriteReg(0x0060,0xA700);LCD_WriteReg(0x0061,0x0001);LCD_WriteReg(0x006A,0x0000);//LCD_WriteReg(0x0080,0x0000);

LCD_WriteReg(0x0081,0x0000);LCD_WriteReg(0x0082,0x0000);LCD_WriteReg(0x0083,0x0000);LCD_WriteReg(0x0084,0x0000);LCD_WriteReg(0x0085,0x0000);//LCD_WriteReg(0x0090,0x0010);LCD_WriteReg(0x0092,0x0600);LCD_WriteReg(0x0007,0x0133);LCD_WriteReg(0x00,0x0022);//**穴******穴******穴******穴*穴**承*穴*穴****穴****)1(******穴*穴**穴*穴*穴**穴*穴*穴承*穴******穴**函数名称:LCD」nit**功能描述:LCD初始化voidLCD」nit(void)LCD_Configuration();LCD_Scan();LCD_LED;//点亮背光LCD_Clear(WHITE);}**穴******穴******穴

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论