完成按键初始化函数的编写 void KEY_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd( 1 , ENABLE); // 使能 GPIOA,GPIOE 时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2|GPIO_Pin_3|GPIO_Pin_4; GPIO_InitStructure.GPIO_Mode = 2 ; // 工作模式 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP; GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = 3 ; //WK_UP 对应引脚 PA0 GPIO_InitStructure.GPIO_PuPd = 4 ; // 下拉 GPIO_Init(GPIOA, &GPIO_InitStructure);// 初始化 GPIOA0 }