新手入门
- 积分
- 15
- 金钱
- 15
- 注册时间
- 2018-7-27
- 在线时间
- 3 小时
|
1金钱
#include"key.h"
#include"sys.h"
#include"stm32f10x.h"
#include"delay.h"
#include"led.h"
#include"beep.h"
void Key_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE|RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_3|GPIO_Pin_4;
GPIO_Init(GPIOE,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPD;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
void Key_Scan(void)
{
int GPIOE_Key0,GPIOE_Key1,GPIOA_WK_UP,GPIOE_TEMP;
GPIOE_TEMP=GPIO_ReadInputData(GPIOE);
GPIOE_Key1=GPIOE_TEMP&00001000;
GPIOE_Key0=GPIOE_TEMP&00010000;
GPIOA_WK_UP=GPIO_ReadInputDataBit(GPIOA,GPIO_Pin_0);
if(GPIOE_Key1==0)
{LED1=!LED1;
}
if(GPIOE_Key0==0)
{LED0=!LED0;
}
if(GPIOA_WK_UP==1)
{//BEEP=!BEEP;
}
}
|
|