




已阅读5页,还剩10页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/key.c/* FILE: key.c* Description: key process* * Copyright (c) 20032007 by WANG SHAOWEI. All Rights Reserved.* * History:* VersionName DateDescription 1.0Wang Shaowei2003/07/16Initial Version (MCU System) 2.0Wang Shaowei2005/06/01MS2 3.0Wang Shaowei2007/03/11MS3 */#include stm32f10x_lib.h#include stm32f10x_type.h #include common.h#includekey.h/*routine.cRoutineCounter*(Short_keycounter*RoutineCounter*20ms),s*/#define Short_keycounter 2 /*/#define F_PLLU 162.4*1000000.0 /,HZ u8 kk; U8 keycan;/*=*/ U8 m=0 ; U8 a10=0; /ma10 U32 temp1=0; U32 temp2=0; /temp1temp2 U32 key_counter=0; / U8 t110=0;/tempcalculate/*=*/*/long int F_OUT;long int change_fr; U8 t210=0;/freq_word()/*/*=*/*routine.cswitch(RoutineCounter)case-routine_flag*/ vu8 routine_flag_4=0 ; /case:4/*=*/void key_check(void) U8 linekeyNo; /,U8keycan; U8 checkkeyline(); U8 checkkeyrow(); / static U8 KeySave = 0;linekeyNo=checkkeyline(); if (linekeyNo!=0xff) keycan=checkkeyrow(); msg_send_msg(MSG_KEY, keycan); /MSG_SEND_MSG(MSG_KEY, keycan); /KeySave = KeyRead; /* Function Name : u8 checkkey* Description : check is the key has been push * Input : None* Output : None* Return : oxff(no key was push) or 0x00(No.1 line) 0x01(No.2 line) 0x02(No.3 line) 0x03(No.4 line)*/ u8 checkkeyline() GPIOA-ODR=0xfffffff0; if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4)=0x00)return(0x00);else if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)=0x00)return(0x01);else if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6)=0x00)return(0x02);else if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7)=0x00)return(0x03);else return(0xff); /* Function Name : u8 checkkey* Description : check is the key has been push * Input : None* Output : None* Return : oxff(no key was push) or 0x00(No.1 line) 0x01(No.2 line) 0x02(No.3 line) 0x03(No.4 line)*/u8 checkkeyrow() u8 linenummber; linenummber=checkkeyline(); GPIOA-ODR=0xfffffffE; if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4)=0x00)kk=(0x00+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)=0x00)kk=(0x00+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6)=0x00)kk=(0x00+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7)=0x00)kk=(0x00+linenummber); GPIOA-ODR=0xfffffffD; if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4)=0x00)kk=(0x04+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)=0x00)kk=(0x04+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6)=0x00)kk=(0x04+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7)=0x00)kk=(0x04+linenummber);GPIOA-ODR=0xfffffffB; if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4)=0x00)kk=(0x08+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)=0x00)kk=(0x08+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6)=0x00)kk=(0x08+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7)=0x00)kk=(0x08+linenummber);GPIOA-ODR=0xfffffff7; if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_4)=0x00)kk=(0x0C+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_5)=0x00)kk=(0x0C+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_6)=0x00)kk=(0x0C+linenummber); if(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_7)=0x00)kk=(0x0C+linenummber);return (kk); void reset_temp(void) / U8 i=0,j=0,k=0; m=0; for(i=0;i10;i+) ai=0; /a10=0;for temp1=0; temp2=0; key_counter=0; for(j=0;j10;j+) /temp1t110 t1j=0; / t110=0; for(k=0;k(double)s1+0.5) change_fr=s1+1; else change_fr=s1;/change_frs void mmi_process(U8 key) switch(keycan) case(0x00): /0 key_counter=key_counter+1; /showzifustr(m*8,0,0,0,255); /showzifu(m*8,0,am,0x03,255); if(key_counter=Short_keycounter) am=0;/am=0showzifuam=0000ASCII0ASCII48showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; /showzifustr(m*8,0,0,0,255); break; case(0x01):/1 key_counter=key_counter+1;/showzifustr(m*8,0,1,0,255); if(key_counter=Short_keycounter) am=1;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x02):/2 key_counter=key_counter+1;/showzifustr(m*8,0,2,0,255); if(key_counter=Short_keycounter)am=2;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x03):/3 key_counter=key_counter+1;/showzifustr(m*8,0,3,0,255); if(key_counter=Short_keycounter) am=3;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x04):/4 key_counter=key_counter+1;/showzifustr(m*8,0,4,0,255); if(key_counter=Short_keycounter)am=4;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break; case(0x05):/5 key_counter=key_counter+1;/showzifustr(m*8,0,5,0,255); if(key_counter=Short_keycounter)am=5;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x06):/6 key_counter=key_counter+1;/showzifustr(m*8,0,6,0,255); if(key_counter=Short_keycounter)am=6;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x07):/7 key_counter=key_counter+1;/showzifustr(m*8,0,6,0,255); if(key_counter=Short_keycounter)am=7;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x08):/8 key_counter=key_counter+1;/showzifustr(m*8,0,6,0,255); if(key_counter=Short_keycounter)am=8;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break; case(0x09):/9 key_counter=key_counter+1;/showzifustr(m*8,0,6,0,255); if(key_counter=Short_keycounter)am=9;showzifu(m*8,0,am,0x03,255); m=m+1; key_counter=0; break;case(0x0A): /HZ calculate_temp1(); sprintf(t1,%-d,temp1); showzifustr(0,12,t1,0x03,255); showzifustr(80,12,HZ ,0x03,255); /GPIO F_OUT= temp1; freq_word (F_OUT); sprintf(t2,%-d,change_fr); showzifustr(0,24,Fword:,0x03,255); showzifustr(40,24,t2,0x03,255); break; case(0x0B):/KHZ calculate_temp1(); sprintf(t1,%-d,temp1); showzifustr(0,12,t1,0x03,255); showzifustr(80,12,KHZ,0x03,255); temp1=temp1*1000; /GPIO F_OUT= temp1; freq_word (F_OUT);sprintf(t2,%-d,change_fr);showzifustr(0,24,Fword:,0x03,255); showzifustr(40,24,t2,0x03,255); break;/break/case(0x0C):/Decimal-.case(0x0C):key_counter=key_counter+1;/showzifustr(m*8,0,6,0,255); if(key_counter=Short_keycounter)routine_flag_4=+routine_flag_4;showzifu(90,0,routine_flag_4+48,0x03,255);if(routine_flag_4=3) routine_flag_4=0; key_counter=0; break;/case(0x0D):/100HZ10KHZ100HZ /case(0x0E):/Backspacecase(0x0F):/ LCD_Clear(255,0);/LCD_Clear(255,0) reset_temp(); break;/default: /default:GPIOF-ODR=0x00000000; /rountine.c/* FILE: routine.c* Description: * * Copyright (c) 20032007 by WANG SHAOWEI. All Rights Reserved.* * History:* VersionName DateDescription 1.0Wang Shaowei2003/07/16Initial Version (MCU System) 2.0Wang Shaowei2005/06/01MS2 3.0Wang Shaowei2007/03/11MS3 */#include common.h/U8 KeyStore;U8 count_time=0;/*=* Function: routine_process* Description: routine program* Input Para: void* Output Para: void* Return Value: void=*/void routine_process(void)static U8 RoutineCounter = 0; /static U8 RTCCounter = 0;if(+RoutineCounter = 5)RoutineCounter = 0; switch(RoutineCounter)case 0:key_check();/led_control(KeyStore);/if(+RTCCounter = 40)/RTCCounter = 0;/rtc_soft_routine(); /*/ break;case 1:/showzifustr(0,36,Fword:,0x03,255);/LedDisplay_control(FALSE, 1, uty_hex2bcd(tTCMember.second) & 0x0F);break;case 2:/LedDisplay_control(FALSE, 2, uty_hex2bcd(tTCMember.second) 4);break;case 3:/LedDisplay_control(TRUE, 3, uty_hex2bcd(tTCMember.minute) & 0x0F);break;case 4:/*RoutineCounter4*,case 0key_check();*/ if(routine_flag_4=0)/oh yeah! showzifu(90,0,routine_flag_4+48,0x03,255); showzifustr(0,42, ,0x03,255); showzifustr(0,54,do
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025版房地产项目融资协议书示范
- 2025年度车辆托管与车辆租赁及增值服务协议
- 2025年度企业员工食堂膳食供应合同
- 2025年度企业商业信用贷款抵押合同模板
- 2025版事业单位信息安全人员聘用合同书(含数据安全协议)
- 2025版汽车维修配件进口分销合同
- 2025版水泥沙石行业绿色认证及标准制定合同
- 2025版医疗器械行业高级管理人员劳动合同示范
- 2025版桥梁施工环境保护及恢复合同
- 2025版幼儿园托管服务合同范本下载及解读
- 2025年业务接替交接协议书
- 2025年1月浙江省高考地理试卷(含答案)
- 2025年湖南铁道职业技术学院高职单招职业技能测试近5年常考版参考题库含答案解析
- 患者照护用品的应用护理员培训
- DB32-T 4334-2022 薄壳山核桃郁闭园改造技术规程
- 农办主任履行职责工作(2篇)
- 2025年中国维生素C咀嚼片市场供需格局及未来发展趋势报告
- 规则之下方有自由课件-高一上学期行为常规主题班会
- 广东省汕头市金平区2021-2022学年八年级下学期期末英语卷
- 物流行业固废处理方案
- 云南省第二十一届职工职业技能大赛机器人系统运维员竞赛考试题库(含答案)
评论
0/150
提交评论