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

📄 drive.c

📁 凌阳机的模组spi串口红外传感器的接口电路及c语言的程序!没有密码!
💻 C
字号:
#define	P_IOA_Data 				(volatile unsigned int *)0x7000   
#define P_IOA_Buffer 			(volatile unsigned int *)0x7001
#define P_IOA_Dir 				(volatile unsigned int *)0x7002
#define P_IOA_Attrib 			(volatile unsigned int *)0x7003
#define P_IOA_Latch 			(volatile unsigned int *)0x7004
//............................................
#define P_IOB_Data				(volatile unsigned int *)0x7005  
#define P_IOB_Buffer			(volatile unsigned int *)0x7006   
#define P_IOB_Dir				(volatile unsigned int *)0x7007   
#define P_IOB_Attrib			(volatile unsigned int *)0x7008   
//............................................
#define P_FeedBack				(volatile unsigned int *)0x7009   
#define P_TimerA_Data			(volatile unsigned int *)0x700A   
#define P_TimerA_Ctrl			(volatile unsigned int *)0x700B   
#define P_TimerB_Data			(volatile unsigned int *)0x700C   
#define P_TimerB_Ctrl			(volatile unsigned int *)0x700D   
#define P_TimeBase_Setup		(volatile unsigned int *)0x700E   
#define P_TimeBase_Clear		(volatile unsigned int *)0x700F 	
#define P_INT_Ctrl				(volatile unsigned int *)0x7010   
#define P_INT_Clear				(volatile unsigned int *)0x7011   
#define P_INT_Mask				(volatile unsigned int *)0x702D   
#define P_Watchdog_Clear		(volatile unsigned int *)0x7012   
#define P_SystemClock			(volatile unsigned int *)0x7013   
#define P_UART_Command1			(volatile unsigned int *)0x7021 	
#define P_UART_Command2			(volatile unsigned int *)0x7022 	
#define P_UART_Data				(volatile unsigned int *)0x7023  	
#define	P_UART_BaudScalarLow	(volatile unsigned int *)0x7024	
#define	P_UART_BaudScalarHigh	(volatile unsigned int *)0x7025 
#define P_SystemClock			(volatile unsigned int *)0x7013 

extern PlayFlag,uiSumFlag;
extern uiFlag[16],uiSum,uiClock,iTest;
//========================================================================================
//函数名称 :    void F_IOSET()
//描述     :   IO初始发
//入口参数 :   无
//出口     :   无
//========================================================================================
void F_IOSET()
{
	*P_IOB_Dir=0x0300;
	*P_IOB_Attrib=0x0300;
	*P_IOB_Data=0x0304;
	*P_IOA_Dir=0x0000;
	*P_IOA_Attrib=0x0000;
	*P_IOA_Data=0x0000;
}
//========================================================================================
//函数名称 :    void finddata()
//描述     :   数据帧接收
//入口参数 :   无
//出口     :   无
//========================================================================================
void finddata()
{
iTest=*P_IOA_Data&0x8000;
    switch(iTest)
  {
               case 0x8000:
                if(uiSum!=0x5555)
                 {
                   uiSum++;
                   switch(uiSum)
                  {
  					case 16:
  					uiFlag[0]=0x0001;
  				    
  					break;
  					case 15:
  					uiFlag[1]=0x0002;
  					break;
  					case 14:
 					 uiFlag[2]=0x0004;
  					break;
 					 case 13:
  					uiFlag[3]=0x0008;
  					break;
  					case 12:
  					uiFlag[4]=0x0010;
  					break;
  					case 11:
					  uiFlag[5]=0x0020;
  					break;
 					case 10:
  					uiFlag[6]=0x0040;
 					 break;
  					case 9:
  					uiFlag[7]=0x0080;
 					case 8:
  					uiFlag[8]=0x0100;
  					
  					break;
  					case 7:
  					uiFlag[9]=0x0200;
  					break;
  					case 6:
 					 uiFlag[10]=0x0400;
  					break;
 					 case 5:
  					uiFlag[11]=0x0800;
  					break;
  					case 4:
  					uiFlag[12]=0x1000;
  					break;
  					case 3:
					  uiFlag[13]=0x2000;
  					break;
 					case 2:
  					uiFlag[14]=0x4000;
 					 break;
  					case 1:
  					uiFlag[15]=0x8000;  					
   			        if(uiSumFlag==0) uiSum=0;
 					 break; 
  					default:
  					break;
  					}
  				}
  break;
  case 0:
  if(uiSum!=0x5555)
  {
  uiSum++;
  switch(uiSum)
  {
  case 16:
  uiFlag[0]=0;

  break;
  case 15:
  uiFlag[1]=0;
  break;
  case 14:
  uiFlag[2]=0;
  break;
  case 13:
  uiFlag[3]=0;
  break;
  case 12:
  uiFlag[4]=0;
  break;
  case 11:
  uiFlag[5]=0;
  break;
  case 10:
  uiFlag[6]=0;
  break;
  case 9:
  uiFlag[7]=0;
  case 8:
  uiFlag[8]=0;
  break;
  case 7:
  uiFlag[9]=0;
  break;
  case 6:
  uiFlag[10]=0;
  break;
  case 5:
  uiFlag[11]=0;
  break;
  case 4:
  uiFlag[12]=0;
  break;
  case 3:
  uiFlag[13]=0;
  break;
  case 2:
  uiFlag[14]=0;
  break;
  case 1:
  uiFlag[15]=0;
   uiSumFlag=1;
  break;  
  default:
  break;
  }
   break;
  default:
  break;  
  }

  }
    if(uiSum==16) uiSum=0xaaaa;
    
    }

⌨️ 快捷键说明

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