欢迎来到天天文库
浏览记录
ID:47918371
大小:38.00 KB
页数:15页
时间:2019-10-29
《基于STM32的_矩阵键盘_驱动(中断方式)(1)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、//==========================Keyboard.h===============================///*---------------------------------------------- 本程序实现4*5键盘的扫描 从左到右,从上到下,键值 依次为1-20------------------------------------------------*/#ifndef__KEYBOARD_H#define__KEYBOARD_H#include"
2、stm32f10x_lib.h"//选择扫描模式#defineInterrupt_Scan //中断扫描模式,要在NVIC在中打开对应中断/*可以自己定义其它扫描方式*/#defineDELAY_COUNT 0x0FFFF/*键盘控制引脚定义*/#defineKeyboard_Control_Port GPIOD#defineKeyboard_Line_1 GPIO_Pin_0#defineKeyboard_Line_2 GPIO_Pin_1#defineKeyboard_Line_3 GPIO_Pin_2#defineKe
3、yboard_Line_4 GPIO_Pin_3#defineKeyboard_Line_5 GPIO_Pin_4#defineKeyboard_Row_1 GPIO_Pin_5#defineKeyboard_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#
4、defineKeyboard_Line (Keyboard_Line_1
5、Keyboard_Line_2
6、Keyboard_Line_3
7、Keyboard_Line_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_EXT
12、I_Row2 EXTI_Line6#defineKeyboard_EXTI_Row3 EXTI_Line7#defineKeyboard_EXTI_Row4 EXTI_Line8#defineKeyboard_EXTI_PortSource GPIO_PortSourceGPIOD#defineKeyboard_EXTI_PinSource1GPIO_PinSource5#defineKeyboard_EXTI_PinSource2GPIO_PinSource6#defineKeyboard_EXTI_PinSource3GPIO_Pin
13、Source7#defineKeyboard_EXTI_PinSource4GPIO_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; //当前键值
17、externunsignedcharKeyboard_Change_Flag; //键值改变标志,读取新的键值后由主程序清零/*键盘接口函数声明*/#ifdefInterrupt_ScanexternvoidInit_Keyboard_Interrupt(void);//键盘初始化为键盘扫描模式#endifexternvoidDelay(vu32nCount); //用于延时消抖#endif/*KEYBOARD_H*///==============================================================
18、===////============================Keyboard.c=============================/
此文档下载收益归作者所有