⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 key.c

📁 包括DSP实验测试程序、实验示例、应用程序以及经典的DSP的C程序和汇编程序库
💻 C
字号:
#include	"cpu_reg.h"
extern	int	f,ms;

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	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: {
								KeyPress();	
							  }
							  break;
					case  K7: {
								KeyPress();
							  }
							  break;
					case  K8: {
								KeyPress();	
							  }
					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 ");       
		}

⌨️ 快捷键说明

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