新手入门
积分 5
金钱 5
注册时间 2020-11-2
在线时间 0 小时
1 金钱
LCD的CS、RS、RD、WS、BL对应的GPIO设置为推挽输出;
#define LCD_RS PCout(8)
`````
void Lcd_Write(u8 CD, u16 Date)
{
GPIOB->CRL=0X33333333; //推挽输出
GPIOB->CRH=0X33333333;
LCD_RS = CD; //CD = 0,写数据; CD = 1,写命令;
LCD_CS = 0;
GPIOB->ODR = Date;
LCD_WR = 0;
LCD_WR = 1;
LCD_CS = 1;
}
u16 Lcd_Read(void)
{
u16 Read_value;
GPIOB->CRL = 0X44444444; //浮空输入
GPIOB->CRH = 0X44444444;
GPIOB->ODR = 0;
GPIOB->IDR = 0xffffffff;
LCD_RS = 1;
LCD_CS = 0;
Read_value = GPIOB->IDR;
LCD_RD = 0;
LCD_RD = 1;
LCD_CS = 1;
return Read_value;
}
u16 Read_Classify()
{
u16 symbol = 0 ;
u16 value;
Lcd_Write(0, 0xD3); //写0xd3命令, 获取ILI控制的ID
symbol = Lcd_Read(); //dummy参数
symbol = Lcd_Read();
symbol = 0;
symbol = Lcd_Read(); //得到ID的高8位
symbol = symbol<<8; //先右移8位,"为了后续得到低8位后获得完整ID信息"
symbol = symbol|(( value = Lcd_Read()) & 0xff); //得到低8位信息,并计算得到完整ID信息
return symbol; //返回ID,通过串口打印至调试助手;
}
我来回答