/***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /******* *******/ /******* D H C - 8 S e r i e s 4 0 0 *******/ /******* *******/ /******* F U E L Q U A N T I T Y G A G I N G S Y S T E M *******/ /******* *******/ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /* */ /* Program Name : DHC-8 Fuel Quantity Gaging System (FQGS) */ /* Source File Name : arinc.c */ /* CPC : ARINC Processing */ /* Engineer : Katherine Monroe /Sucheta Saraph */ /* Criticality Level : Level C */ /* Contents : arn_formatter */ /* arn_transmit_arinc_data */ /* arn_hw_init */ /* arn_process_wrap */ /* */ /* Description : This CSC performs arinc data processing. */ /* */ /* */ /* Contents of this document are propriety information, property of: */ /* PARKER HANNIFIN CORPORATION */ /* GULL ELECTRONIC SYSTEMS DIVISION */ /* SMITHTOWN, NEW YORK 11787 */ /* Any attempt to copy or use the contents of this document in any manner */ /* whatsoever without express written consent of the owner is prohibited. */ /***************************************************************************/ /***************************************************************************/ /***************************************************************************/ #pragma EJECT /***************************************************************************/ /* Revision History */ /***************************************************************************/ /* */ /* Date Rev Engineer Description */ /* ------ --- -------- ------------------------------------------------ */ /* */ /***************************************************************************/ #pragma EJECT #pragma DEBUG #pragma LARGE #pragma NOAM #pragma OBJECTEXTEND // #pragma SYMBOLS #define EXTRN extern /* declare all global variables external */ #define MAIN_FILE 0 //#pragma SRC #include "c:\c51\inc\reg51.h" #include "c:\c51\inc\stdlib.h" #include "c:\c51\inc\stdio.h" #include "c:\c51\inc\string.h" #include "asicaddr.h" #include "typedefs.h" #include "defines.h" #include "globals.h" #include "prototyp.h" #include "fai.h" #pragma EJECT extern code uchar MASK_TBL[]; /*************************/ /* Module level literals */ /*************************/ #define DROP_PARITY_MASK 0x7fffffff #define NUMBER_OF_ARINC_MSGS 10 /**************************/ /* Module level variables */ /**************************/ xdata ARINC_MESSAGE_STRUCT_T arn_message_array[NUMBER_OF_ARINC_MSGS]; xdata ulong arn_arinc_tx_byte _at_ 0xd600; xdata ulong arn_arinc_rx_byte _at_ 0xd60c; xdata ulong arn_expected_wrap; xdata uchar arn_wrap_failure; xdata uchar arn_probe_index; #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : arn_hw_init */ /* Description : This unit initializes the ARINC hardware. */ /* */ /* */ /***************************************************************************/ void arn_hw_init(void) { /***********************/ /* Enable transmitter. */ /***********************/ XBYTE [AR_CON_ADDR] = 0x01; } /***************************************************************************/ /* */ /* Unit Name : arn_tx_task */ /* Description : This unit calls the ARINC transmitter with the data to be */ /* transmitted. */ /* */ /***************************************************************************/ void arn_tx_task (void) { arn_transmit_arinc_data (&arn_message_array[0].arn_message, NUMBER_OF_ARINC_MSGS); // transmit built message } /* */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : arn_transmit_arinc_data */ /* Description : This unit transmits 10 messages of ARINC data. Each */ /* message is 32 bits in length. */ /* */ /* Inputs : This unit inputs the address of the first of n number of */ /* 32 bit messages and n the number of messages. Each 32 */ /* bit message should be stored as an unsigned long data */ /* type. The value of n should be a maximum of 5 so that */ /* this unit will execute within a maximum of 25 ms. */ /* */ /***************************************************************************/ void arn_transmit_arinc_data (ulong *transmit_data_message, uchar number_of_messages) { /******************/ /* Local literals */ /******************/ #define MAX_DELAY_CNT 5 /* 5 msec */ /*******************/ /* Local variables */ /*******************/ uchar message_index,delay_cnt; bit transmission_complete; delay_cnt =0; message_index =0; transmission_complete = FALSE; ARN_TRANSMIT_START: while (!transmission_complete) { /************************************/ /* WAIT FOR ARINC TRANSMITTER READY */ /************************************/ while (!(XBYTE [AR_STATUS_ADDR] & 0x1) && (delay_cnt++ < MAX_DELAY_CNT)) bit_delay(1); /* Count 1 millisecond */ /********************************************/ /* If a timeout occurred report a failure */ /********************************************/ ARN_TRANSMIT_TIMEOUT: if (delay_cnt >= MAX_DELAY_CNT) { transmission_complete = SET; /********************************/ /* Report a transmitter failure */ /********************************/ fai_pass_fail_logger(ARN_TX_READY_TEST_ID,FAIL); } /* end if */ else { /***************************************/ /* Any more messages to send ? */ /***************************************/ if (++message_index >= number_of_messages) { arn_expected_wrap = *transmit_data_message & DROP_PARITY_MASK; transmission_complete = SET; } /****************************************/ /* Get next message of ARINC data to be */ /* transmitted and place in transmit */ /* locations. */ /****************************************/ arn_arinc_tx_byte = *transmit_data_message++; delay_cnt =0; /********************************/ /* Report a transmitter pass. */ /********************************/ fai_pass_fail_logger(ARN_TX_READY_TEST_ID,PASS); } /* end else */ } /* end transmission_complete loop */ } /* arn_transmit_arinc_data */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : arn_process_wrap */ /* Description : This unit does a wrap test based on the last message that */ /* was transmitted. The last message transmitted was saved */ /* by arn_transmit_arinc_data. */ /* */ /* */ /* Inputs : arn_expected_wrap */ /* */ /* */ /* */ /***************************************************************************/ void arn_process_wrap(void) { #define RECEIVER_EMPTY 0x8 xdata ulong received_wrap; if (!(XBYTE [AR_STATUS_ADDR] & RECEIVER_EMPTY)) { /********************************************/ /* report a failure nothing in the receiver */ /********************************************/ fai_pass_fail_logger(ARN_WRAP_TEST_ID,FAIL); } else { /*****************************************************/ /* read the received message and drop the parity bit */ /*****************************************************/ received_wrap = (*(ulong xdata *)AR_RX2B0_ADDR) & DROP_PARITY_MASK; /******************************************/ /* Perform a wrap test and report results */ /******************************************/ ARN_WRAP_TEST: if (received_wrap != arn_expected_wrap) { fai_pass_fail_logger(ARN_WRAP_TEST_ID,FAIL); } else { fai_pass_fail_logger(ARN_WRAP_TEST_ID,PASS); } } if (fai_status_reporter (ARINC_FAULT_GROUP) & HARD_FAILURE) /* check for hard failure */ arn_wrap_failure = SET; else arn_wrap_failure = RESET; } #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : arn_formatter */ /* Description : This unit formats the ARINC message to be transmitted. */ /* */ /* */ /* Inputs : arn_wrap_failure */ /* g_own_proc_id */ /* */ /* */ /***************************************************************************/ void arn_formatter(void) { #define LOWER 0 #define UPPER 1 typedef struct { uint label_with_sdi; uint *src_ptr; uint *ssm_to_be_used; } LABELS_T; code LABELS_T RIGHT_MESSAGE_LIST[NUMBER_OF_ARINC_MSGS] = /************************************************************/ /* | | */ /* Byte 0 | Byte 1 | */ /* label | SDI | */ /************************************************************/ /* 0111 0101|xx00 0010|= 7502h = label 256 left lbs 0*/ /* 1111 0101|xx00 0010|= f502h = label 257 right lbs 1*/ /* 1000 1101|xx00 0010|= 8d02h = label 261 left kgs 2*/ /* 0100 1101|xx00 0010|= 4d02h = label 262 right kgs 3*/ /* 1110 0101|xx00 0010|= e502h = label 247 total lbs 4*/ /* 0001 0101|xx00 0010|= 1502h = label 250 total kgs 5*/ /* 0001 0111|xx00 0010|= 1702h = label 350 system status 6*/ /* 1001 0111|xx00 0010|= 9702h = label 351 left TU status 7*/ /* 0101 0111|xx00 0010|= 5702h = label 352 right TU status 8*/ /* 1101 0111|xx00 0010|= d702h = label 353 reserved data 9*/ /************************************************************/ {{0x7502, &g_fuel_qty[OTHERS_QTY_ENTRY].lbs, &g_fuel_qty[OTHERS_QTY_ENTRY].ssm}, {0xf502, &g_fuel_qty[OWN_QTY_ENTRY].lbs, &g_fuel_qty[OWN_QTY_ENTRY].ssm}, {0x8d02, &g_fuel_qty[OTHERS_QTY_ENTRY].kgs, &g_fuel_qty[OTHERS_QTY_ENTRY].ssm}, {0x4d02, &g_fuel_qty[OWN_QTY_ENTRY].kgs , &g_fuel_qty[OWN_QTY_ENTRY].ssm}, {0xe502, &g_own_total_fuel_qty_lbs, &g_own_total_fuel_qty_ssm}, {0x1502, &g_own_total_fuel_qty_kgs , &g_own_total_fuel_qty_ssm}, {0x1702, &g_own_system_status , &g_own_system_status_ssm }, {0x9702, &g_others_tu_status , &g_others_tu_status_ssm ,}, {0x5702, &g_own_tu_status , &g_own_tu_status_ssm , }, {0xd702, &g_own_test_data, &g_own_test_data_ssm, }, }; code LABELS_T LEFT_MESSAGE_LIST[NUMBER_OF_ARINC_MSGS] = /************************************************************/ /* | | */ /* Byte 0 | Byte 1 | */ /* label | SDI | */ /************************************************************/ /* 0111 0101|xx00 0010|= 7501h = label 256 left lbs 0*/ /* 1111 0101|xx00 0010|= f501h = label 257 right lbs 1*/ /* 0011 0010|xx00 0010|= 8d01h = label 114 left kgs 2*/ /* 1011 0010|xx00 0010|= 4d01h = label 115 right kgs 3*/ /* 1110 0101|xx00 0010|= e501h = label 247 total lbs 4*/ /* 0001 0101|xx00 0010|= 1501h = label 250 total kgs 5*/ /* 0001 0111|xx00 0010|= 1701h = label 350 system status 6*/ /* 1001 0111|xx00 0010|= 9701h = label 351 left TU status 7*/ /* 0101 0111|xx00 0010|= 5701h = label 352 right TU status 8*/ /* 1101 0111|xx00 0010|= d701h = label 353 reserved data 9*/ /************************************************************/ {{0x7501, &g_fuel_qty[OWN_QTY_ENTRY].lbs, &g_fuel_qty[OWN_QTY_ENTRY].ssm}, {0xf501, &g_fuel_qty[OTHERS_QTY_ENTRY].lbs, &g_fuel_qty[OTHERS_QTY_ENTRY].ssm}, {0x8d01, &g_fuel_qty[OWN_QTY_ENTRY].kgs, &g_fuel_qty[OWN_QTY_ENTRY].ssm}, {0x4d01, &g_fuel_qty[OTHERS_QTY_ENTRY].kgs , &g_fuel_qty[OTHERS_QTY_ENTRY].ssm}, {0xe501, &g_own_total_fuel_qty_lbs, &g_own_total_fuel_qty_ssm}, {0x1501, &g_own_total_fuel_qty_kgs , &g_own_total_fuel_qty_ssm}, {0x1701, &g_own_system_status , &g_own_system_status_ssm }, {0x9701, &g_own_tu_status , &g_own_tu_status_ssm , }, {0x5701, &g_others_tu_status , &g_others_tu_status_ssm ,}, {0xd701, &g_own_test_data, &g_own_test_data_ssm, }, }; xdata LABELS_T *p_label; xdata uchar index; WORD_BYTE_OVERLAY_T temp_word; /*****************************************/ /* Setup lower words consisting of label */ /* in reverse octal and SDI. */ /*****************************************/ if (g_own_proc_id == LEFT_PROCESSOR) p_label = LEFT_MESSAGE_LIST; else p_label = RIGHT_MESSAGE_LIST; for (index=0; index < NUMBER_OF_ARINC_MSGS; index++) { /*****************************************/ /* Clear the current message. */ /*****************************************/ arn_message_array[index].arn_message= 0l; arn_message_array[index].msg_parts[LOWER].w.word = p_label->label_with_sdi; /*****************************************/ /* Get data to be output. */ /*****************************************/ /*****************************************/ /* If index = 9, put the test data one by*/ /* one for each probe. */ /*****************************************/ if ((NUMBER_OF_ARINC_MSGS -1) == index) { temp_word.w.word = *(p_label->src_ptr+arn_probe_index); g_own_test_data_ssm = SSM_NORMAL_OPERATION ; } else temp_word.w.word = *p_label->src_ptr; /*****************************************/ /* If ARINC wrap failure exists, output */ /* fuel quantity of zero. */ /*****************************************/ if (SET == arn_wrap_failure) { temp_word.w.word = 0x0000; } if ((7 == index) || (8 == index)){ // Two Tank Unit Status messages /*********************************************/ /* Format tank unit status message word. */ /*********************************************/ /*********************************************/ /* Output data's 6 least siginificant */ /* bits are written in the most significant */ /* 6 bits of the lower word of message array.*/ /*********************************************/ if (temp_word.w.word & 0x01) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x04; if (temp_word.w.word & 0x02) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x08; if (temp_word.w.word & 0x04) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x10; if (temp_word.w.word & 0x08) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x20; if (temp_word.w.word & 0x10) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x40; if (temp_word.w.word & 0x20) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x80; temp_word.w.word = temp_word.w.word >> 6; /*********************************************/ /* Remainder of output data is written into */ /* the upper word of the message array. */ /*********************************************/ arn_message_array[index].msg_parts[UPPER].b.hbyte = temp_word.b.lbyte; arn_message_array[index].msg_parts[UPPER].b.lbyte = temp_word.b.hbyte; /*********************************************/ /* Place bit 27 & 28 data in message. */ /*********************************************/ if ((g_own_proc_id == RIGHT_PROCESSOR && index == 8) || (g_own_proc_id == LEFT_PROCESSOR && index == 7)) { if (g_own_stored_tu8_chan) arn_message_array[index].msg_parts[UPPER].b.lbyte |= 0x04; if (g_own_stored_tu9_chan) arn_message_array[index].msg_parts[UPPER].b.lbyte |= 0x08; } if ((g_own_proc_id == RIGHT_PROCESSOR && index == 7) || (g_own_proc_id == LEFT_PROCESSOR && index == 8)) { if (g_others_stored_tu8_chan) arn_message_array[index].msg_parts[UPPER].b.lbyte |= 0x04; if (g_others_stored_tu9_chan) arn_message_array[index].msg_parts[UPPER].b.lbyte |= 0x08; } } else { /*********************************************/ /* Output test data's four address bits in */ /* bits 11 thru 14 in the most significant */ /* byte of the lower word of message array.*/ /*********************************************/ if ((NUMBER_OF_ARINC_MSGS -1) == index) { // Test data message if (arn_probe_index & 0x01) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x04; if (arn_probe_index & 0x02) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x08; if (arn_probe_index & 0x04) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x10; if (arn_probe_index & 0x08) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x20; arn_probe_index++; arn_probe_index%=NUMBER_OF_PROBES + 1; } /*********************************************/ /* Output data's 2 least siginificant */ /* bits are written in the most significant */ /* 2 bits of the lower word of message array.*/ /*********************************************/ if (temp_word.w.word & 0x01) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x40; if (temp_word.w.word & 0x02) arn_message_array[index].msg_parts[LOWER].b.lbyte |= 0x80; temp_word.w.word = temp_word.w.word >> 2; /*********************************************/ /* Remainder of output data is written into */ /* the upper word of the message array. */ /*********************************************/ arn_message_array[index].msg_parts[UPPER].b.hbyte = temp_word.b.lbyte; arn_message_array[index].msg_parts[UPPER].b.lbyte = temp_word.b.hbyte; } /*****************************************/ /* Write SSM bits into bits 31 & 30. */ /*****************************************/ temp_word.w.word = *p_label->ssm_to_be_used; /*****************************************/ /* If ARINC wrap failure exists, output */ /* SSM of failure warning. */ /*****************************************/ if (SET == arn_wrap_failure) { temp_word.w.word = SSM_FAILURE_WARNING ; } arn_message_array[index].msg_parts[UPPER].b.hbyte |= temp_word.b.lbyte; arn_message_array[index].msg_parts[UPPER].b.lbyte |= temp_word.b.hbyte; p_label++; } }