key.c 647 B

12345678910111213141516171819202122
  1. #include "stm32f10x.h"
  2. #include "key.h"
  3. #include "sys.h"
  4. #include "delay.h"
  5. //按键初始化函数
  6. void KEY_Init(void) //IO初始化
  7. {
  8. GPIO_InitTypeDef GPIO_InitStructure;
  9. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);//使能PORTA,PORTE时钟
  10. GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;//KEY0-KEY2
  11. GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //设置成上拉输入
  12. GPIO_Init(GPIOB, &GPIO_InitStructure);//初始化
  13. // //初始化 WK_UP-->GPIOA.0 下拉输入
  14. // GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  15. // GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD; //PA0设置成输入,默认下拉
  16. // GPIO_Init(GPIOA, &GPIO_InitStructure);//初始化GPIOA.0
  17. }