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

📄 int.c

📁 SDU的字库
💻 C
字号:

/*********************************************************************************************************
** 函数名称: ex_int0()
** 功能描述: 外部中断0中断服务程序.主要提供收码功能。
********************************************************************************************************/
/*
void ex_int0() interrupt 0
{
  uchar error_c = 0;
  uchar error_d = 0;
   IT0 = 1;
  EX0 = 0;
  IE0 = 0;
  S_487_IN = 1;
  S_487_CTRL = 0;

  if( watch_pre_code() )
  {
   while(~S_487_IN && error_c++ < 255);
   read_code();
   while( S_487_IN && error_d++ < 255);
 
  }
  else
  {
   ;
  }
  IT0 = 1;
  EX0 = 1;
  IE0 = 0;
 }
 */
/*********************************************************************************************************
** 函数名称: timer0()
** 功能描述: 定时timer0中断服务程序,主要提供时钟功能。
********************************************************************************************************/
void timer0() interrupt 1
 {
 	v_Get1302( cur_time_cach );
	if( disappear_sw )	          // disappear_sw == 1 则允许显示
	{
	 disappear_time++;
	 if( disappear_time>1000 )
	 {
	  disappear_time = 0;
	  disappear_sw = 0;
	 }
    }
	if (sheding_sw)				
	{
	 sheding_time++;
	 if(sheding_time>1000)
	 {sheding_time=0;
	  sheding_sw =0;
	  menu_code=5;
	  }
	} 
	TH0=-50000/256;    //@24M, define clock is 10ms			
    TL0=-50000%256;
    
 } 

 /*********************************************************************************************************
 **函数名称:serial()
 **功能描述:串口中断服务程序,主要提供收码功能(TN026)。
 *********************************************************************************************************/
 
 void  serial() interrupt 4
   {
//     unsigned char n;
	 TI=0;
	 ES=0;
	 if((RI==1)&&(tn026==1))
     {	  	 	  
	      RI=0;
	      sbuf_buffer=SBUF;
          if(nummber==0)
		  {
			   check_sum=0;
		       if(sbuf_buffer==0x55)
			   {
		            code_data[nummber]=sbuf_buffer;
			        nummber++;
		       }
		  }
		  else if(nummber==1)
		  {
		       if(sbuf_buffer==0x33)
			   {
		            code_data[nummber]=sbuf_buffer;
			        nummber++;
		       }
			   else
			   {
			        nummber=0;
			   }
		  }
		  else if(nummber==2)
		  {
		       if(sbuf_buffer==0x77)
			   {
//		            code_data[nummber]=sbuf_buffer;
			        nummber++;
		       }
			   else
			   {
			        nummber=0;
			   }
		  }
		  else if(nummber==13)
		  {
		  	 code_data[3]=sbuf_buffer;
			 nummber++;
//			 check_sum=check_sum+sbuf_buffer;
		  }
		  else if(nummber==14)
		  {
		      code_data[4]=sbuf_buffer;
			   nummber++;
//			   check_sum=check_sum+sbuf_buffer;
			   
		  }
		  else if(nummber==15)
		  {
		      code_data[5]=sbuf_buffer;
			   nummber++;
//			   check_sum=check_sum+sbuf_buffer;
		  }
		  else if(nummber==17)
		  {
		      code_data[6]=sbuf_buffer;
			   nummber++;
//			   check_sum=check_sum+sbuf_buffer;
		  }
		  else if(nummber==18)
		  {
		      code_data[7]=sbuf_buffer;
			   nummber++;
//			   check_sum=check_sum+sbuf_buffer;
		  }
		
		  else 
		  {
			   check_sum=check_sum+sbuf_buffer;
			   nummber++;
			   if(nummber>=22)
			   {
			        nummber=0;
//					if(check_sum==sbuf_buffer)
					f_bit=1;
			   }
		  }	  
     } 
        
	 if((RI==1)&&(floor_def==0))
	      {
               	
				if(Flag_Effective_Data==0)
			           {
                           
						   h.Serial_Communication_Data_Buffer[Communication_Data_Counter]=SBUF;
				           Communication_Data_Counter++;
				 	       if(Communication_Data_Counter>=20) 
				               {  
                                   Communication_Data_Counter=0;
                                   if(  (h.Serial_Communication_Data_Buffer[0]==0xf0)
								      &&(h.Serial_Communication_Data_Buffer[1]==0xf1)
                                      &&(h.Serial_Communication_Data_Buffer[2]==0xf2) 
								      &&(h.Serial_Communication_Data_Buffer[3]==0xf3)
                                      &&(h.Serial_Communication_Data_Buffer[4]==0xf4)
								      &&(h.Serial_Communication_Data_Buffer[5]==0xf5)
                                      &&(h.Serial_Communication_Data_Buffer[6]==0xf6)
								      &&(h.Serial_Communication_Data_Buffer[7]==0xf7)
                                      &&(h.Serial_Communication_Data_Buffer[8]==0xf8)
								      &&(h.Serial_Communication_Data_Buffer[9]==0xf9)
//									  &&(h.Serial_Communication_Data_Buffer[18]==0x02)
//									  &&(h.Serial_Communication_Data_Buffer[13]==0x06)
									  )
                                          {
                                             Flag_Effective_Data=1;
											 Communication_Data_Counter=0;

											flag_first=1;
									//		SUM_COMU=0;
									//		for(n=10;n<20;n++)
									//		{	
									//		SUM_COMU=SUM_COMU+h.Serial_Communication_Data_Buffer[n];
									//		}
                                          }
									else
									{													 
											 Flag_Effective_Data=0;
								    		 Communication_Data_Counter=0;
											 flag_first=1;
									}										
                                }
                        }
                   else
			            {	
							  
							  h.Serial_Communication_Data_Buffer[Communication_Data_Counter]=SBUF;
//							  SUM_COMU=SUM_COMU+h.Serial_Communication_Data_Buffer[Communication_Data_Counter];
							  Communication_Data_Counter++;

							 if((Communication_Data_Counter==65)&&(flag_first==1))
									{
									 which_one=h.Serial_Communication_Data_Buffer[0];
									 flag_first=0;
									if((which_one%2)==1)							  
													{
														IIC_Data_Addr_L=0x00;
									                	IIC_Data_Addr_H=which_one/2;
													}
										else
													{
														IIC_Data_Addr_L=0x80;
									                	IIC_Data_Addr_H=which_one/2-1;
													}
								Data_Length=16;
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L,(h.Serial_Communication_Data_Buffer+1),Data_Length);
								Delay_ms(2);
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x10,(h.Serial_Communication_Data_Buffer+17),Data_Length);
								Delay_ms(2);
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x20,(h.Serial_Communication_Data_Buffer+33),Data_Length);
								Delay_ms(2);
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x30,(h.Serial_Communication_Data_Buffer+49),Data_Length);
								Delay_ms(2);					
                                Flag_Effective_Data=1;
                                Communication_Data_Counter=1;    
									}
							else if((Communication_Data_Counter==66)&&(flag_first==0))
							           {											  

										flag_first=1;
										if((which_one%2)==1)							  
													{
														IIC_Data_Addr_L=0x40;
									                	IIC_Data_Addr_H=which_one/2;
													}
										else
													{
														IIC_Data_Addr_L=0xc0;
									                	IIC_Data_Addr_H=which_one/2-1;
													}
										Data_Length=16;
										 
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L,h.Serial_Communication_Data_Buffer+1,Data_Length);	
								Delay_ms(2);
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x10,(h.Serial_Communication_Data_Buffer+17),Data_Length);
								Delay_ms(2);
								ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x20,(h.Serial_Communication_Data_Buffer+33),Data_Length);
								Delay_ms(2);
								if(ISendStr(IIC_Data_Addr_H,IIC_Data_Addr_L+0x30,(h.Serial_Communication_Data_Buffer+49),Data_Length))
								dis_ok();
								Flag_Effective_Data=0;
                                Communication_Data_Counter=0;
												
							}
						}
					RI=0;			
					}
//	loop:;
	ES=1;
	}
	/* 
if((RI==1)&&(floor_def==0))
	         {
//				  Check_first=0;
              if(Flag_Effective_Data==0)
			           {
                           h.Serial_Communication_Data_Buffer[Communication_Data_Counter]=SBUF;
				           Communication_Data_Counter++;
				 	       if(Communication_Data_Counter>=20) //65
				               {  
                                   Communication_Data_Counter=0;
                                   if(  (h.Serial_Communication_Data_Buffer[0]==0xf0)
								      &&(h.Serial_Communication_Data_Buffer[1]==0xf1)
                                      &&(h.Serial_Communication_Data_Buffer[2]==0xf2) 
								      &&(h.Serial_Communication_Data_Buffer[3]==0xf3)
                                      &&(h.Serial_Communication_Data_Buffer[4]==0xf4)
								      &&(h.Serial_Communication_Data_Buffer[5]==0xf5)
                                      &&(h.Serial_Communication_Data_Buffer[6]==0xf6)
								      &&(h.Serial_Communication_Data_Buffer[7]==0xf7)
                                      &&(h.Serial_Communication_Data_Buffer[8]==0xf8)
								      &&(h.Serial_Communication_Data_Buffer[9]==0xf9)
									  &&(h.Serial_Communication_Data_Buffer[18]==0x02)
									  &&(h.Serial_Communication_Data_Buffer[13]==0x06)
									  )
                                          {
                                             Flag_Effective_Data=1;
//										     Flag_Serial_Communication_Over=0;
											 Communication_Data_Counter=0;
//											 Display_Busy2();
											flag_first=1;
											SUM_COMU=0;
											for(i=10;i<20;i++)
											{	
												SUM_COMU=SUM_COMU+h.Serial_Communication_Data_Buffer[i];
											}
                                          }
									else
									{
                                             Flag_Effective_Data=0;
//										     Flag_Serial_Communication_Over=0;
											 Communication_Data_Counter=0;
//											 Display_Busy2();
											flag_first=1;
									}										
                                }
                        }
                   else
			            {							  
                                    h.Serial_Communication_Data_Buffer[Communication_Data_Counter]=SBUF;
								    SUM_COMU=SUM_COMU+h.Serial_Communication_Data_Buffer[Communication_Data_Counter];
									Communication_Data_Counter++;
//									Display_Busy3();
									 if((Communication_Data_Counter==65)&&(flag_first==1))
									      {
											  which_one=h.Serial_Communication_Data_Buffer[0];

											  		flag_first=0;
													if((which_one%2)==1)
													{
														IIC_Data_Addr_L=0x00;
									                	IIC_Data_Addr_H=which_one/2;
													}
													else
													{
														IIC_Data_Addr_L=0x80;
									                	IIC_Data_Addr_H=which_one/2-1;
													}
															Data_Length=64;
															Display_Busy(TABLE_LED_Display1[2*which_one-1]);
														    Write_FloorDefine();
 //                                                           display_ok();														
                                                    	Flag_Effective_Data=1;
                                                    	Communication_Data_Counter=1;
												}
										else if((Communication_Data_Counter==66)&&(flag_first==0))
										{
											  		flag_first=1;
													if((which_one%2)==1)
													{
														IIC_Data_Addr_L=0x40;
									                	IIC_Data_Addr_H=which_one/2;
													}
													else
													{
														IIC_Data_Addr_L=0xc0;
									                	IIC_Data_Addr_H=which_one/2-1;
													}
															Data_Length=64;
															Display_Busy(TABLE_LED_Display1[(2*which_one)]);
														    Write_FloorDefine();
 //                                                           display_ok();														
                                                    	Flag_Effective_Data=0;
                                                    	Communication_Data_Counter=0;
					if(h.Serial_Communication_Data_Buffer[65]!=(SUM_COMU-h.Serial_Communication_Data_Buffer[65]))
						{						
								Display_Busy(0X6D);
								goto loop;
								}
							}			

							}
					    RI=0;				
								}													
														 	      
              ES=1;
			  loop:;
    }
//----------------------------------------------------

⌨️ 快捷键说明

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