今天记录一个轮询按键的函数
在上一篇点灯的基础上添加key.c和key.h,我用的开发板key3的引脚是PE4
key.c的代码如下
#include "key.h"
extern void Delay(__IO u32 count);
void Key_Gpio_Config(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOE,ENABLE);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IPU;
//GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOE,&GPIO_InitStructure