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

📄 p_hunter.c

📁 这是监视器行业常见的键盘与球机通讯协议的C语言源代码
💻 C
字号:

/*

history;
  V 1.00 build 2003.05.24 by zh

*/

#include <REG54.H>
#include <INTRINS.H>
#include "protocol.h"
#include "kernel.h"
#include "config.h"

unsigned char data rr = 0;
unsigned char data recv_code;

unsigned char data word4,word6,word7,word7,word8,word9,wordx;
unsigned char bdata word5;
sbit ext_fg = word5^0;

unsigned char data pp = 0; // for seq point
bit start_set_fg = 0;
bit manu_need_stop = 0;


extern bit do_set_addon(unsigned char no)
{
	no = no;
	return 0;
}


extern bit do_call_addon(unsigned char no)
{
	no = no;
	return 0;
}

extern void init_serial(void)
{
	PCON = 0x00;SCON = 0x50;
	TH2 = 0xff; RCAP2H = 0xff;
#ifdef FOCS_40M
	TL2 = 0x7e; RCAP2L = 0x7e;
#else // for 22.1184
	TL2 = 0xb8; RCAP2L = 0xb8;
#endif
	T2CON = 0x34;
}

void serial_int(void) interrupt 4 using 1
{ 
    ES = 0;

	if (_testbit_(RI))
	{								
		recv_code = SBUF;
		rr++;
		switch (rr)
		{
		case 1:
			if (recv_code != 0xf2) rr = 0;     
			break;
		case 2:
			if (recv_code != 0xf1) rr = 0;
			break;
        case 3:
            if (recv_code != 0x11) rr=0;
            break;
        case 4:
            if (recv_code == 0xfe)
			{
			    if (_testbit_(zoom_need_stop))
			 		zoom_stop_fg = 1;
			    else if (_testbit_(focus_need_stop)) 
					focu_stop_fg = 1;
				else if (_testbit_(manu_need_stop))
				{
		        	seq[12] = 0;
			    	cont_fg = 1;
				}
			}
			else if (recv_code != id) rr = 0;
            break; 
         case 5:
            //word4 = recv_code;
            //switch (word4);
			switch (recv_code)
            {
		    case 0xb7:
              	iris_close_fg = 1;    
                break;
            case 0xb6:
                iris_open_fg = 1;    
                break;
            case 0xb9:             
                zoom_wide_fg = 1;   
                zoom_need_stop = 1;
			    break;
            case 0xb8:             
                zoom_tele_fg = 1;
                zoom_need_stop = 1;
                break;
            case 0xba:            
                focu_far_fg = 1;
                focus_need_stop = 1;
			    break;
            case 0xbb:           
                focu_near_fg = 1;
                focus_need_stop = 1;
				break;
            case 0xb0:     
				cont_fg = 1;
			    run_swing2_fg = 0;
				manu_need_stop = 1;
			    seq[12] = 8;
			    seq[13] = 0;
			    seq[14] = 0x40;
			    break;
            case 0xb1:    
			    cont_fg = 1;
			    run_swing2_fg = 0;
				manu_need_stop = 1;
			    seq[12] = 16;
			    seq[13] = 0;
			    seq[14] = 0x40;
			    break;
			case 0xae:     
				cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
                seq[12] = 4;
                seq[13] = 0x40;
                seq[14] = 0;
                break;
            case 0xaf:     
                cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
                seq[12] = 2;
                seq[13] = 0x40;
                seq[14] = 0;
                break;
			case 0xb2:     
			    cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
				seq[12] = 12;
                seq[13] = 0x40;
                seq[14] = 0x40;
                break;
            case 0xb3:   
			    cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
				seq[12] = 20;
                seq[13] = 0x40;
                seq[14] = 0x40;
                break;
            case 0xb4:   
			    cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
				seq[12] = 10;
                seq[13] = 0x40;
                seq[14] = 0x40;
                break;
            case 0xb5:    
                cont_fg = 1;
                run_swing2_fg = 0;
				manu_need_stop = 1;
				seq[12] = 18;
                seq[13] = 0x40;
                seq[14] = 0x40;
                break;
            case 0xcc:    
                set_pre_fg = 1;
                run_swing_fg=0;
				run_seq2_fg=0;
				seq[15] = 0x01;
				break;
           case 0xcd:    
                call_pre_fg = 1;
                run_swing_fg=0;
				run_seq2_fg=0;
                seq[15] = 0x01;
				break;
           case 0xce:   
                set_pre_fg = 1;
                run_swing_fg=0;
				run_seq2_fg=0;
				seq[15] = 0x02;
				break;
		   case 0xcf:   
                call_pre_fg = 1;
                run_swing_fg=0;
				run_seq2_fg=0;
                seq[15] = 0x02;
				break;
		   case 0xc1:    
		        power_on_fg = 1;
                break;
		   case 0xc0:   
		        power_off_fg = 1;
                break;
           case 0xca:
		        set_pre_fg =1;
				run_swing2_fg = 0;
                run_swing_fg = 0;
				run_seq2_fg = 0;
                seq[15] = 51;
		        break;
           case 0xcb:
		        run_seq2_fg = 1;
			    break;
           case 0xc9:
		        run_seq2_fg = 0;
		        run_swing_fg = 1;
				seq[17] = 51;
				seq[18] = 52;
                break;
           case 0xc8:
		        set_pre_fg = 1;
				run_swing2_fg = 0;
		        run_swing_fg = 0;
				run_seq2_fg = 0;
				seq[15] = 52;
                break;	
		   }  //end case5
        default:
		    rr = 0;
		    break;
		}   //end switch
    }        //end if
    ES = 1;
}

⌨️ 快捷键说明

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