欢迎来到天天文库
浏览记录
ID:47477747
大小:38.51 KB
页数:6页
时间:2020-01-11
《基于STM32的_矩阵键盘运用》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//==========================keyboard.h===========================//#ifndef__KEYBOARD_H#define__KEYBOARD_H#include"stm32f10x_lib.h"//键盘选择扫描模式。#defineInterrupt_Scan //中断扫描模式,要在NVIC在中打开对应中断。/*可以定义其它扫描方式*/#defineDELAY_COUNT 0x0FFFF/*键盘控制引脚定义*/#defineK
2、eyboard_Control_Port GPIOD#defineKeyboard_Line_1 GPIO_Pin_0#defineKeyboard_Line_2 GPIO_Pin_1#defineKeyboard_Line_3 GPIO_Pin_2#defineKeyboard_Line_4 GPIO_Pin_3#defineKeyboard_Line_5 GPIO_Pin_4#defineKeyboard_Row_1 GPIO_Pin_5#defineKeyboar
3、d_Row_2 GPIO_Pin_6#defineKeyboard_Row_3 GPIO_Pin_7#defineKeyboard_Row_4 GPIO_Pin_8#defineKeyboard_LineBaseKeyboard_Line_1#defineKeyboard_RowBase Keyboard_Row_1#defineKeyboard_Line (Keyboard_Line_1
4、Keyboard_Line_2
5、Keyboard_Line_3
6、Keyboard_Line_
7、4
8、Keyboard_Line_5)#defineKeyboard_Row (Keyboard_Row_1
9、Keyboard_Row_2
10、Keyboard_Row_3
11、Keyboard_Row_4)#ifdefInterrupt_Scan /*中断扫描模式宏定义*/#defineKeyboard_EXTI_Row1 EXTI_Line5#defineKeyboard_EXTI_Row2 EXTI_Line6#defineKeyboard_EXTI_Row3 EXTI_Line7#def
12、ineKeyboard_EXTI_Row4 EXTI_Line8#defineKeyboard_EXTI_PortSource GPIO_PortSourceGPIOD#defineKeyboard_EXTI_PinSource1GPIO_PinSource5#defineKeyboard_EXTI_PinSource2GPIO_PinSource6#defineKeyboard_EXTI_PinSource3GPIO_PinSource7#defineKeyboard_EXTI_PinSou
13、rce4GPIO_PinSource8#defineKeyboard_IRQ_Channel EXTI9_5_IRQChannel#defineKeyboard_EXTI_Line (Keyboard_EXTI_Row1
14、Keyboard_EXTI_Row2
15、Keyboard_EXTI_Row3
16、Keyboard_EXTI_Row4)#endif /*中断扫描模式宏定义*//*键盘全局变量声明*/externunsignedintKeyboard_Val; //当前键值externuns
17、ignedcharKeyboard_Change_Flag; //键值改变标志,读取新的键值后由主程序清零/*键盘接口函数声明*/#ifdefInterrupt_ScanexternvoidInit_Keyboard_Interrupt(void);//键盘初始化为键盘扫描模式#endifexternvoidDelay(vu32nCount); //用于延时消抖#endif/*KEYBOARD_H*///==============================================
18、==============////=========================Keyboard.c=============================//#include"stm32f10x_lib.h"#include"Keyboard.h"?????????????unsignedintKeyboard_Val=0; //保存键值unsignedcharKeyboard_Change_Flag=0;//键值改变标志,读取键值后清零/**********************
此文档下载收益归作者所有