#include <KEY44.h>
#include <sys.h>
#include <delay.h>
//PA0-PA3为输出
//PA4-PA7为输入
//RX---B10
//TX---B11
void KEY44_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_Init(GPIOA, &GPIO_InitStructure);
}
unsigned char key44_Scan(void)
{
H_1= 0;
H_2= 1;
H_3= 1;
H_4= 1;
if(L_1 == 0)
{
delay_ms(10);
if(L_1 == 0)
{
while(!L_1);
return 1;
}
}
2. 矩阵键盘通过串口 3 输出
最新推荐文章于 2022-12-30 22:10:23 发布