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

📄 overhead.c

📁 单片机程序代码,经过很详细的测试.呵呵,硬件相关.
💻 C
📖 第 1 页 / 共 4 页
字号:
#include <reg54.h>
#include "rc7860.h"
#include "f2rc7860.h"
#include "se0111.h"
#include "cmd_para_save.h"

unsigned char xdata j_rx[15];
unsigned char xdata j_tx[15];
unsigned char xdata overhead_value;

extern unsigned char f2rc7860_rd(unsigned int f2addr) large reentrant;
extern void f2rc7860_wr(unsigned int f2addr,unsigned char value) large reentrant;
extern void se0111_reg_wr(unsigned char Haddr,unsigned char Laddr,unsigned char value,unsigned char slot);
extern unsigned char se0111_reg_rd(unsigned char Haddr,unsigned char Laddr,unsigned char slot);
extern void SetResRdyTbl(unsigned char prio) large reentrant;
extern unsigned char GetResRdyTbl(unsigned char prio) large reentrant;
extern unsigned char xdata start_flg[4];
extern unsigned char xdata board_type[4][2];	//定义插盘类型数组,第一位表示槽号,第二位表示盘号
extern unsigned long int xdata commandid;
extern unsigned char xdata tx_buf[];
extern unsigned char xdata tx_buf_pointer;
extern bit tx_done;

unsigned char get_overhead_value(struct cmd_para_save *get_overhead){
//C20取开销字节函数
unsigned char xdata boardid;				//盘号
unsigned char xdata portid;					//端口号
unsigned char xdata timeid;					//时隙号
unsigned char xdata outporth;				//Mapper中端口高8位
unsigned char xdata outportl;				//Mapper中端口低8位
unsigned int  xdata overhead_name;			//开销字节名
unsigned char xdata return_value;			//返回值
unsigned char xdata temp_value;

	commandid = 0x00433230;
	boardid = get_overhead -> ohget_board;
	portid = get_overhead -> ohget_port;
	timeid = get_overhead -> ohget_slot;
	overhead_name = get_overhead -> ohget_name;

	if (portid < 22){	
	switch (overhead_name){
	case 0x4A30: if (boardid == 4 & start_flg[0] == 0){				 //J0字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2SohJ0_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2SohJ0_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = SohJ0_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = SohJ0_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4B31: if (boardid == 4 & start_flg[0] == 0){				 //K1字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2SohK1_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2SohK1_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = SohK1_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = SohK1_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4b32: if (boardid == 4 & start_flg[0] == 0){				 //K2字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2SohK2_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2SohK2_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = SohK2_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = SohK2_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x5331: if (boardid == 4 & start_flg[0] == 0){				 //S1字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2SohS1_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2SohS1_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = SohS1_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = SohS1_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4332: if (boardid == 4 & start_flg[0] == 0){				 //C2字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2PohC2_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2PohC2_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = PohC2_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = PohC2_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4731: if (boardid == 4 & start_flg[0] == 0){				 //G1字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2PohG1_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2PohG1_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = PohG1_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = PohG1_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4B33: if (boardid == 4 & start_flg[0] == 0){				 //K3字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2PohK3_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2PohK3_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = PohK3_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = PohK3_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4E31: if (boardid == 4 & start_flg[0] == 0){				 //N1字节光分支盘OTB
					if (portid == 1){                                //光分支7860A口
						overhead_value = f2rc7860_rd(F2PohN1_rx_a);
						return_value = 0;
					}
					else if (portid == 2){                           //光分支7860B口
						overhead_value = f2rc7860_rd(F2PohN1_rx_b);
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else if (boardid == 5){                            //主光盘MCB
				  	if (portid == 1){
						overhead_value = PohN1_rx_a;
						return_value = 0;
					}
					else if (portid == 2){
						overhead_value = PohN1_rx_b;
						return_value = 0;
					}
					else return_value = 2;
				 }
				 else return_value = 2;
				 break;
	case 0x4B34:switch (portid){                                //K4字节 得出Mapper中的支路号
					case 1: outporth=0x04;
	        				outportl=0x2C;
							break;
					case 2: outporth=0x04;
		        			outportl=0x4C;
							break;
					case 3: outporth=0x04;
	        				outportl=0x6C;
							break;
					case 4: outporth=0x04;
		        			outportl=0x8C;
							break;
					case 5: outporth=0x04;
	        				outportl=0xAC;
							break;
					case 6: outporth=0x04;
		        			outportl=0xCC;
							break;
					case 7: outporth=0x04;
		        			outportl=0xEC;
							break;
					case 8: outporth=0x05;
	        				outportl=0x2C;
							break;
					case 9: outporth=0x05;
		        			outportl=0x4C;
							break;
					case 10: outporth=0x05;
	         				 outportl=0x6C;
			 			 	 break;
					case 11: outporth=0x05;
		   			      	 outportl=0x8C;
							 break;
					case 12: outporth=0x05;
	         				 outportl=0xAC;
							 break;
					case 13: outporth=0x05;
						     outportl=0xCC;
				 			 break;
					case 14: outporth=0x05;
	         				outportl=0xEC;
			 				break;
					case 15: outporth=0x06;
		         			outportl=0x2C;
				 			break;
					case 16: outporth=0x06;
	         				outportl=0x4C;
			 				break;
					case 17: outporth=0x06;
		         			outportl=0x6C;
				 			break;
					case 18: outporth=0x06;
	         				outportl=0x8C;
			 				break;
					case 19: outporth=0x06;
		         			outportl=0xAC;
				 			break;
					case 20: outporth=0x06;
	         				outportl=0xCC;
			 				break;
					case 21: outporth=0x06;
					         outportl=0xEC;
							 break;
			    	default: break;
				}
				switch (boardid){                                             
			    	case 1: if (start_flg[1] == 0){
								overhead_value = se0111_reg_rd(outporth,outportl,1);  //2M盘1
					    		return_value = 0;
							}
							else return_value = 2;
							break;
					case 2: if (start_flg[2] == 0){
								overhead_value = se0111_reg_rd(outporth,outportl,2);  //2M盘2
					    		return_value = 0;
							}
							else return_value = 2;
							break;
					case 3: if (start_flg[2] == 0){
								overhead_value = se0111_reg_rd(outporth,outportl,3);  //2M盘3
					    		return_value = 0;
							}
							else return_value = 2;
							break;
					default:return_value = 2;
							break;
				}
				break;
	case 0x5635:switch (portid){                                //V5字节 得出Mapper中的支路号
					case 1: outporth=0x04;//??对应原0035,042B的比特4,3(对应0031)含义可能导致错误
	        				outportl=0x2B;
							break;
					case 2: outporth=0x04;
		        			outportl=0x4B;
							break;
					case 3: outporth=0x04;
	        				outportl=0x6B;
							break;
					case 4: outporth=0x04;
		        			outportl=0x8B;
							break;
					case 5: outporth=0x04;
	        				outportl=0xAB;
							break;
					case 6: outporth=0x04;
		        			outportl=0xCB;
							break;
					case 7: outporth=0x04;
	        				outportl=0xEB;
							break;
					case 8: outporth=0x05;
		        			outportl=0x2B;
							break;
					case 9: outporth=0x05;
	        				outportl=0x4B;
							break;
					case 10: outporth=0x05;
		         			 outportl=0x6B;
				 		 	 break;
					case 11: outporth=0x05;
	   				      	 outportl=0x8B;
							 break;
					case 12: outporth=0x05;
		         			 outportl=0xAB;
							 break;
					case 13: outporth=0x05;
						     outportl=0xCB;
				 			 break;
					case 14: outporth=0x05;
	        	 			outportl=0xEB;

⌨️ 快捷键说明

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