/***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /******* *******/ /******* 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 : dsc.c */ /* CPC : Discrete Processing */ /* Engineer : Katherine Monroe */ /* Criticality Level : Level C */ /* */ /* Contents : dsc_read_config */ /* dsc_process_discretes */ /* dsc_output_discrete_data */ /* dsc_sw_init */ /* dsc_hw_init */ /* */ /* Description : This CPC performs discrete 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 */ /* ------ --- -------- ------------------------------------------------ */ /* */ /* 072795 A K Monroe Pr 020 Leave discrete fault light on after any */ /* failure has occurred. */ /* */ /***************************************************************************/ #pragma EJECT #pragma DEBUG #pragma LARGE #pragma NOAM #pragma OBJECTEXTEND #pragma SYMBOLS #define EXTRN extern /* declare all global variables external */ #define MAIN_FILE 0 /* used to declare sbits in globals.h to external */ //#pragma SRC #include "c:\c51\inc\reg51.h" #include "c:\c51\inc\absacc.h" #include #include "asicaddr.h" #include "defines.h" #include "typedefs.h" #pragma LISTINCLUDE #include "globals.h" #include "prototyp.h" #include "fai.h" /**************************/ /* Module level variables */ /**************************/ uchar xdata dsc_port_a_image ; /***************************************************************************/ /* */ /* Unit Name : dsc_hw_init */ /* Description : This unit initializes the discrete output port. */ /* */ /* Inputs : None */ /* */ /* Outputs : None */ /* */ /* Called by : main startup procedure */ /* */ /* Calls : None */ /* */ /***************************************************************************/ void dsc_hw_init(void) { #define INITIAL_PORT_A_VALUE 0xF1; XBYTE[PORT_A_ADDR] = INITIAL_PORT_A_VALUE; /* Initially valve has to be closed */ } /***************************************************************************/ /* */ /* Unit Name : dsc_sw_init */ /* Description : This unit initializes the discrete data. */ /* */ /* Inputs : None */ /* */ /* Outputs : g_sys_test_req */ /* */ /* Called by : main startup procedure */ /* */ /* Calls : None */ /* */ /***************************************************************************/ void dsc_sw_init(void) { g_sys_test_req = RESET; dsc_port_a_image = SET; } #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : dsc_read_config */ /* Description : This unit reads the configuration register and sets the */ /* processor id and lbs/kgs based on the value read. */ /* */ /* Inputs : None */ /* */ /* Outputs : g_own_proc_id */ /* g_own_lbs_kgs_mode */ /* */ /* Called by : main startup procedure */ /* */ /* Calls : None */ /* */ /***************************************************************************/ void dsc_read_config(void) { #define PROC_ID_LOCATION 0x80 /* Config reg bit 7 is left/right id */ #define LBS_KGS_LOCATION 0x01 /* Config reg bit 0 is lbs/kgs id */ #define LBS_KGS_PARITY_BIT 0x04 /* Config reg bit 2 is parity bit */ #define TEST_DATA_LOCATIONS 0x07 /* Config reg bits 0-2 */ xdata uchar parity_check_data; /*********************************************************/ /* Read in configuration - processor ID. */ /*********************************************************/ g_own_proc_id = (XBYTE[CONFIG_ADDR] & PROC_ID_LOCATION ); /*********************************************************/ /* Read in configuration - LBS/KGS mode & verify odd */ /* parity using bits 0, 1 and 2. If the parity test */ /* fails, default to pounds. */ /*********************************************************/ parity_check_data = XBYTE[CONFIG_ADDR] & TEST_DATA_LOCATIONS ; if ((parity_check_data == 0x07) | (parity_check_data == 0x02)) { g_own_lbs_kgs_mode = (XBYTE[CONFIG_ADDR] & LBS_KGS_LOCATION ); g_own_sys_lbs_kgs = ~g_own_lbs_kgs_mode; fai_pass_fail_logger(DSC_PARITY_TEST_ID,PASS); } else { g_own_lbs_kgs_mode = RESET; // default to lbs g_own_sys_lbs_kgs = SET; // default to lbs fai_pass_fail_logger(DSC_PARITY_TEST_ID,FAIL); } } /* end dsc_read_config */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : dsc_process_discretes */ /* Description : This unit reads in and debounces the discrete input data. */ /* The status of the door switch and system test switch */ /* is constantly updated. */ /* */ /* */ /* Inputs : None */ /* */ /* Outputs : g_own_refuel_door */ /* g_sys_test_req */ /* */ /* Called by : main executive procedure */ /* */ /* Calls : None */ /* */ /***************************************************************************/ void dsc_process_discretes (void) { #define TEST_SWITCH_LOCATION 0x01 /* Config reg bit 0 is id */ #define DOOR_SWITCH_LOCATION 0x02 /* Config reg bit 1 is id */ #define FILL_VALVE_POWER_OUT_LOCATION 0x04 /* Config reg bit 2 is id */ #define FILL_VALVE_POWER_IN_LOCATION 0x10 /* Config reg bit 4 is id */ static xdata uchar last_port_c_image; static xdata uchar prev_port_c_image; xdata uchar port_c_image; /*********************************************************/ /* Read in entire port and compare to last read. Update */ /* data on change of state. */ /*********************************************************/ port_c_image = XBYTE[PORT_C_ADDR ]; if (port_c_image != prev_port_c_image) { prev_port_c_image = port_c_image; } else { /*********************************************************/ /* Update door switch and system test switch status */ /*********************************************************/ g_own_refuel_door = (port_c_image & DOOR_SWITCH_LOCATION); if (!(port_c_image & TEST_SWITCH_LOCATION) && (last_port_c_image & TEST_SWITCH_LOCATION)) g_sys_test_req = !(port_c_image & TEST_SWITCH_LOCATION); if (dsc_port_a_image & TURN_REFUEL_VALVE_OFF) { // IF BIT IS SET 6-27-97 if (RESET == g_valve_cmd ) { /***************************************/ /* Valve has been commanded to close. */ /***************************************/ if (((port_c_image & FILL_VALVE_POWER_IN_LOCATION) != 0x0) && ((port_c_image & FILL_VALVE_POWER_OUT_LOCATION) == 0x0)) /***************************************/ /* No failure exists. */ /***************************************/ fai_pass_fail_logger(REF_VALVE_CONT_TEST_ID,PASS); else // 6-27-97 deleted /*********************************************************** if ( ( (port_c_image & FILL_VALVE_POWER_IN_LOCATION) == 0x0) && ( (port_c_image & FILL_VALVE_POWER_OUT_LOCATION) == 0x0) ) // ************************************* No failure exists. ************************************* fai_pass_fail_logger(REF_VALVE_WRAP_TEST_ID,PASS) else *****************************************************/ /***************************************/ /* Log failure. */ /***************************************/ fai_pass_fail_logger(REF_VALVE_CONT_TEST_ID,FAIL); } } else { /***************************************/ /* Valve has been commanded to open. */ /***************************************/ if (port_c_image & FILL_VALVE_POWER_OUT_LOCATION) /****************************/ /* Power out is not zero. */ /****************************/ fai_pass_fail_logger(REF_VALVE_WRAP_TEST_ID,PASS); // 6-27-97 else /***************************/ /* Power out is zero. */ /***************************/ fai_pass_fail_logger(REF_VALVE_WRAP_TEST_ID,FAIL); // 6-27-97 } last_port_c_image = port_c_image; } } /* end dsc_process_discretes */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : dsc_output_discrete_data */ /* Description : This unit reads in discrete data and saves in it's */ /* designated location. */ /* */ /* Inputs : g_valve_cmd */ /* g_current_failure */ /* */ /* Outputs : None */ /* */ /* Called by : main executive procedure */ /* */ /* Calls : None */ /* */ /***************************************************************************/ void dsc_output_discrete_data (void) { static bit system_fail_toggle; static xdata uchar keep_light_on; /***************************************************/ /* If refuel is enabled then turn on fuel valves */ /***************************************************/ if (SET == g_valve_cmd ) dsc_port_a_image &=TURN_REFUEL_VALVE_ON; // CLEAR BIT 6-27-97 else dsc_port_a_image |=TURN_REFUEL_VALVE_OFF; // SET BIT 6-27-97 /***************************************************/ /***************************************************/ /* If a current failure has occured then set the */ /* discrete to on. Else reset it */ /***************************************************/ /***************************************************/ if (g_own_proc_id == RIGHT_PROCESSOR) { if (g_own_tu == SET || g_own_fqc == SET) dsc_port_a_image |=SYSTEM_FAULT_ENABLE; else dsc_port_a_image &= SYSTEM_FAULT_DISABLE ; } else { if (g_others_tu == SET || g_others_fqc == SET) dsc_port_a_image |=SYSTEM_FAULT_ENABLE; else dsc_port_a_image &= SYSTEM_FAULT_DISABLE ; } XBYTE[PORT_A_ADDR ] = dsc_port_a_image; } /* end dsc_output_discrete_data */