新手上路
- 积分
- 49
- 金钱
- 49
- 注册时间
- 2017-4-25
- 在线时间
- 6 小时
|
发表于 2017-8-19 14:11:12
|
显示全部楼层
为了避免混乱我把改后的整个上电初始化程序粘过来,楼主自己可以自行对比例程源代码
u8 GT9147_Init(void)
{
u8 temp[5];
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOF, ENABLE); //使能PF端口时钟
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; // PF11端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF, &GPIO_InitStructure);//PF11推挽输出
GPIO_SetBits(GPIOF,GPIO_Pin_11);//上拉
CT_IIC_Init();
GT_RST=0;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // PB2端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //下拉输入
GPIO_Init(GPIOF, &GPIO_InitStructure);//PF10下拉输入
GPIO_ResetBits(GPIOF,GPIO_Pin_10);//下拉
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // PB2端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //上拉输入
GPIO_Init(GPIOF, &GPIO_InitStructure);//PF10上拉输入
GPIO_SetBits(GPIOF,GPIO_Pin_10);//上拉
delay_ms(10);
GT_RST=1;
delay_ms(10);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10; // PB2端口配置
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOF, &GPIO_InitStructure);
delay_ms(100);
GT9147_RD_Reg(GT_PID_REG,temp,4); //读取产品ID
temp[4]=0;
printf("CTP ID:%s\r\n",temp); //打印ID
if(strcmp((char*)temp,"9147")==0) //ID==9147
{
temp[0]=0X02;
GT9147_WR_Reg(GT_CTRL_REG,temp,1);//软复位GT9147
GT9147_RD_Reg(GT_CFGS_REG,temp,1);//读取GT_CFGS_REG寄存器
if(temp[0]<0X60)//默认版本比较低,需要更新flash配置
{
printf("Default Ver:%d\r\n",temp[0]);
GT9147_Send_Cfg(1);//更新并保存配置
}
delay_ms(10);
temp[0]=0X00;
GT9147_WR_Reg(GT_CTRL_REG,temp,1); //结束复位
return 0;
}
return 1;
} |
|