各位好:
有个问题想请教下
现在在用tft,原子家的
程序用的库写的:
__inline void LCD_Write_Data(uint16_t data) //写数据,内联函数
{
LCD_RS_SET(); //写数据
LCD_CS_CLR(); //片选开启
GPIO_Write(GPIOB,data); //写入数据
LCD_WR_CLR(); //写时序
LCD_WR_SET();
LCD_CS_SET(); //片选关闭
}
void LCD_Write_Comm(uint8_t comm) //写命令
{
LCD_RS_CLR(); //写命令
LCD_CS_CLR(); //片选开启
GPIO_Write(GPIOB,comm); //写入数据
LCD_WR_CLR();
LCD_WR_SET();
LCD_CS_SET(); //片选关闭
}
uint16_t LCD_Read_Reg(uint8_t add) //读寄存器
{
GPIO_InitTypeDef GPIO_InitStructure;
uint16_t d;
LCD_Write_Comm(add); //写寄存器地址
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU; //上拉输入
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStructure);
GPIO_Write(GPIOB,0xffff); //输出高电平
LCD_RS_SET(); //数据
LCD_CS_CLR();
LCD_RD_CLR();
d=GPIO_ReadInputData(GPIOB);
LCD_RD_SET();
LCD_CS_SET();
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_All;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOB,&GPIO_InitStructure);
return d;
}
这么去读0x00:
printf("%x\n",LCD_Read_Reg(0x00));
printf("%x\n",LCD_Read_Reg(0x00));
printf("%x\n",LCD_Read_Reg(0x00));
每次第一个会读出9325,但是第二个第三个都是0:
9325
0
0
而且如果我把地址改为别的,读出来的还是这样
是这三个驱动的问题吗
|