欢迎来到天天文库
浏览记录
ID:47709878
大小:54.00 KB
页数:9页
时间:2019-10-29
《C8051键盘测试程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include//-----------------------------------------------------------------------------#defineucharunsignedchar#defineuintunsignedint#defineBAUDRATE#defineSYSCLKvoidSYSCLK_Init(void);voiddelaynus(unsignedintq);voidPORT_Init(void);voi
2、dSPI0_Init(void);voidLCD_Init(void);voidSendSPIByte(unsignedcharch);voiddelaynms(unsignedintj);voidwritecom(unsignedcharcom);voidwritedata(unsignedchard);voidwritechar(unsignedcharua);voidWrite_COM(ucharins);voidlcden(datad);voidLCD_set_xy(unsignedcharx,unsignedcha
3、ry);voidLCD_write_string(unsignedcharn);voidlcd_key1(void);voidlcd_key2(void);voidlcd_key3(void);voidlcd_key4(void);voidUART0_Init(void);voidpresskey(void);//-----------------------------------------------------------------------------//GlobalCONSTANTS//-----------
4、------------------------------------------------------------------sbitS3=P1^0;sbitS4=P1^1;sbitS5=P1^2;sbitS6=P1^3;sbitlcdcs=P3^0;unsignedcharcomd,kk,sdf,ppca;unsignedcharvirt_port,v,b,m;unsignedcharlcd_data_count;unsignedcharlcdpoint;unsignedcharqqq;unsignedchardat
5、a8;unsignedinti;//-----------------------------------------------------------------------------//-----------------------------------------------------------------------------voidmain(void){WDTCN=0xde;//disablewatchdogtimerWDTCN=0xad;SYSCLK_Init();PORT_Init();UART0_
6、Init();//initializecrossbarandGPIOSPI0_Init();LCD_Init();delaynms(20);delaynus(100);LCD_set_xy(0X00,0);delaynus(200);presskey();delaynus(200);LCD_write_string(16);delaynus(200);while(1){if(S3==0){Write_COM(0X01);delaynms(200);LCD_set_xy(0X00,0);delaynus(200);lcd_ke
7、y1();delaynus(200);LCD_write_string(6);delaynus(200);}elseif(S4==0){Write_COM(0X01);delaynms(200);LCD_set_xy(0X00,0);delaynus(200);lcd_key2();delaynus(200);LCD_write_string(6);delaynus(200);}elseif(S5==0){Write_COM(0X01);delaynms(200);LCD_set_xy(0X00,0);delaynus(20
8、0);lcd_key3();delaynus(200);LCD_write_string(6);delaynus(200);}elseif(S6==0){Write_COM(0X01);delaynms(200);LCD_set_xy(0X00,0);delaynus(200);lcd_k
此文档下载收益归作者所有