中级会员
 
- 积分
- 294
- 金钱
- 294
- 注册时间
- 2017-7-7
- 在线时间
- 42 小时
|

楼主 |
发表于 2017-11-8 10:33:33
|
显示全部楼层
void KEY_GPIO_init(void)//初始化管脚
{
/*********定义一个GPIO_InitTypeDef 类型的结构体**********/
GPIO_InitTypeDef GPIO_InitStructure;
/*********选择要控制的GPIOx的引脚**********/
//GPIO_InitStructure.GPIO_Pin =(GPIO_Pin_6|GPIO_Pin_7);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
/*********设置引脚速率为50MHZ**********/
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
/*********设置引脚模式为通用上拉输入**********/
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
/*打开LED使用的GPIO的时钟使能*/
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
/*初始化相应的GPIO*/
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2)==Bit_RESET)
{
delay_ms(10);
if(GPIO_ReadInputDataBit(GPIOA, GPIO_Pin_2)==Bit_RESET)
{
GPIO_SetBits(GPIOA,GPIO_Pin_1);
// }
}
}
这是相关代码,没有检测到低电平
|
-
已经改了,贴错了
|