欢迎来到天天文库
浏览记录
ID:15836399
大小:37.50 KB
页数:11页
时间:2018-08-06
《按键去抖--对按键输入的整数进行处理程序(未加小数点)》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/********************************************************************************************************************************************************************************FILE:key.c*Description:keyprocess**Copyright(c)2003~2007byWANGSHAOWEI.AllRightsReserved.**History:*VersionNameDat
2、eDescription1.0WangShaowei2003/07/16InitialVersion(MCUSystem)2.0WangShaowei2005/06/01MS23.0WangShaowei2007/03/11MS3*******************************************************************************************************************************************************************************
3、*/#include"stm32f10x_lib.h"#include"stm32f10x_type.h"#include"common.h"#include"key.h"#defineShort_keycounter7//¶ÔɨÃèµ½µÄ°´¼ü´ÎÊý¼ÆÊý£¬Õâ¾ö¶¨ÁË°´¼üµÄÁéÃô¶È¡£u8kk;U8keycan;U8m=0;U8a[10]={0};//mΪÊý×éµÄϱ꣬a[10]ÓÃÀ´´æ·Å¼üÈëµÄÊýµÄÿһλ¡£U32temp1=0;U32temp2=0;//temp1¡¢temp2·Ö±ðÓÃÀ´´æ·Å¼üÈë
4、ÖµµÄÕûÊý²¿·ÖºÍСÊý²¿·Ö¡£U32key_counter=0;//ÓÃÀ´¼ÆÊý°´¼ü¼ì²âµ½µÄ´ÎÊýU8t1[13]={0};//ÓÃÀ´´æ·Åtemp¾calculate¼ÆËãºóµÄÿһλֵ¡£voidkey_check(void){U8linekeyNo;//,U8keycan;U8checkkeyline();U8checkkeyrow();//staticU8KeySave=0;linekeyNo=checkkeyline();if(linekeyNo!=0xff){keycan=checkkeyrow();msg_s
5、end_msg(MSG_KEY,keycan);//MSG_SEND_MSG(MSG_KEY,keycan);}//KeySave=KeyRead;}/********************************************************************************FunctionName:u8checkkey*Description:checkisthekeyhasbeenpush*Input:None*Output:None*Return:oxff(nokeywaspush)or0x00(No.1line)0x01(No.2
6、line)0x02(No.3line)0x03(No.4line)*******************************************************************************/u8checkkeyline(){GPIOA->ODR=0xfffffff0;if(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_4)==0x00)return(0x00);elseif(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_5)==0x00)return(0x01);elseif(GPI
7、O_ReadInputDataBit(GPIOC,GPIO_Pin_6)==0x00)return(0x02);elseif(GPIO_ReadInputDataBit(GPIOC,GPIO_Pin_7)==0x00)return(0x03);elsereturn(0xff);}/********************************************************************************FunctionName:u8checkkey*Description:che
此文档下载收益归作者所有