mykey.c

来自「USB for TMS320C5402」· C语言 代码 · 共 105 行

C
105
字号
#include	"MyKey.h"

extern	int	f,ms,mybuf1;
extern unsigned char Timer_Count;



Uint16	ScanKey(void)
		{
			Uint16	temp,temp1;
			Uint16  flag = 0;
			while(flag==0)
				{
					temp = KeyReg;
					temp = temp & 0xff;
					while(temp==0xff)
						{
							temp = KeyReg;			
							temp = temp & 0xff;
		       			 }
		    		Delay(5000);
					temp = KeyReg;			
					temp = temp & 0xff;
					temp1 = temp;
					if (temp == 0xff) flag = 0;
					else  flag = 1;		    
		        }
			temp = KeyReg;
			temp = temp & 0xff;
		    while( temp != 0xff)
		    	{
					temp = KeyReg;
					temp = temp & 0xff;
		    	}
		    return(temp1);		    			
		}


//void	KEY_Delay(Uint32  num)
//		{
//			volatile  Uint32  i;
//			for (i=0;i<num;i++) { ; }				
//		}	

void	KeyFunction(Uint16	Temp)
		{
			switch(Temp)
				{
					case  K1: {
								KeyPress();
							  }
							  break;
					case  K2: {
								KeyPress();
							  }
							  break;
					case  K3: {
								KeyPress();
							  }
							  break;
					case  K4: {
								KeyPress();
							  }
							  break;
					case  K5: {
								KeyPress();
							  }
							  break;
					case  K6: {
								KeyPress6();	
							  }
							  break;
					case  K7: {
								//KeyPress();
								asm("  SSBX  XF ");
							  }
							  break;
					case  K8: {
								//KeyPress8();
								asm("  RSBX  XF ");	
							  }
					default:  
							  break;
			}				  				  			  				   			  			  			   		
		}

void	KeyPress(void)
		{
		    ms=0;	
       		while(ms<500/f);     //LED_flash
       		ms=0;
       		asm("  RSBX  XF ");       
       		while(ms<500/f);
       		ms=0;
       		asm("  SSBX  XF ");       
		}
		
void KeyPress6(void)
		{
		    //mybuf1=0x32;// ++;
		    //TimeCount=char(mybuf1);
		    //LCD_WriteStr(6,3,mybuf1);    
		}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?