key.c

来自「此源码是本人买的株洲开发板全套例程」· C语言 代码 · 共 89 行

C
89
字号
#include	"DSP28_Device.h"
void	delay(Uint32	num);
void	KeyAck(void);

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(2000);
					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	delay(Uint32  num)
		{
			volatile  Uint32  i;
			for (i=0;i<num;i++) { ; }				
		}	

void	KeyFunction(Uint16	Temp)
		{
			switch(Temp)
				{
					case  K1: {
								KeyAck();
							  }
							  break;
					case  K2: {
								KeyAck();
							  }
							  break;
					case  K3: {
								KeyAck();
							  }
							  break;
					case  K4: {
								KeyAck();
							  }
							  break;
					case  K5: {
								KeyAck();
							  }
							  break;
					case  K6: {
								KeyAck();	
							  }
							  break;
					case  K7: {
								KeyAck();
							  }
							  break;
					case  K8: {
								KeyAck();
							  }	 		 
							  break; 			  
					default:  
							  break;
			}				  				  			  				   			  			  			   		
		}
void	KeyAck(void)
		{
			LedReg = 0x00;
			delay(500000);
			LedReg = 0xFF;			
		}				
//================================= end ===========================

⌨️ 快捷键说明

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