欢迎来到天天文库
浏览记录
ID:16449929
大小:22.50 KB
页数:24页
时间:2018-08-09
《单片机使用状态机的键盘程序( scm using state machine keyboard program)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、51单片机使用状态机的键盘程序(51SCMusingstatemachinekeyboardprogram)IalsosendkeyboardprogramsusingstatemachinestosupportsinglekeysanddoublebondsSinglekey,keyboard,status,program,joininthefun1headerfile:KeyBoard.h#ifndef_Key_Board_h_#define_Key_Board_h_#defineKey_Up0x3E//arrow#defineKey_Down0x3D//downarrow#defin
2、eKey_Add0x3B//add#defineKey_Sub//0x37reduction#defineKey_Enter//0x2F.#defineKey_Return0x1F//returnThekeycombination#define0x33//Key_LR.Maythisdefinitionotherkeycombinations......#defineKey_NULL//0xFFwithoutanykeysSeveralfunctionsinthestatement/externalcallsExternvoidKey_Board_Init(void);//keyboard
3、interfaceinitializationExternU8Read_Key(void);//readkeyfunctionreturnsthekeyboardbufferinkeyExternvoidKey_In(void);//handlekeyinputfunction,thetimerinterruptinthecallExternvoidKey_Board_Test(void);//keyboardinterfacetestfunction(usedonlyinthecommissioningphase)#endif2sourcefile:KeyBoard.c//#includ
4、e"includes.h"//publicheaderfiles#include"Key_Board.h""//keyboardbufferrelatedconstantsdefined#defineKeyBuffLen//8keydefinitionofringbufferlengthis8(thesizeofthebuffercanbefreelydefinedasgreaterthan0.)//defineakeyboardbufferstructureStructStruct_KeyBoardBuff{U8buff[KeyBuffLen];//keyringbufferU8in;/
5、/writekeyinstructions(writetimerinterrupt)U8out;//readkeyindicator(Reader)}Key;/*************************************************************************Prototypeoffunction:voidKey_Board_Init(void)Function:initializethekeyboardinterface,thatis,thekeybufferisclearedAfferentparameter:NoneReturnparam
6、eter:NoneGlobalvariables:directmanipulationofthekeyboardbufferstructureDesign:MinisterWeiamo73@126.comModificationdate:2007-9-5Remark:itiscalledonlyoncethepowerupisinitialized**************************************************************************/VoidKey_Board_Init(void){Memset(&Key,0,sizeof(Ke
7、y));}/*************************************************************************Prototypeoffunction:U8Read_Key(void)Function:readakeyvaluefromthekeybufferAfferentparameter:NoneReturnparameter:U8keyvalue,ifthebuffe
此文档下载收益归作者所有