stm32:简单按键输入实现
开发环境keil4,芯片STM32F103C8T6 1、main.c //串口实验 #include "sys.h" #include "delay.h" #include "key.h" #define DC12VDO_ON() GPIO_SetBits (GPIOC, GPIO_Pin_13) #define DC12VDO_OFF() GPIO_ResetBits (GPIOC, GPIO_Pin_13) int Index1,Index2,Index3 = 0; int time1; unsigned char gUart_Rece_Buf1[256]; unsigned char gUart_Rece_Buf2[256]; unsigned char gUart_Rece_Buf3[2048]; int i,j=0; u8 key; int main(void) { delay_init(); //延时函数初始化 sys_Init(); //系统初始化(时钟初始化、中断初始化、GPIOx初始化、串口1初始化、串口2初始化、串口3初始化) while(1) { DC12VDO_OFF();//led常亮 key=KEY_Scan(); if(key==1) { DC12VDO_ON();//灭led delay_ms(1000);//等待 } } } 2、key.c