/***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /******* *******/ /******* 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 : pdm.c */ /* CPC : PDM/FSK Data Processing */ /* Engineer : Katherine Monroe /Sucheta Saraph */ /* Criticality Level : Level C */ /* Contents : pdm_sw_init */ /* pdm_hw_init */ /* pdm_init_repeaters */ /* */ /* pdm_talk_to_repeaters */ /* pdm_process_rx_data */ /* pdm_process_discrete_data */ /* pdm_invoke_wrap */ /* pdm_wrap_handler */ /* pdm_replace_char */ /* */ /* pdm_format_normal_displays */ /* pdm_setup_normal_upper_display */ /* pdm_setup_normal_middle_display */ /* pdm_setup_normal_lower_display */ /* */ /* pdm_format_test_displays */ /* pdm_exit_test_mode */ /* */ /* */ /* */ /* Description : This CSC performs PDM/FSK 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 "nvm.h" #include "fai.h" #include "asicaddr.h" #include "typedefs.h" #include "defines.h" #include "globals.h" #include "pdm.h" #include "prototyp.h" #pragma EJECT extern code uchar MASK_TBL[]; /*************************/ /* Module level literals */ /*************************/ #define TRANSMITTER_READY 0x1 /* 8251 */ #define SPACE ' ' #define STATUS_ENTRY0 0 /* Status register */ #define STATUS_ENTRY1 1 /* Discrete Data Register */ #define ZERO 0 #define TEN 10 #define RX_BUFFER_SET 0x4F /* OK for both status and discrete data register */ #define STORED_FAULTS 0 #define CURRENT_FAULTS 1 #define OFF 0 /* selector switch is OFF */ #define ON 1 /* selector switch is ON */ #define TOTAL 0 /* used to indicate that lower display qty is total qty */ #define SELECTED 1 /* used to indicate that lower display qty is selected qty */ #define SELECT_TOTAL 2 /* used to indicate that you may be in preselect refuel/defuel mode*/ /***************************************/ /* Timeouts based on tx rate of 192 ms */ /***************************************/ #define ONE_SECOND 5 #define TWO_SECONDS 10 #define FOUR_SECONDS 20 #define FIVE_SECONDS 25 #define SIX_SECONDS 30 #define TEN_SECONDS 50 #define THIRTY_SECONDS 150 #define MAX_STUCK_TIME 1250 // 4 minutes = 192ms * 1250 = 240000ms #define MAX_INC_DEC_STUCK_TIME 625 // 4 minutes = (192ms * 1250)/2 = 120000ms // Since switch in incremented (decremented) // every other cycle, count must be set for // 2 minutes and result will be 4 minutes /***************************************/ /* Command bytes sent to repeater. */ /***************************************/ #define UPPER_DISPLAY_READ 0xC3 /* 1100 0011 */ #define MIDDLE_DISPLAY_READ 0xC7 /* 1100 0111 */ #define LOWER_DISPLAY_READ 0xCB /* 1100 1011 */ #define UPPER_DISPLAY_WRITE 0xE3 /* 1110 0011 */ #define MIDDLE_DISPLAY_WRITE 0xE7 /* 1110 0111 */ #define LOWER_DISPLAY_WRITE 0xEB /* 1110 1011 */ #define CHECKERBOARD 0x7F #define INVERSE_CHECKERBOARD 0x86 // UDC address #6 code char LBS[] = {"LB"}; code char KGS[] = {"KG"}; code char UDC1_LBS[] = {0x81}; code char UDC2_LBS[] = {0x82}; code char UDC1_KGS[] = {0x84}; code char UDC2_KGS[] = {0x85}; /**************************/ /* Module level variables */ /**************************/ xdata uchar pdm_wrap_save_buff [3]; xdata uchar pdm_upper_transmitted_data [8]; xdata uchar pdm_middle_transmitted_data [8]; xdata uchar pdm_lower_transmitted_data [8]; xdata uchar pdm_uart1_wr_index, /* write index into the global transmit buffer */ pdm_test_mode, /* set indicated system in test mode. */ pdm_display_timer, /* counts time for each display change. */ pdm_test_display_case, /* defines current display case in test mode */ pdm_fail_count, /* counter used to alternate FAIL display. */ pdm_upper_display_data_index, pdm_lower_display_data_index, pdm_middle_display_data_index, pdm_wrap_index, /* identifies which display to perform wrap test on */ pdm_stored_rx_index, /* stored fault list index. */ pdm_refuel_wait_ctr, /* counter used to wait 4 secs to enable auto refuel*/ pdm_defuel_wait_ctr, /* counter used to wait 4 secs to enable auto defuel*/ pdm_auto_refuel_flag, /* indicates if you have entered auto refuel for the first time */ pdm_auto_defuel_flag, /* indicates if you have entered auto defuel for the first time */ pdm_refuel_defuel_mode_status, /* indicates refuel/defuel selector switch position */ pdm_abort_timer, /* timer used to show "ABORT" for 5 sec on lower display */ pdm_tank_failure, /* indicates whether switch or tank has failed or not */ pdm_switch_failure, /* indicates whether any switch has failed or not */ pdm_left_tank_failure, /* indicates whether left tank has failed or not */ pdm_right_tank_failure; /* indicates whether right tank has failed or not */ xdata uchar pdm_initialize_repeater, /* flag used to indicate the repeater needs */ /* to be initialized */ pdm_initialize_ctr; /* counter used to send initialization data in two batches */ xdata uchar pdm_transmit_data; PDM_OUT_DATA_T xdata *p_pdm_fault; bit pdm_wrap_enable_flag , pdm_otherside_first_fault_read, pdm_myside_first_fault_read ; extern code uint FAI_FAULT_CODES[]; #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_sw_init */ /* Description : This unit initializes the PDM/FSK Processing CSC variables*/ /* */ /* Inputs : None */ /* Outputs : None */ /* Called by : main (background executive) */ /* Calls : pdm_read_faults */ /* */ /***************************************************************************/ void pdm_sw_init(void) { xdata uchar found, lru; /***********************************************/ /* Initialize read pointer of buffer to 0. */ /***********************************************/ pdm_uart1_wr_index = 0; /***********************************************/ /* Set flag to tell talk_to_repeater_s that the*/ /* repeater must be initialized. */ /***********************************************/ pdm_initialize_repeater = SET; /***********************************************/ /* Clear all indexes and counters. */ /***********************************************/ pdm_wrap_index = RESET; pdm_fail_count = RESET; pdm_test_mode=RESET; pdm_display_timer=RESET; pdm_test_display_case=RESET; pdm_refuel_wait_ctr= pdm_defuel_wait_ctr= RESET; pdm_auto_refuel_flag = pdm_auto_defuel_flag = RESET; g_pdm_third_row = TOTAL; pdm_abort_timer = RESET; g_pdm_abort_variable = RESET; pdm_tank_failure = RESET; pdm_switch_failure = RESET; g_own_sys_ref_panel = RESET; /* ???????? */ pdm_left_tank_failure = RESET; pdm_right_tank_failure = RESET; pdm_initialize_ctr = RESET; /***********************************************/ /* Put stored faults on arinc, if any */ /***********************************************/ pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; found = RESET; while (!found) { p_pdm_fault = pdm_read_faults (STORED_FAULTS); if (p_pdm_fault != NULL) { lru = p_pdm_fault->lru_id; if ((g_own_proc_id == RIGHT_PROCESSOR) && (pdm_otherside_first_fault_read == RESET)) { switch (p_pdm_fault->lru_id) { case 11: g_own_stored_tu1_chan = SET; break; case 13: g_own_stored_tu2_chan = SET; break; case 15: g_own_stored_tu3_chan = SET; break; case 17: g_own_stored_tu4_chan = SET; break; case 19: g_own_stored_tu5_chan = SET; break; case 28: g_own_stored_tu6_chan = SET; break; case 30: g_own_stored_tu7_chan = SET; break; case 32: g_own_stored_tu8_chan = SET; break; case 34: g_own_stored_tu9_chan = SET; break; case 21: g_own_stored_tu6_chan = SET; g_own_stored_tu7_chan = SET; break; case 23: g_own_stored_tu8_chan = SET; g_own_stored_tu9_chan = SET; break; default: break; }/*end switch*/ }/*end RIGHT PROCESSOR */ if ((g_own_proc_id == LEFT_PROCESSOR) && (pdm_otherside_first_fault_read == RESET)) { switch (p_pdm_fault->lru_id) { case 11: g_own_stored_tu1_chan = SET; break; case 13: g_own_stored_tu2_chan = SET; break; case 15: g_own_stored_tu3_chan = SET; break; case 17: g_own_stored_tu4_chan = SET; break; case 19: g_own_stored_tu5_chan = SET; break; case 28: g_own_stored_tu6_chan = SET; break; case 30: g_own_stored_tu7_chan = SET; break; case 32: g_own_stored_tu8_chan = SET; break; case 34: g_own_stored_tu9_chan = SET; break; case 21: g_own_stored_tu6_chan = SET; g_own_stored_tu7_chan = SET; break; case 23: g_own_stored_tu8_chan = SET; g_own_stored_tu9_chan = SET; break; default: break; }/*end switch*/ }/*end LEFT PROCESSOR */ }/* end if */ else found = SET; }/*end while */ } /*pdm_sw_init*/ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_hw_init */ /* Description : This unit initializes UART1. */ /* Inputs : None */ /* Outputs : None */ /* Called by : main (background executive) */ /* Calls : None */ /***************************************************************************/ void pdm_hw_init(void) { xdata uchar port_copy, ctrl_copy; /***********************************************/ /* P1.1 and P1.3 must be set to zero to enable */ /* PDM/FSK. */ /***********************************************/ P1 &= 0xF5; /******************************************/ /* Set BAUD2 to 4800 baud using 16X clock */ /******************************************/ XBYTE [BAUD2_ADDR] = 243; /***********************************************/ /* To guarantee that the device is in Command */ /* instruction format before the reset command */ /* is issued, execute the worst case init */ /* sequence (sync mode with two sync chars) */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x00; XBYTE [UART1_CONT_ADDR ] = 0x00; XBYTE [UART1_CONT_ADDR ] = 0x00; XBYTE [UART1_CONT_ADDR ] = 0x40; /***********************************************/ /* Set mode instruction definition */ /* D901 = 5Eh */ /* bits 0 & 1 = 01 baud rate of 16x */ /* bits 2 & 3 = 11 character length of 8 bits */ /* bit 4 = 1 parity enabled */ /* bit 5 = 0 odd parity */ /* bit 6 & 7 = 10 one stop bit */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x5E; /***********************************************/ /* Set command instruction definition */ /* D901 = 04h */ /* bit 0 = 0 disable transmit */ /* bit 1 = 0 Data terminal ready */ /* bit 2 = 1 receive enabled */ /* bit 3 = 0 send break character */ /* bit 4 = 0 error reset */ /* bit 5 = 0 request to send */ /* bit 6 = 0 internal reset */ /* bit 7 = 0 enter hunt mode */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x04; /***********************************************/ /* To guarantee that the device is in Command */ /* instruction format before the reset command */ /* is issued, execute the worst case init */ /* sequence (sync mode with two sync chars) */ /***********************************************/ XBYTE [UART2_CONT_ADDR ] = 0x00; XBYTE [UART2_CONT_ADDR ] = 0x00; XBYTE [UART2_CONT_ADDR ] = 0x00; XBYTE [UART2_CONT_ADDR ] = 0x40; /***********************************************/ /* Set mode instruction definition */ /* D901 = 5Eh */ /* bits 0 & 1 = 01 baud rate of 16x */ /* bits 2 & 3 = 11 character length of 8 bits */ /* bit 4 = 1 parity enabled */ /* bit 5 = 0 odd parity */ /* bit 6 & 7 = 10 one stop bit */ /***********************************************/ XBYTE [UART2_CONT_ADDR ] = 0x5E; /***********************************************/ /* Set command instruction definition */ /* D901 = 04h */ /* bit 0 = 0 disable transmit */ /* bit 1 = 0 Data terminal ready */ /* bit 2 = 1 receive enabled */ /* bit 3 = 0 send break character */ /* bit 4 = 0 error reset */ /* bit 5 = 0 request to send */ /* bit 6 = 0 internal reset */ /* bit 7 = 0 enter hunt mode */ /***********************************************/ XBYTE [UART2_CONT_ADDR ] = 0x04; } /* pdm_hw_init1 */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_init_repeaters */ /* Description : This unit sets up commands to initialize the repeater. */ /* Inputs : None */ /* Outputs : g_uart1_tx_buff */ /* g_own_sys_ref_panel */ /* Called by : main (background executive) */ /* : pdm_talk_to_repeaters */ /* Calls : None */ /* */ /***************************************************************************/ void pdm_init_repeaters(void) { code uchar DISPLAY_INIT_LBS_DATA1[] = {0xE2, /* bit 3 & 2 = 00 top control word register */ 0x80, /* bit 2 - 0 = 000 100% brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ 0xE6, /* bit 3 & 2 = 01 middle control word register */ 0x80, /* bit 2 - 0 = 000 100%brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ 0xEA, /* bit 3 & 2 = 10 bottom control word register */ 0x80, /* bit 2 - 0 = 010 100%brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ 0xE0, /* upper display */ 0x01, /* UDC address register 1 */ 0xE1, /* Write to UDC RAM */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* l */ 0x00, /* */ 0x00, /* */ 0xE0, /* upper display */ 0x02, /* UDC address register 2 */ 0xE1, /* Write to UDC RAM */ 0x10, /* */ 0x10, /* */ 0x1C, /* */ 0x12, /* */ 0x1C, /* b */ 0x00, /* */ 0x00, /* */ 0xE4, /* middle display */ 0x01, /* UDC address register 1 */ 0xE5, /* Write to UDC RAM */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* l */ 0x00, /* */ 0x00, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ code uchar DISPLAY_INIT_LBS_DATA2[] = {0xE4, /* middle display */ 0x02, /* UDC address register 2 */ 0xE5, /* Write to UDC RAM */ 0x10, /* */ 0x10, /* */ 0x1C, /* */ 0x12, /* */ 0x1C, /* b */ 0x00, /* */ 0x00, /* */ 0xE8, /* lower display */ 0x01, /* UDC address register 1 */ 0xE9, /* Write to UDC RAM */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* */ 0x01, /* l */ 0x00, /* */ 0x00, /* */ 0xE8, /* lower display */ 0x02, /* UDC address register 2 */ 0xE9, /* Write to UDC RAM */ 0x10, /* */ 0x10, /* */ 0x1C, /* */ 0x12, /* */ 0x1C, /* b */ 0x00, /* */ 0x00, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ code uchar DISPLAY_INIT_LBS_DATA3[] = {0xE0, /* upper display */ 0x06, /* UDC address register 6 */ 0xE1, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xE4, /* middle display */ 0x06, /* UDC address register 6 */ 0xE5, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xE8, /* lower display */ 0x06, /* UDC address register 6 */ 0xE9, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ code uchar DISPLAY_INIT_KGS_DATA1[] = {0xE2, /* bit 3 & 2 = 00 top control word register */ 0x80, /* bit 2 - 0 = 000 100% brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ 0xE6, /* bit 3 & 2 = 01 middle control word register */ 0x80, /* bit 2 - 0 = 000 100%brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ 0xEA, /* bit 3 & 2 = 10 bottom control word register */ 0x80, /* bit 2 - 0 = 010 100%brightness */ /* bit 3 = 0 no flash */ /* bit 4 = 0 no blink */ /* bit 6 & 5 = 00 no self test */ /* bit 7 = 1 clear Character and Flash RAM*/ /* UDC initialization. !!! Do not use address 3*/ 0xE0, /* upper display */ 0x04, /* UDC address register 4 */ 0xE1, /* Write to UDC RAM */ 0x04, /* */ 0x04, /* */ 0x05, /* */ 0x06, /* */ 0x05, /* k */ 0x00, /* */ 0x00, /* */ 0xE0, /* upper display */ 0x05, /* UDC address register 5 */ 0xE1, /* Write to UDC RAM */ 0x00, /* */ 0x00, /* */ 0x0C, /* */ 0x12, /* */ 0x0E, /* g */ 0x02, /* */ 0x0C, /* */ 0xE4, /* middle display */ 0x04, /* UDC address register 4 */ 0xE5, /* Write to UDC RAM */ 0x04, /* */ 0x04, /* */ 0x05, /* */ 0x06, /* */ 0x05, /* k */ 0x00, /* */ 0x00, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ code uchar DISPLAY_INIT_KGS_DATA2[] = {0xE4, /* middle display */ 0x05, /* UDC address register 5 */ 0xE5, /* Write to UDC RAM */ 0x00, /* */ 0x00, /* */ 0x0C, /* */ 0x12, /* */ 0x0E, /* g */ 0x02, /* */ 0x0C, /* */ 0xE8, /* lower display */ 0x04, /* UDC address register 4 */ 0xE9, /* Write to UDC RAM */ 0x04, /* */ 0x04, /* */ 0x05, /* */ 0x06, /* */ 0x05, /* k */ 0x00, /* */ 0x00, /* */ 0xE8, /* lower display */ 0x05, /* UDC address register 5 */ 0xE9, /* Write to UDC RAM */ 0x00, /* */ 0x00, /* */ 0x0C, /* */ 0x12, /* */ 0x0E, /* g */ 0x02, /* */ 0x0C, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ code uchar DISPLAY_INIT_KGS_DATA3[] = {0xE0, /* upper display */ 0x06, /* UDC address register 6 */ 0xE1, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xE4, /* middle display */ 0x06, /* UDC address register 6 */ 0xE5, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xE8, /* lower display */ 0x06, /* UDC address register 6 */ 0xE9, /* Write to UDC RAM */ 0x15, /* */ 0x0A, /* */ 0x15, /* inverse checkboard */ 0x0A, /* */ 0x15, /* */ 0x0A, /* */ 0x15, /* */ 0xEF, /* bit 3 & 2 = 11 Status register */ 0x40, /* set the INIT bit (bit 6) */ 0x7f}; /* discrete data register, all pins input */ /**************************************************/ /* Initialize the Repeater Indicator Displays */ /* by sending out a command byte followed by */ /* a control word. Set the INIT bit to 1 */ /* to indicate initialization was performed. */ /* Send initialization data in 3 batches */ /* depending upon the initialization counter. */ /**************************************************/ if (g_own_lbs_kgs_mode) { if (pdm_initialize_ctr == RESET) { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_KGS_DATA1,sizeof(DISPLAY_INIT_KGS_DATA1)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_KGS_DATA1); } else if (pdm_initialize_ctr == 1) { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_KGS_DATA2,sizeof(DISPLAY_INIT_KGS_DATA2)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_KGS_DATA2); } else { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_KGS_DATA3,sizeof(DISPLAY_INIT_KGS_DATA3)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_KGS_DATA3); } } else { if (pdm_initialize_ctr == RESET) { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_LBS_DATA1,sizeof(DISPLAY_INIT_LBS_DATA1)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_LBS_DATA1); } else if (pdm_initialize_ctr == 1) { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_LBS_DATA2,sizeof(DISPLAY_INIT_LBS_DATA2)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_LBS_DATA2); } else { memcpy(&g_uart1_tx_buff,&DISPLAY_INIT_LBS_DATA3,sizeof(DISPLAY_INIT_LBS_DATA3)); pdm_uart1_wr_index+=sizeof(DISPLAY_INIT_LBS_DATA3); } } /**************************************************/ /* Reset all indexes and counters. */ /**************************************************/ pdm_wrap_index = RESET; pdm_fail_count = RESET; pdm_test_mode = RESET; pdm_display_timer = RESET; pdm_test_display_case= RESET; pdm_refuel_wait_ctr= pdm_defuel_wait_ctr= RESET; pdm_auto_refuel_flag = pdm_auto_defuel_flag = RESET; g_pdm_third_row = TOTAL; pdm_abort_timer = RESET; g_pdm_abort_variable = RESET; pdm_tank_failure = RESET; pdm_switch_failure = RESET; g_own_sys_ref_panel = RESET; /* ???????? */ pdm_left_tank_failure = RESET; pdm_right_tank_failure = RESET; } /* pdm_init_repeaters */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_talk_to_repeaters */ /* Description : This unit controls repeater communications. */ /* Inputs : g_own_refuel_door, g_own_proc_id */ /* Outputs : g_uart1_tx_buff */ /* : g_uart1_rx_buff */ /* : g_uart1_tx_index */ /* : g_uart1_rx_index */ /* : g_selected_qty */ /* : g_current_failure */ /* Called by : main (background executive) */ /* Calls : pdm_wrap_handler */ /* : pdm_init_repeaters */ /* : pdm_process_rx_data */ /* : pdm_format_normal_displays */ /* : pdm_format_test_displays */ /* : pdm_replace_char */ /* */ /***************************************************************************/ void pdm_talk_to_repeaters(void) { #define STATUS_REQUEST 0xCC #define CLEAR_MYSIDE 1 #define CLEAR_OTHERSIDE 2 static xdata uchar last_door_status; static xdata uchar closed_cnt; static xdata uchar setup_to_clear; static xdata uchar clear_status; xdata uchar found; if (RIGHT_PROCESSOR == g_own_proc_id) { /***********************************************/ /* If wrap is enabled then invoke the wrap */ /* handler. */ /***********************************************/ if (pdm_wrap_enable_flag) pdm_wrap_handler(); /***********************************************/ /* Clear index used to write into tx buffer. */ /***********************************************/ pdm_uart1_wr_index = RESET; /***********************************************/ /* Clear transmit buffer. */ /***********************************************/ memset(&g_uart1_tx_buff, RESET, sizeof(g_uart1_tx_buff)); /*************************************************/ /* If Repeater indicator door has transitioned */ /* from closed to open, stop transmitting data */ /* for three cycles, initialize the repeater and */ /* then resume normal transmission of data. */ /*************************************************/ if ((g_own_refuel_door == DOOR_OPEN)) { if (last_door_status == DOOR_CLOSED) { if (closed_cnt++ == 3) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; closed_cnt=RESET; last_door_status = DOOR_OPEN; pdm_initialize_repeater = SET; pdm_initialize_ctr = RESET; pdm_transmit_data = SET; } else { pdm_transmit_data = RESET; } } /* end last_door_status = DOOR_CLOSED */ else { /*******************************************/ /* Powerup condition. Door has always been*/ /* open. */ /*******************************************/ pdm_transmit_data = SET; last_door_status = DOOR_OPEN; } } /* end g_own_refuel_door = DOOR_OPEN */ else { /*******************************************/ /* Setup for closed to open transition. */ /* Always transmit PDM data. */ /*******************************************/ last_door_status = DOOR_CLOSED; pdm_transmit_data = SET; } if (pdm_transmit_data == SET) { /***********************************************/ /* If status flag indicates repeater needs to */ /* be initialized then call function to perform*/ /* initialization otherwise process rx data. */ /***********************************************/ if (pdm_initialize_repeater) pdm_init_repeaters(); else pdm_process_rx_data(); /***********************************************/ /* If status flag indicates repeater was not */ /* just initialized, call function to format */ /* display data in normal or test format. */ /***********************************************/ if (!pdm_initialize_repeater) { if (pdm_test_mode) pdm_format_test_displays(); else pdm_format_normal_displays(); } pdm_initialize_ctr++; if (pdm_initialize_ctr == 3) { pdm_initialize_repeater = RESET; pdm_initialize_ctr = RESET; } /***********************************************/ /* Replace all zero's with the letter O. */ /***********************************************/ pdm_replace_char(); /***********************************************/ /* Save upper and lower display data in */ /* transmit buffers for wrap test. */ /***********************************************/ memcpy(&pdm_upper_transmitted_data, &g_uart1_tx_buff[pdm_upper_display_data_index], sizeof(pdm_upper_transmitted_data)); memcpy(&pdm_middle_transmitted_data, &g_uart1_tx_buff[pdm_middle_display_data_index], sizeof(pdm_middle_transmitted_data)); memcpy(&pdm_lower_transmitted_data, &g_uart1_tx_buff[pdm_lower_display_data_index], sizeof(pdm_lower_transmitted_data)); /***********************************************/ /* Request status data. */ /***********************************************/ g_uart1_tx_buff [pdm_uart1_wr_index++] = STATUS_REQUEST; g_uart1_tx_buff [pdm_uart1_wr_index] = ETX; /***********************************************/ /* Reset transmit index and receive index. */ /***********************************************/ g_uart1_tx_index = RESET; g_uart1_rx_index = RESET; /***********************************************/ /* Clear receive buffer. */ /***********************************************/ memset(&g_uart1_rx_buff, RX_BUFFER_SET, sizeof(g_uart1_rx_buff)); /***********************************************/ /* Set command instruction definition to enable*/ /* the transmit interrupt. D901 = 05h */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x05; } } else { /***********************************************/ /* LEFT SIDE PROCESSING ONLY */ /***********************************************/ /***********************************************/ /* If a current fault exists then setup so that*/ /* the system fault light will not blink. */ /***********************************************/ p_pdm_fault = fai_fault_output(MY_SIDE, CURRENT_FAULTS, RESET_LIST); if (p_pdm_fault != NULL) { g_current_failure = SET; } else { g_current_failure = RESET; g_others_fqc = RESET; } /***********************************************/ /* If a interprocessor indicates clear faults, */ /* reset current fail status and fault counts. */ /***********************************************/ if (SET == g_others_clear_flts) { g_current_failure = RESET; g_myside_current_failure = RESET; setup_to_clear = SET; // pr 019 clear_status = CLEAR_MYSIDE; // pr 019 } /******************************************/ /* Clear nonvolatile RAM in segments for */ /* both sides. Pr 019*/ /******************************************/ if (SET == setup_to_clear) { /***********************************************/ /* Determine current side to clear then switch */ /* to otherside and clear flag when finished */ /* clearing both sides. */ /***********************************************/ g_own_tu_status &= 0x0000; //Clear the tu status word for left side. g_own_tu_status1 &= 0x00; g_own_system_status &= 0x0FE00; //Clear fault bits in system status. g_set_tu_bit = RESET; switch (clear_status ) { case CLEAR_MYSIDE : /******************************************/ /* Clear nonvolatile RAM for this side. */ /******************************************/ if (RESET == (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_MAIN_FAULT_GROUP))) { clear_status = CLEAR_OTHERSIDE; fai_kill_fault_list(NVM_MAIN_FAULT_GROUP); } break; case CLEAR_OTHERSIDE : /********************************************/ /* Clear nonvolatile RAM for the other side.*/ /********************************************/ if (RESET == (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_IPC_FAULT_GROUP))) { fai_kill_fault_list(NVM_IPC_FAULT_GROUP); /********************************/ /* Both sides have been cleared.*/ /********************************/ setup_to_clear = RESET; } break; default: setup_to_clear = RESET; break; } // end switch } // end if setup to clear if (g_current_failure) { /*************************************************/ /* Repeat until you get left fqc fault or end of */ /* list. */ /*************************************************/ pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; found = RESET; while (!found) { p_pdm_fault = pdm_read_faults (CURRENT_FAULTS); if (p_pdm_fault != NULL) { /*********************************************************/ /* Check for fqc failure to set fqc bit in system status.*/ /* Check for left side only. */ /*********************************************************/ if (!found) { if ((p_pdm_fault->lru_id == 1 || p_pdm_fault->lru_id == 2) && (p_pdm_fault->error_code != 33) && (pdm_otherside_first_fault_read == RESET)) { g_others_fqc = SET; found = SET; } else { g_others_fqc = RESET; } } } else { if (pdm_otherside_first_fault_read == SET) { found = SET; g_others_fqc = RESET; } } } } } // Left side only } /* pdm_talk_to_repeaters */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_process_rx_data */ /* Description : This unit processes the received data. */ /* Inputs : g_uart1_rx_index */ /* : g_uart1_rx_buff */ /* : g_uart1_error_flag */ /* : g_own_refuel_door */ /* : g_refuel_in_prog, g_defuel_in_prog */ /* : g_pdm_fuel_qty */ /* Outputs : g_uart1_error_flag, g_uart1_rx_buff */ /* : g_own_abort_refuel, g_own_abort_defuel */ /* : g_selected_qty */ /* Called by : pdm_talk_to_repeaters */ /* Calls : fai_pass_fail_logger */ /* : pdm_init_repeaters */ /* : pdm_process_discrete_data */ /* */ /***************************************************************************/ void pdm_process_rx_data(void) { #define NO_HW_RESET 0x40 #define PARITY_OR_FRAME_ERROR 0xA0 #define TEST_RESET_SELECTED 0x03 #define TWO_ENTRIES 2 static bit test_on; static xdata uint stuck_test_count, stuck_reset_count; /***********************************************/ /* Is received data is less than two bytes or */ /* is the uart error flag set ? */ /***********************************************/ PDM_RECEIVER_TEST: if ((g_uart1_rx_index != TWO_ENTRIES) || (g_uart1_error_flag)) { // 5/24/95 if (g_uart1_rx_index != TWO_ENTRIES) { // 5/24/95 <2 /*****************************************/ /* Log UART1 receive error. No data was */ /* received. Only log error if repeater */ /* door is open. */ /*****************************************/ if (g_own_refuel_door == DOOR_OPEN) fai_pass_fail_logger (REPEATER_COMM_STATUS_TEST_ID,FAIL); } else { /*****************************************/ /* Log UART1 receive error. Command */ /* status contained parity, overrun or */ /* framing errors. */ /*****************************************/ if (g_own_refuel_door == DOOR_OPEN) fai_pass_fail_logger (REPEATER_PARITY_FRAME_TEST_ID,FAIL); /* ?????? */ } g_uart1_error_flag = RESET; /*************************************************/ /* Clear out receive buffer to prevent erroneous */ /* switch byte decode. */ /*************************************************/ g_uart1_rx_buff[0] = g_uart1_rx_buff[1] = RX_BUFFER_SET; } else { fai_pass_fail_logger (REPEATER_COMM_STATUS_TEST_ID,PASS); fai_pass_fail_logger (REPEATER_PARITY_FRAME_TEST_ID,PASS); /***************************************************/ /* If parity or framing errors, log an error. */ /***************************************************/ if (PARITY_OR_FRAME_ERROR & (g_uart1_rx_buff [STATUS_ENTRY0])) fai_pass_fail_logger (REPEATER_PARITY_TEST_ID,FAIL); else fai_pass_fail_logger (REPEATER_PARITY_TEST_ID,PASS); /***************************************************/ /* If status word indicates HW reset has not */ /* occurred then process received status data. */ /***************************************************/ if ((g_uart1_rx_buff [STATUS_ENTRY0]) & NO_HW_RESET) { fai_pass_fail_logger (REPEATER_INIT_FLAG_TEST_ID,PASS); /***********************************************/ /* process discrete data first */ /***********************************************/ pdm_process_discrete_data(); /***********************************************/ /* TEST or RESET switch selected */ /***********************************************/ switch (TEST_RESET_SELECTED & (~g_uart1_rx_buff [STATUS_ENTRY0])) { case 0: /***********************************************/ /* No switch selected, so reset stuck switch */ /* counts */ /***********************************************/ stuck_test_count = RESET; stuck_reset_count = RESET; fai_pass_fail_logger(RPTR_RESET_TEST_SWITCH_STUCK_ID,PASS); /*************************************************/ /* Clear failure since both reset and test */ /* switch are not both enabled at the same time. */ /*************************************************/ fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_INVALID_ID,PASS); test_on = RESET; /* indicate that test switch not enabled */ break; case 1: /*************************************************/ /* reset switch has been selected. */ /* If left/right auto refuel/defuel in progress */ /* abort it. */ /*************************************************/ if (g_refuel_in_prog || g_others_refuel_in_prog) { g_own_abort_refuel = SET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; g_pdm_abort_variable = SET; } if (g_defuel_in_prog || g_others_defuel_in_prog) { g_own_abort_defuel = SET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; g_pdm_abort_variable = SET; } /***********************************************/ /* reset stuck test count and report invalid */ /* state pass */ /***********************************************/ stuck_test_count = RESET; fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_INVALID_ID,PASS); /***********************************************/ /* check for stuck reset switch */ /***********************************************/ if (++stuck_reset_count == MAX_STUCK_TIME) { fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_STUCK_ID,FAIL); /******************************************/ /* Reset count so that fault will be */ /* reported every 4 minutes. */ /******************************************/ stuck_reset_count = RESET; } /******************************************/ /* If in test mode, jump to CLEAR?? */ /* only if test display case = 2 or 3 */ /******************************************/ if (pdm_test_mode && ((pdm_test_display_case == 2) || (pdm_test_display_case == 3)) ) { pdm_test_display_case = 3; pdm_display_timer = 0; p_pdm_fault = NULL; } test_on = RESET; /* indicate that test switch not enabled */ break; case 2: /***************************************************/ /* Test switch selected. */ /* Enter test mode only upon seeing an edge. */ /***************************************************/ if (!test_on) { /**********************************************/ /* Enter test mode only if not in auto refuel */ /* or auto defuel */ /**********************************************/ if ((RESET == g_refuel_in_prog) && (RESET == g_defuel_in_prog) && (RESET == g_pdm_abort_variable) && (RESET == g_others_refuel_in_prog) && (RESET == g_others_defuel_in_prog)) { pdm_test_mode = SET; test_on = SET; } } /***********************************************/ /* clear stuck reset count and report invalid */ /* state pass */ /***********************************************/ stuck_reset_count = RESET; fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_INVALID_ID,PASS); /***********************************************/ /* check for stuck test switch */ /***********************************************/ if (++stuck_test_count == MAX_STUCK_TIME) { fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_STUCK_ID,FAIL); /******************************************/ /* Reset count so that fault will be */ /* reported every 4 minutes. */ /******************************************/ stuck_test_count = RESET; } break; case 3: /***********************************************/ /* Log failure since both reset and test */ /* switch are both enabled at the same time. */ /***********************************************/ fai_pass_fail_logger (RPTR_RESET_TEST_SWITCH_INVALID_ID,FAIL); break; default: break; }/* end switch */ } else { /************************************************/ /* HW reset of repeater has occurred, setup to */ /* re-initialize the repeater and ignore rest */ /* of the status data. */ /************************************************/ HW_RESET: pdm_init_repeaters(); pdm_initialize_repeater = SET; pdm_initialize_ctr = RESET; fai_pass_fail_logger (REPEATER_INIT_FLAG_TEST_ID,FAIL); } } /* if then else */ }/* pdm_process_rx_data */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_process_discrete_data */ /* Description : This unit processes the discrete data. */ /* Inputs : g_uart1_rx_buff */ /* : g_refuel_in_prog, g_defuel_in_prog */ /* : g_pdm_fuel_qty */ /* Outputs : g_selected_qty */ /* : g_own_abort_refuel, g_own_abort_defuel */ /* : g_valve_cmd */ /* Called by : pdm_process_rx_data */ /* Calls : fai_pass_fail_logger */ /* */ /***************************************************************************/ void pdm_process_discrete_data(void) { #define REFUEL_DEFUEL_SWITCH_SELECTED 0X0F /***********************************************/ /* refuel/defuel switch selected ? */ /***********************************************/ switch (REFUEL_DEFUEL_SWITCH_SELECTED & (~g_uart1_rx_buff [STATUS_ENTRY1])) { case 0: case 3: case 5: case 6: case 7: case 9: case 10: case 11: case 12: case 13: case 14: case 15: /***********************************************/ /* 0, 2, 3 or 4 bits selected at a time, hence */ /* report an error. */ /***********************************************/ pdm_refuel_defuel_mode_status = 0; fai_pass_fail_logger (RPTR_REFUEL_DEFUEL_SWITCH_INVALID_ID, FAIL); break; case 1: case 8: /***********************************************/ /* manual refuel or defuel selected */ /* set to abort auto refuel/defuel */ /* reset auto refuel/defuel flags and make */ /* selected qty = total */ /***********************************************/ pdm_refuel_defuel_mode_status = 1; pdm_auto_refuel_flag = RESET; pdm_auto_defuel_flag = RESET; g_own_abort_refuel = SET; g_own_abort_defuel = SET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; g_valve_cmd = RESET; /* close the valve ????? */ /***********************************************/ /* if auto refuel/defuel in progress, set to */ /* display ABORT */ /***********************************************/ if ((g_refuel_in_prog) || (g_defuel_in_prog) || (g_others_refuel_in_prog) || (g_others_defuel_in_prog)) { g_pdm_abort_variable = SET; } fai_pass_fail_logger (RPTR_REFUEL_DEFUEL_SWITCH_INVALID_ID, PASS); /* ???? */ break; case 2: /***********************************************/ /* auto refuel selected */ /* hence, set to abort auto defuel and */ /* reset auto defuel flag */ /***********************************************/ pdm_refuel_defuel_mode_status = 2; g_own_abort_defuel = SET; pdm_auto_defuel_flag = RESET; /***********************************************/ /* Check if auto refuel entered for the first */ /* time. If yes, put selected qty = total, */ /* set auto refuel flag and close the valve. */ /***********************************************/ if (pdm_auto_refuel_flag == RESET) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; pdm_auto_refuel_flag = SET; pdm_refuel_wait_ctr = RESET; g_valve_cmd = RESET; /* Close the valve ???????? */ } fai_pass_fail_logger (RPTR_REFUEL_DEFUEL_SWITCH_INVALID_ID, PASS); /* ???? */ break; case 4: /***********************************************/ /* auto defuel selected */ /* hence, set to abort auto refuel and */ /* reset auto refuel flag */ /***********************************************/ pdm_refuel_defuel_mode_status = 4; g_own_abort_refuel = SET; pdm_auto_refuel_flag = RESET; /***********************************************/ /* Check if auto defuel entered for the first */ /* time. If yes, put selected qty = total, */ /* set auto defuel flag and close the valve. */ /***********************************************/ if (pdm_auto_defuel_flag == RESET) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; pdm_auto_defuel_flag = SET; pdm_defuel_wait_ctr = RESET; g_valve_cmd = RESET; /* Close the valve ???????? */ } fai_pass_fail_logger (RPTR_REFUEL_DEFUEL_SWITCH_INVALID_ID, PASS); /* ???? */ break; default: break; }/* end switch */ /***********************************************/ /* If selected qty = total, keep updating it. */ /***********************************************/ if (g_pdm_third_row == TOTAL) g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; else { if ((g_pdm_third_row == SELECT_TOTAL) && (g_refuel_in_prog == RESET) && (g_defuel_in_prog == RESET) && (g_others_refuel_in_prog == RESET) && (g_others_defuel_in_prog == RESET)) { g_pdm_third_row = TOTAL; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; } } }/* pdm_process_discrete_data */ #pragma EJECT /***************************************************************************/ /* Unit Name : pdm_invoke_wrap */ /* Description : This unit sets up to perform a wrap test of the upper, */ /* middle and lower displays */ /* Inputs : g_uart1_rx_index */ /* : g_uart1_wr_index */ /* : g_uart1_rx_buff */ /* Outputs : g_uart1_rx_index */ /* : g_uart1_tx_buff */ /* : g_uart1_tx_index */ /* : g_uart1_rx_index */ /* Called by : main (background executive) */ /* Calls : None */ /***************************************************************************/ void pdm_invoke_wrap (void) { if ((pdm_transmit_data == SET) && (g_own_refuel_door == DOOR_OPEN)) { /***************************************************/ /* Set wrap enable flag */ /***************************************************/ pdm_wrap_enable_flag = SET; /***************************************************/ /* Copy first 2 bytes of data in rx buffer into */ /* a temporary buffer. */ /***************************************************/ pdm_wrap_save_buff[0] = g_uart1_rx_buff[0]; pdm_wrap_save_buff[1] = g_uart1_rx_buff[1]; /***************************************************/ /* Save uart1 receive index. */ /***************************************************/ pdm_stored_rx_index = g_uart1_rx_index; /***********************************************/ /* Clear transmit buffer. */ /***********************************************/ memset(&g_uart1_tx_buff, RESET, sizeof(g_uart1_tx_buff)); pdm_uart1_wr_index = RESET; /***********************************************/ /* Request display wrap data. */ /***********************************************/ switch (pdm_wrap_index) { case 0 : g_uart1_tx_buff [pdm_uart1_wr_index++] = UPPER_DISPLAY_READ; break; case 1 : g_uart1_tx_buff [pdm_uart1_wr_index++] = MIDDLE_DISPLAY_READ; break; case 2 : g_uart1_tx_buff [pdm_uart1_wr_index++] = LOWER_DISPLAY_READ; break; default: break; } g_uart1_tx_buff [pdm_uart1_wr_index] = ETX; /**************************************************/ /* */ /* Reset transmit index and receive index. */ /* (Global index into the transmit and receive */ /* buffers.) */ /**************************************************/ g_uart1_tx_index = 0; g_uart1_rx_index = 0; /***********************************************/ /* Clear receive buffer. */ /***********************************************/ memset(&g_uart1_rx_buff, RX_BUFFER_SET, sizeof(g_uart1_rx_buff)); /***********************************************/ /* Set command instruction definition to enable*/ /* the transmit interrupt. */ /* D901 = 05h */ /***********************************************/ XBYTE [UART1_CONT_ADDR ] = 0x05; } } /* pdm_invoke_wrap */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_wrap_handler */ /* Description : This unit processes the wrap data. */ /* Inputs : None */ /* Outputs : g_uart1_rx_index */ /* : g_uart1_rx_buff */ /* Called by : pdm_talk_to_repeaters */ /* Calls : fai_pass_fail_logger */ /* */ /***************************************************************************/ void pdm_wrap_handler(void) { #define NUMBER_OF_DISPLAY_LINES 3 static xdata uchar compare_results[NUMBER_OF_DISPLAY_LINES]; /***********************************************/ /* Compare received data to transmitted data. */ /* If no match then report error. */ /***********************************************/ switch (pdm_wrap_index) { case 0 : compare_results[pdm_wrap_index] = memcmp(&g_uart1_rx_buff, &pdm_upper_transmitted_data, sizeof(pdm_upper_transmitted_data)); break; case 1 : compare_results[pdm_wrap_index] = memcmp(&g_uart1_rx_buff, &pdm_middle_transmitted_data, sizeof(pdm_middle_transmitted_data)); break; case 2 : compare_results[pdm_wrap_index] = memcmp(&g_uart1_rx_buff, &pdm_lower_transmitted_data, sizeof(pdm_lower_transmitted_data)); break; default: break; } if (ZERO != compare_results[pdm_wrap_index]) { /***********************************************/ /* Comparison failed so log an error. */ /***********************************************/ if ((g_own_refuel_door == DOOR_OPEN)) fai_pass_fail_logger (REPEATER_WRAP_TEST_ID,FAIL); else fai_pass_fail_logger (REPEATER_WRAP_TEST_ID,PASS); } else { /***********************************************/ /* Comparison passed so log a pass only if the */ /* top, middle and bottom displays have passed. */ /***********************************************/ if ((ZERO == compare_results[0]) && (ZERO == compare_results[1]) && (ZERO == compare_results[2])) fai_pass_fail_logger (REPEATER_WRAP_TEST_ID,PASS); } /***********************************************/ /* Restore receive buffer data and index. */ /***********************************************/ memcpy(&g_uart1_rx_buff,&pdm_wrap_save_buff,sizeof(pdm_wrap_save_buff)); /***************************************************/ /* Restore the uart1 receive index. */ /* Reset wrap enable flag & setup for next test. */ /***************************************************/ g_uart1_rx_index = pdm_stored_rx_index ; pdm_wrap_enable_flag = RESET; pdm_wrap_index++; pdm_wrap_index %=NUMBER_OF_DISPLAY_LINES; } #pragma EJECT /***************************************************************************/ /* Unit Name : pdm_format_normal_displays */ /* Description : This unit monitors the switch input data to determine the */ /* fuel qty and selected quantity to be displayed. */ /* Inputs : g_selected_qty */ /* : g_uart1_rx_buff */ /* : g_refuel_in_prog, g_defuel_in_prog */ /* : g_pdm_fuel_qty */ /* : g_own_refuel_door */ /* : g_tank_failure */ /* Outputs : g_selected_qty */ /* : g_own_refuel_status, g_own_defuel_status */ /* : g_own_abort_refuel, g_own_abort_defuel */ /* : g_current_failure */ /* : g_own_sys_ref_panel, g_own_fqc */ /* Called by : pdm_talk_to_repeaters */ /* Calls : pdm_setup_normal_upper_display */ /* : pdm_setup_normal_middle_display */ /* : pdm_setup_normal_lower_display */ /* : fai_pass_fail_logger */ /* */ /***************************************************************************/ void pdm_format_normal_displays(void) { #define ANY_SWITCH_SELECTED 0x0C #define MAX_STEP_COUNT 10 #define DISPLAY_UPDATE_RATE 2 code uchar INITIAL_SELECTION[2] = {10,10}; // PR 036 change selection step code uint MAX_PRESELECT_QTY[2] = {14000,6350}; code uchar FAST_SELECTION[2] = {100,100}; // PR 036 change selection step static xdata uchar step_count, step_select, skip_ctr; static xdata uint stuck_inc_count, stuck_dec_count; xdata uchar select_index; xdata uchar skip_step; xdata uchar found, found1; /*********************************************************/ /* Determine which fault (tank and/or switch) is present */ /* for use in display routines and refuel/defuel. */ /*********************************************************/ pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; p_pdm_fault = pdm_read_faults (CURRENT_FAULTS); if (p_pdm_fault != NULL) g_current_failure = SET; else { g_current_failure = RESET; pdm_tank_failure = RESET; pdm_switch_failure = RESET; g_own_sys_ref_panel = RESET; pdm_left_tank_failure = RESET; pdm_right_tank_failure = RESET; g_own_fqc = RESET; } if (g_current_failure) { /*************************************************/ /* Repeat until */ /* */ /*************************************************/ pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; found = RESET; found1 = RESET; while ((!found) || (!found1)) { p_pdm_fault = pdm_read_faults (CURRENT_FAULTS); if (p_pdm_fault != NULL) { /*********************************************************/ /* Check for switch failures error code 33, 37,38 or 39 */ /* ???? */ /*********************************************************/ // changed fault_code to error_code 5/23/95 KM if (!found) { if (/*(p_pdm_fault->error_code == (uchar) FAI_FAULT_CODES[RPTR_RESET_TEST_SWITCH_STUCK_ID]) || (p_pdm_fault->error_code == (uchar) FAI_FAULT_CODES[RPTR_INC_DEC_SWITCH_TEST_ID] ) || (p_pdm_fault->error_code == (uchar) FAI_FAULT_CODES[RPTR_INC_DEC_SWITCH_STUCK_ID] ) || (p_pdm_fault->error_code == (uchar) FAI_FAULT_CODES[RPTR_RESET_TEST_SWITCH_INVALID_ID]) ||*/ (p_pdm_fault->lru_id == 3) || (p_pdm_fault->error_code == (uchar) FAI_FAULT_CODES[RPTR_REFUEL_DEFUEL_SWITCH_INVALID_ID])) { pdm_switch_failure = SET; g_own_sys_ref_panel = SET; found = SET; } else { pdm_switch_failure = RESET; g_own_sys_ref_panel = RESET; } } /*********************************************************/ /* Check for fqc failure to set fqc bit in system status.*/ /* Check for right side. Exclude NVM failure. */ /*********************************************************/ if (!found1) { if ((p_pdm_fault->lru_id == 1 || p_pdm_fault->lru_id == 2) && (p_pdm_fault->error_code != 33) && (pdm_otherside_first_fault_read == RESET)) { g_own_fqc = SET; found1 = SET; } else { g_own_fqc = RESET; } } } else { if (pdm_otherside_first_fault_read == SET) { found = SET; found1 = SET; } } } /*********************************************************/ /* Check for left or right tank failures */ /*********************************************************/ if (g_tank_failure[MY_SIDE] == SET) pdm_right_tank_failure = SET; else pdm_right_tank_failure = RESET; if (g_tank_failure[OTHER_SIDE] == SET) pdm_left_tank_failure = SET; else pdm_left_tank_failure = RESET; if (pdm_left_tank_failure == SET || pdm_right_tank_failure == SET) pdm_tank_failure = SET; else pdm_tank_failure = RESET; } /*********************************************************/ /* If door closed or any switch or tank failures occur, */ /* reset wait counters so that auto re/defuel will not */ /* start */ /*********************************************************/ if ((g_own_refuel_door == DOOR_CLOSED) || (pdm_switch_failure == SET) || (pdm_tank_failure == SET)) { pdm_refuel_wait_ctr = RESET; pdm_defuel_wait_ctr = RESET; } if (g_own_lbs_kgs_mode) select_index = SET; else select_index = RESET; /*********************************/ /* Setup for fast selection slow */ /* selection transition pr019*/ /*********************************/ skip_step = RESET; // pr019 skip_ctr++; skip_ctr %= DISPLAY_UPDATE_RATE; /***************************************/ /* INCR or DECR switch selected ? */ /***************************************/ switch (ANY_SWITCH_SELECTED & (~g_uart1_rx_buff [STATUS_ENTRY0])) { case 0 : /***********************************************/ /* No switch was selected so reset counter and */ /* set step count to minimum step. */ /***********************************************/ step_count = RESET; step_select = INITIAL_SELECTION[select_index]; skip_ctr = RESET; fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_TEST_ID,PASS); /***********************************************/ /* Reset stuck switch counts. */ /***********************************************/ stuck_inc_count = RESET; stuck_dec_count = RESET; //pr 013 fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_STUCK_ID,PASS); // added 3/6/95 if ((g_own_refuel_door == DOOR_OPEN)) { /***********************************************/ /* If switch activity has occurred and if auto */ /* refuel is selected, start four second wait */ /* count before enabling auto refuel, if auto */ /* defuel is not active. */ /***********************************************/ if ((pdm_refuel_defuel_mode_status == 2) && (pdm_refuel_wait_ctr> 0)) { pdm_refuel_wait_ctr--; if ((pdm_refuel_wait_ctr == RESET) && (g_defuel_in_prog == RESET) && (pdm_switch_failure == RESET) && (pdm_tank_failure == RESET) && (g_others_defuel_in_prog == RESET)) { g_own_refuel_status = SET; g_own_abort_refuel = RESET; } } else { /***********************************************/ /* If switch activity has occurred and if auto */ /* defuel is selected, start four second wait */ /* count before enabling auto defuel, if auto */ /* refuel is not active. */ /***********************************************/ if ((pdm_refuel_defuel_mode_status == 4) && (pdm_defuel_wait_ctr> 0)) { pdm_defuel_wait_ctr--; if ((pdm_defuel_wait_ctr == RESET) && (g_refuel_in_prog == RESET) && (pdm_switch_failure == RESET) && (pdm_tank_failure == RESET) && (g_others_refuel_in_prog == RESET)) { g_own_defuel_status = SET; g_own_abort_defuel = RESET; } } } } break; case 4: /******************************************************/ /* Decrement switch has been selected then decrement */ /* selected quantity, only if auto refuel/defuel is */ /* selected, door and switch are ON, and no switch or */ /* tank fault is present. */ /******************************************************/ if ((pdm_refuel_defuel_mode_status == 2 || pdm_refuel_defuel_mode_status == 4) && (pdm_switch_failure == RESET) && (pdm_tank_failure == RESET)) { if (!skip_ctr) { if ((g_own_refuel_door == DOOR_OPEN)) { if (++step_count > MAX_STEP_COUNT ) { step_select = FAST_SELECTION[select_index]; step_count = MAX_STEP_COUNT ; if (ZERO != // pr 036 (g_selected_qty % FAST_SELECTION[select_index]) ) skip_step = SET; } if (g_selected_qty < step_select) g_selected_qty=0; else /*************************************/ /* Round off to fast select only if */ /* indicated. */ /*************************************/ if (SET == skip_step) g_selected_qty -= (g_selected_qty % FAST_SELECTION[select_index]); //pr 036 else g_selected_qty-=step_select; /***********************************************/ /* if auto refuel selected and selected qty is */ /* less than total, make it equal to total. */ /***********************************************/ if ((pdm_refuel_defuel_mode_status == 2) && (g_selected_qty < g_pdm_fuel_qty[TOTAL_QTY_ENTRY])) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; } /***********************************************/ /* if auto defuel selected and selected qty is */ /* greater than total, make it equal to total. */ /***********************************************/ else if ((pdm_refuel_defuel_mode_status == 4) && (g_selected_qty > g_pdm_fuel_qty[TOTAL_QTY_ENTRY])) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; } else g_pdm_third_row = SELECTED; g_own_refuel_status = RESET; /* this is not needed here */ g_own_defuel_status = RESET; /***********************************************/ /* Set wait counters to maximum time. */ /***********************************************/ if (pdm_refuel_defuel_mode_status == 2) pdm_refuel_wait_ctr = FOUR_SECONDS; if (pdm_refuel_defuel_mode_status == 4) pdm_defuel_wait_ctr = FOUR_SECONDS; /***********************************************/ /* if refuel or defuel was in progress kill it */ /***********************************************/ if (g_refuel_in_prog || g_others_refuel_in_prog) g_own_abort_refuel = SET; if (g_defuel_in_prog || g_others_defuel_in_prog) g_own_abort_defuel = SET; stuck_inc_count = RESET; /******************************************/ /* Report invalid state pass. */ /******************************************/ fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_TEST_ID,PASS); if (++stuck_dec_count == MAX_INC_DEC_STUCK_TIME) { fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_STUCK_ID,FAIL); /******************************************/ /* Reset count so that fault will be */ /* reported every 4 minutes. */ /******************************************/ stuck_dec_count = RESET; } } } } break; case 8: /******************************************************/ /* Increment switch has been selected then increment */ /* selected quantity, only if auto refuel/defuel is */ /* selected, door and switch are ON, and no switch or */ /* tank fault is present. */ /******************************************************/ if ((pdm_refuel_defuel_mode_status == 2 || pdm_refuel_defuel_mode_status == 4) && (pdm_switch_failure == RESET) && (pdm_tank_failure == RESET)) { if (!skip_ctr) { if ((g_own_refuel_door == DOOR_OPEN)) { if (++step_count > MAX_STEP_COUNT) { step_select = FAST_SELECTION[select_index]; step_count = MAX_STEP_COUNT; if (ZERO != // pr 036 (g_selected_qty % FAST_SELECTION[select_index]) ) skip_step = SET; } /*************************************/ /* Round off to fast select only if */ /* indicated. pr019 */ /*************************************/ if (SET == skip_step) // pr 019 g_selected_qty += FAST_SELECTION[select_index] - (g_selected_qty % FAST_SELECTION[select_index]); //pr 036 else g_selected_qty+=step_select; if (g_selected_qty > MAX_PRESELECT_QTY[select_index]) g_selected_qty=MAX_PRESELECT_QTY[select_index]; /***********************************************/ /* if auto defuel selected and selected qty is */ /* greater than total, make it equal to total. */ /***********************************************/ if ((pdm_refuel_defuel_mode_status == 4) && (g_selected_qty > g_pdm_fuel_qty[TOTAL_QTY_ENTRY])) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; } /***********************************************/ /* if auto refuel selected and selected qty is */ /* less than total, make it equal to total. */ /***********************************************/ else if ((pdm_refuel_defuel_mode_status == 2) && (g_selected_qty < g_pdm_fuel_qty[TOTAL_QTY_ENTRY])) { g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; } else g_pdm_third_row = SELECTED; g_own_refuel_status = RESET; /* this is not needed here */ g_own_defuel_status = RESET; /***********************************************/ /* Set wait counters to maximum time. */ /***********************************************/ if (pdm_refuel_defuel_mode_status == 2) pdm_refuel_wait_ctr = FOUR_SECONDS; if (pdm_refuel_defuel_mode_status == 4) pdm_defuel_wait_ctr = FOUR_SECONDS; /***********************************************/ /* if refuel or defuel was in progress kill it */ /***********************************************/ if (g_refuel_in_prog || g_others_refuel_in_prog) g_own_abort_refuel = SET; if (g_defuel_in_prog || g_others_defuel_in_prog) g_own_abort_defuel = SET; stuck_dec_count = RESET; /******************************************/ /* Report invalid state pass. */ /******************************************/ fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_TEST_ID,PASS); if (++stuck_inc_count == MAX_INC_DEC_STUCK_TIME) { fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_STUCK_ID,FAIL); /******************************************/ /* Reset count so that fault will be */ /* reported every 4 minutes. */ /******************************************/ stuck_inc_count = RESET; } } } } break; case 12: /***********************************************/ /* Increment and decrement switch indicates */ /* both states, reset counters and increm error*/ /* count. */ /***********************************************/ step_count = RESET; step_select = RESET; /* indicate error */ fai_pass_fail_logger (RPTR_INC_DEC_SWITCH_TEST_ID,FAIL); break; default: break; } /* end switch */ pdm_setup_normal_upper_display(); pdm_setup_normal_middle_display(); pdm_setup_normal_lower_display(); } /* pdm_format_normal_displays */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_setup_normal_upper_display */ /* Description : This unit writes data to the tx buffer to format the */ /* upper display in normal display format. */ /* Inputs : g_own_lbs_kgs_mode */ /* : g_pdm_fuel_qty */ /* : g_current_failure */ /* Outputs : g_uart1_tx_buff */ /* : */ /* Called by : pdm_format_normal_displays */ /* Calls : none */ /* */ /***************************************************************************/ void pdm_setup_normal_upper_display(void) { #define DISPLAY_LENGTH 8 code char DASHES[] = {"--------"}; /***********************************************/ /* Setup transmit buffer for upper display. */ /* Save index into transmit buffer for upper */ /* display wrap test. */ /***********************************************/ g_uart1_tx_buff [pdm_uart1_wr_index++] = UPPER_DISPLAY_WRITE; pdm_upper_display_data_index = pdm_uart1_wr_index; /***********************************************/ /* If left tank failed, setup to display dashes*/ /* on upper display. */ /***********************************************/ if (pdm_left_tank_failure) { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",DASHES); pdm_uart1_wr_index += DISPLAY_LENGTH ; } else { /***********************************************/ /* Set up to display left tank qty */ /* on upper display. */ /***********************************************/ g_uart1_tx_buff[pdm_uart1_wr_index++] = SPACE; /*g_uart1_tx_buff[pdm_uart1_wr_index++] = SPACE;*/ pdm_uint_print(&g_uart1_tx_buff[pdm_uart1_wr_index], g_pdm_fuel_qty[OTHERS_QTY_ENTRY]); pdm_uart1_wr_index += 5; if (g_own_lbs_kgs_mode) { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC1_KGS); sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC2_KGS); } else { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC1_LBS); sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC2_LBS); } } } /* pdm_setup_normal_upper_display */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_setup_normal_middle_display */ /* Description : This unit writes data to the tx buffer to format the */ /* middle display in normal display format. */ /* Inputs : g_own_lbs_kgs_mode */ /* : g_pdm_fuel_qty */ /* : g_current_failure */ /* Outputs : g_uart1_tx_buff */ /* : */ /* Called by : pdm_format_normal_displays */ /* Calls : none */ /* */ /***************************************************************************/ void pdm_setup_normal_middle_display(void) { code char DASHES[] = {"--------"}; /***********************************************/ /* Setup transmit buffer for middle display. */ /* Save index into transmit buffer for middle */ /* display wrap test. */ /***********************************************/ /*g_uart1_tx_buff [pdm_uart1_wr_index++] = MIDDLE_DISPLAY_WRITE;*/ pdm_middle_display_data_index = pdm_uart1_wr_index; /***********************************************/ /* If right tank failed, setup to display dashes*/ /* on middle display. */ /***********************************************/ if (pdm_right_tank_failure) { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",DASHES); pdm_uart1_wr_index += DISPLAY_LENGTH ; } else { /***********************************************/ /* else set up to display right tank qty */ /* on middle display. */ /***********************************************/ g_uart1_tx_buff[pdm_uart1_wr_index++] = SPACE; /*g_uart1_tx_buff[pdm_uart1_wr_index++] = SPACE;*/ pdm_uint_print(&g_uart1_tx_buff[pdm_uart1_wr_index], g_pdm_fuel_qty[OWN_QTY_ENTRY]); pdm_uart1_wr_index += 5; if (g_own_lbs_kgs_mode) { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC1_KGS); sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC2_KGS); } else { sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC1_LBS); sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index++],"%s", UDC2_LBS); } } } /* pdm_setup_normal_middle_display */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_setup_normal_lower_display */ /* Description : This unit writes data to the tx buffer to format */ /* the lower display in normal display format. */ /* Inputs : g_pdm_fuel_qty, g_selected_qty */ /* Outputs : g_uart1_tx_buff */ /* : g_selected_qty */ /* Called by : pdm_format_normal_displays */ /* Calls : none */ /* */ /***************************************************************************/ void pdm_setup_normal_lower_display(void) { code char ABORT[] = {" ABORT "}; code char MANUAL[] = {" MANUAL "}; code char IMBALANCE[] = {"IMBALNCE"}; code char DASHES[] = {"--------"}; xdata uchar normal_lower_transmitted_data [9]; xdata uchar alternate_lower_transmitted_data [9]; xdata uchar index; static xdata uchar flash_lower_display; /***********************************************/ /* First determine what do you want to display */ /* on the lower display. */ /***********************************************/ /***********************************************/ /* If auto refuel/defuel is aborted, display */ /* "ABORT" for 5 sec */ /***********************************************/ if (g_pdm_abort_variable == SET) { if (FIVE_SECONDS <= pdm_abort_timer) { pdm_abort_timer = RESET; g_pdm_abort_variable = RESET; } else pdm_abort_timer ++; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; strcpy(normal_lower_transmitted_data, ABORT); flash_lower_display = RESET; } /*************************************************************/ /* If manual refuel/defuel is selected, check for imbalance. */ /* IF imbalance present, alternate display between IMBALNCE */ /* and MANUAL. Else display MANUAL. */ /*************************************************************/ else if (pdm_refuel_defuel_mode_status ==1) { if (g_own_sys_imb == SET) { flash_lower_display = SET; strcpy(alternate_lower_transmitted_data, IMBALANCE); } else flash_lower_display = RESET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; strcpy(normal_lower_transmitted_data, MANUAL); } /*************************************************************/ /* If any tank has failed, display dashes on lower display. */ /*************************************************************/ else if ((pdm_tank_failure == SET) && (g_refuel_in_prog == RESET) && (g_defuel_in_prog == RESET) && (g_others_refuel_in_prog == RESET) && (g_others_defuel_in_prog == RESET)) { flash_lower_display = RESET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; strcpy(normal_lower_transmitted_data, DASHES); } /*************************************************************/ /* If any switch has failed, check for imbalance. */ /* IF imbalance present, alternate display between IMBALNCE */ /* and DASHES. Else display DASHES. */ /*************************************************************/ else if ((pdm_switch_failure == SET) && (g_refuel_in_prog == RESET) && (g_defuel_in_prog == RESET) && (g_others_refuel_in_prog == RESET) && (g_others_defuel_in_prog == RESET)) { if (g_own_sys_imb == SET) { flash_lower_display = SET; strcpy(alternate_lower_transmitted_data, IMBALANCE); } else flash_lower_display = RESET; g_selected_qty = g_pdm_fuel_qty[TOTAL_QTY_ENTRY]; g_pdm_third_row = TOTAL; strcpy(normal_lower_transmitted_data, DASHES); } /*************************************************************/ /* Display SELECTED or TOTAL qty on lower display. */ /*************************************************************/ else { flash_lower_display = RESET; index = 0; normal_lower_transmitted_data[index++] = SPACE; /*normal_lower_transmitted_data[index++] = SPACE;*/ pdm_uint_print(&normal_lower_transmitted_data[index], g_selected_qty); index += 5; if (g_own_lbs_kgs_mode) { normal_lower_transmitted_data[index++] = UDC1_KGS[0]; normal_lower_transmitted_data[index++] = UDC2_KGS[0]; } else { normal_lower_transmitted_data[index++] = UDC1_LBS[0]; normal_lower_transmitted_data[index++] = UDC2_LBS[0]; } /*************************************************************/ /* Check if imbalance is present or not. */ /* IF imbalance is present, alternate display between */ /* IMBALNCE and (SELECTED or TOTAL) qty. IF user wants to */ /* change the qty, then stop flashing and display only qty. */ /*************************************************************/ if (g_own_sys_imb == SET) { if (pdm_refuel_wait_ctr == 0 && pdm_defuel_wait_ctr == 0) { flash_lower_display = SET; strcpy(alternate_lower_transmitted_data, IMBALANCE); } else flash_lower_display = RESET; } } if (flash_lower_display) pdm_fail_count++; else pdm_fail_count=RESET; /***********************************************/ /* Setup transmit buffer for lower display. */ /* Save index into transmit buffer for lower */ /* display wrap test. */ /***********************************************/ /*g_uart1_tx_buff [pdm_uart1_wr_index++] = LOWER_DISPLAY_WRITE;*/ pdm_lower_display_data_index = pdm_uart1_wr_index; if (pdm_fail_count <= ONE_SECOND) { /*************************************************/ /* Setup to display normal qty on lower display. */ /*************************************************/ sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",normal_lower_transmitted_data); pdm_uart1_wr_index += DISPLAY_LENGTH ; } else { /****************************************************/ /* Setup to display alternate qty on lower display. */ /****************************************************/ sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",alternate_lower_transmitted_data); pdm_uart1_wr_index += DISPLAY_LENGTH ; /***************************************************/ /* Setup to display normal qty on lower display if */ /* alternate qty has been displayed for one second.*/ /***************************************************/ if (TWO_SECONDS <= pdm_fail_count) pdm_fail_count = RESET; } } /*pdm_setup_normal_lower_display */ #pragma EJECT /***************************************************************************/ /* Unit Name : pdm_read_faults */ /* Description : This unit reads the current / stored faults via fai. */ /* Inputs : read_current_faults, read_my_side */ /* Outputs : fault_code */ /* Called by : pdm_format_test_displays */ /* Calls : None */ /***************************************************************************/ PDM_OUT_DATA_T xdata *pdm_read_faults (uchar fault_type) { #define TEST_SWITCH_FAIL 10 static xdata uchar side; PDM_OUT_DATA_T xdata *p_fault_list_received; if (!pdm_myside_first_fault_read) { pdm_myside_first_fault_read = SET; side=MY_SIDE; p_fault_list_received = fai_fault_output(MY_SIDE, fault_type, RESET_LIST); /***********************************************/ /* Read first fault on this side. If null then*/ /* read first fault on other side. If null */ /* return no more faults. */ /***********************************************/ if (p_fault_list_received == NULL) { /***********************************************/ /* No faults found on my side. */ /***********************************************/ p_fault_list_received = fai_fault_output(OTHER_SIDE, fault_type, RESET_LIST); side=OTHER_SIDE; g_myside_current_failure = RESET; pdm_otherside_first_fault_read = SET; } else g_myside_current_failure = SET; } else { p_fault_list_received = fai_fault_output(side, fault_type, NEXT_FAULT); if (p_fault_list_received == NULL) { if (!pdm_otherside_first_fault_read) { side=OTHER_SIDE; p_fault_list_received = fai_fault_output(OTHER_SIDE, fault_type, RESET_LIST); pdm_otherside_first_fault_read = SET; } } } /************************************************/ /* Make sure lru id is correct for FCU failures.*/ /************************************************/ if (p_fault_list_received->lru_id != TEST_SWITCH_FAIL) { p_fault_list_received->lru_id +=side; } return(p_fault_list_received); } #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_format_test_displays */ /* Description : This unit sets up the global transmit buffer to update the*/ /* upper and lower displays with test display format */ /* Inputs : g_uart1_rx_buff */ /* Outputs : g_uart1_tx_buff */ /* Called by : pdm_talk_to_repeaters */ /* Calls : pdm_exit_test_mode */ /* : pdm_format_normal_displays */ /* */ /***************************************************************************/ void pdm_format_test_displays(void) { #define TEST_SWITCH_ACTION 0x2 #define RESET_SWITCH_ACTION 0x1 #define MAX_NO_FAULTS 20 code char test_display[14][9] = { {" "}, /* all segs off */ {CHECKERBOARD, /* pr 019 CHECKERBOARD pattern */ CHECKERBOARD, CHECKERBOARD, CHECKERBOARD, CHECKERBOARD, CHECKERBOARD, CHECKERBOARD, CHECKERBOARD},/* all segs on */ {" CLEAR ?"} , /* */ {"CLEARING"} , /* */ {"CLEARED "} , /* pr 019 INVERSE CHECKERBOARD pattern*/ {INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD, INVERSE_CHECKERBOARD}, {" ACTIVE "}, {" Please "}, {" Wait "}, {"(hold in"}, {"'RESET')"}, {" FAULTS "}, {" FAULT "}, {" NO "}, }; /* */ xdata char lower_display_data[9]; xdata char middle_display_data[9]; xdata char upper_display_data[9]; xdata char current_action_status; // pr 019 xdata char reset_action_status; xdata char reset_last_action_status; static xdata uchar fault_list_index; static xdata uchar display_timer; static xdata char last_action_status; // pr 019 static xdata char toggle_action_status; xdata uchar lru, error; bit return_to_normal; return_to_normal = RESET; /***********************************************/ /* Setup to determine if a transition of the */ /* test switch has taken place. pr 019 */ /***********************************************/ current_action_status = // pr 019 TEST_SWITCH_ACTION & (~g_uart1_rx_buff [STATUS_ENTRY0]); // pr 019 reset_action_status = RESET_SWITCH_ACTION & (~g_uart1_rx_buff [STATUS_ENTRY0]); /***********************************************/ /* Setup to display all segments off on upper */ /* and lower displays. */ /***********************************************/ strcpy (upper_display_data, test_display [0]); strcpy (middle_display_data, test_display [0]); strcpy (lower_display_data, test_display [0]); #pragma EJECT switch (pdm_test_display_case) { case 0: if (pdm_display_timer++ < FIVE_SECONDS) { /*************************************************/ /* Setup to perform display test if test switch */ /* is toggled within five sec. Else, if test */ /* held for 5 sec, go to fault summary page. */ /*************************************************/ if (RESET == current_action_status) { /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step, which is display test. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case=1; } else { pdm_setup_normal_upper_display(); pdm_setup_normal_middle_display(); pdm_setup_normal_lower_display(); } } else { /***************************************************/ /* Reset display timer for next count and setup */ /* for next case step, which is fault summary page */ /***************************************************/ pdm_display_timer=0; pdm_test_display_case=2; } break; case 1 : /***********************************************/ /* Display test. */ /***********************************************/ if (pdm_display_timer++ < FOUR_SECONDS) { if (pdm_display_timer < TWO_SECONDS) { /***********************************************/ /* Setup to display inverse checkboard pattern.*/ /* pr 019*/ /***********************************************/ strcpy (upper_display_data, test_display [5]); strcpy (middle_display_data, test_display [5]); strcpy (lower_display_data, test_display [5]); } else { /***********************************************/ /* Setup to display checkboard pattern. pr 019*/ /***********************************************/ strcpy (upper_display_data, test_display [1]); strcpy (middle_display_data, test_display [1]); strcpy (lower_display_data, test_display [1]); } } else { if (pdm_display_timer++ < SIX_SECONDS) { /***********************************************/ /* Setup to display all segments off. */ /***********************************************/ strcpy (upper_display_data, test_display[0]); strcpy (middle_display_data, test_display[0]); strcpy (lower_display_data, test_display[0]); } else { /***********************************************/ /* Reset /exit test mode, since display test */ /* is over. */ /***********************************************/ pdm_exit_test_mode(); return_to_normal = SET; } } break; case 2 : /***********************************************/ /* display fault summary page for 30 sec */ /***********************************************/ fault_list_index = 0; pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; p_pdm_fault = pdm_read_faults (STORED_FAULTS); /***********************************************/ /* find out how many faults are present */ /***********************************************/ while ((p_pdm_fault != NULL) && (fault_list_index < MAX_NO_FAULTS)) { fault_list_index++; p_pdm_fault = pdm_read_faults (STORED_FAULTS); } if (pdm_display_timer++ < THIRTY_SECONDS) { /***********************************************/ /* Display no. of faults. If 0, then display */ /* "NO FAULTS" */ /***********************************************/ if (fault_list_index < 10) upper_display_data[3] = fault_list_index + '0'; else { upper_display_data[3] = (fault_list_index / 10) + '0'; upper_display_data[4] = (fault_list_index % 10) + '0'; } if (fault_list_index == 0) strcpy (upper_display_data, test_display[13]); strcpy (middle_display_data, test_display[11]); if (fault_list_index == 1) strcpy (middle_display_data, test_display[12]); if (RESET == last_action_status) { /***********************************************/ /* Check if test switch is released or not, to */ /* check for toggling */ /***********************************************/ toggle_action_status = SET; } if (SET == toggle_action_status) { if ((RESET == current_action_status) && (TEST_SWITCH_ACTION == last_action_status)) { /*****************************************************/ /* Test switch has been toggled, hence reset display */ /* timer for next count and setup for next case */ /* step, which is display faults */ /*****************************************************/ if (fault_list_index == 0) { toggle_action_status = RESET; pdm_exit_test_mode(); return_to_normal = SET; } else { pdm_myside_first_fault_read = RESET; pdm_otherside_first_fault_read = RESET; p_pdm_fault = pdm_read_faults (STORED_FAULTS); pdm_display_timer=0; pdm_test_display_case=3; toggle_action_status = RESET; } } } } /***********************************************/ /* Reset /exit test mode, since test switch is */ /* not toggled within specified time. */ /***********************************************/ else { toggle_action_status = RESET; pdm_exit_test_mode(); return_to_normal = SET; } break; case 3 : /***********************************************/ /* If test switch not toggled within specified */ /* time, then exit. */ /***********************************************/ if (pdm_display_timer++ > THIRTY_SECONDS) { pdm_exit_test_mode(); return_to_normal = SET; } else { if (p_pdm_fault == NULL) { /***********************************************/ /* check here if no. of faults is 0. If yes, */ /* then exit. */ /***********************************************/ /***********************************************/ /* Thru all stored faults. Setup for next case */ /* step which is CLEAR? faults. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case=4; } else { strcpy (upper_display_data, UPPER_DISPLAY_LRU[LRU_FAULT_LEGEND[p_pdm_fault->lru_id]]); strcpy (middle_display_data, LOWER_DISPLAY_FAULT[ERROR_LEGEND[p_pdm_fault->error_code]]); /* ???? */ lru = p_pdm_fault->lru_id; /*FOR TESTING PURPOSE */ error = p_pdm_fault->error_code; if (p_pdm_fault -> current_status == FAIL) strcpy (lower_display_data, test_display[6]); if ((RESET == current_action_status) && (TEST_SWITCH_ACTION == last_action_status)) { /*****************************************************/ /* Test switch has been toggled, hence read next */ /* fault. */ /*****************************************************/ p_pdm_fault = pdm_read_faults (STORED_FAULTS); pdm_display_timer=0; } } } break; #pragma EJECT case 4 : if (pdm_display_timer++ < FIVE_SECONDS) { /***********************************************/ /* Display CLEAR? (hold in "RESET") on displays*/ /***********************************************/ strcpy (upper_display_data, test_display[2]); strcpy (middle_display_data, test_display[9]); strcpy (lower_display_data, test_display[10]); /***********************************************/ /* Is Reset pressed ? If yes then, */ /* reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ if ((RESET_SWITCH_ACTION == reset_action_status) && (RESET == reset_last_action_status)) { display_timer=0; pdm_test_display_case=5; } } /***********************************************/ /* Reset /exit test mode, since reset switch is*/ /* not pressed within specified time. */ /***********************************************/ else { pdm_exit_test_mode(); return_to_normal = SET; } break; case 5 : if (display_timer++ < FIVE_SECONDS) { /*************************************************/ /* Check if reset is held for 5 sec or not. */ /* If no, then exit test mode. */ /* If yes, then display CLEARING Please Wait. */ /*************************************************/ /***********************************************/ /* Display CLEAR? (hold in "RESET") on displays*/ /***********************************************/ strcpy (upper_display_data, test_display[2]); strcpy (middle_display_data, test_display[9]); strcpy (lower_display_data, test_display[10]); pdm_display_timer++; if (RESET == reset_action_status && RESET_SWITCH_ACTION == reset_last_action_status) { /*pdm_exit_test_mode(); return_to_normal = SET;*/ pdm_test_display_case = 4; } } else { /****************************************************/ /* Fill transmit buffer with "CLEARING Please Wait" */ /****************************************************/ strcpy (upper_display_data, test_display[3]); strcpy (middle_display_data, test_display[7]); strcpy (lower_display_data, test_display[8]); /*******************************************/ /* Clear nonvolatile RAM by calling NVM */ /* for this side and then the other. */ /*******************************************/ if (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_MAIN_FAULT_GROUP)) { /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 7; g_own_clear_flts = SET; } else { g_own_clear_flts = SET; fai_kill_fault_list(NVM_MAIN_FAULT_GROUP); if (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_IPC_FAULT_GROUP)) { /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 8; } } } break; case 7 : /******************************************/ /* Clear nonvolatile RAM for this side. */ /******************************************/ if (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_MAIN_FAULT_GROUP)) { /****************************************************/ /* Fill transmit buffer with "CLEARING Please Wait" */ /****************************************************/ strcpy (upper_display_data, test_display[3]); strcpy (middle_display_data, test_display[7]); strcpy (lower_display_data, test_display[8]); /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 7; } else { fai_kill_fault_list(NVM_MAIN_FAULT_GROUP); if (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_IPC_FAULT_GROUP)) { /****************************************************/ /* Fill transmit buffer with "CLEARING Please Wait" */ /****************************************************/ strcpy (upper_display_data, test_display[3]); strcpy (middle_display_data, test_display[7]); strcpy (lower_display_data, test_display[8]); /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 8; } else { fai_kill_fault_list(NVM_IPC_FAULT_GROUP); /***********************************************/ /* Fill transmit buffer with "CLEARED " */ /***********************************************/ strcpy (middle_display_data, test_display[4]); /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 6; } } break; case 8 : /***********************************************/ /* Clear nonvolatile RAM for the other side. */ /***********************************************/ if (NVM_ERASE_IN_PROGRESS == nvm_erase_novram(NVM_IPC_FAULT_GROUP)) { /****************************************************/ /* Fill transmit buffer with "CLEARING Please Wait" */ /****************************************************/ strcpy (upper_display_data, test_display[3]); strcpy (middle_display_data, test_display[7]); strcpy (lower_display_data, test_display[8]); /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case = 8; } else { fai_kill_fault_list(NVM_IPC_FAULT_GROUP); /***********************************************/ /* Fill transmit buffer with "CLEARED " */ /***********************************************/ strcpy (middle_display_data, test_display[4]); /***********************************************/ /* Reset display timer for next count and setup*/ /* for next case step. */ /***********************************************/ pdm_display_timer=0; pdm_test_display_case=6; } break; case 6 : /***********************************************/ /* Display CLEARED ? for 5 seconds. */ /***********************************************/ if (pdm_display_timer++ < FIVE_SECONDS) { /***********************************************/ /* Fill transmit buffer with "CLEARED " */ /***********************************************/ strcpy (middle_display_data, test_display[4]); } else { /***********************************************/ /* Reset / exit test mode. */ /***********************************************/ g_own_tu_status &= 0x0000; //Clear tu status word. g_own_tu_status1 &= 0x00; g_own_system_status &= 0x0FE00; //Clear fault bits in system status. g_set_tu_bit = RESET; pdm_exit_test_mode(); g_own_clear_flts = RESET; return_to_normal = SET; } break; default: break; } /* end switch */ last_action_status = current_action_status; // pr 019 reset_last_action_status = reset_action_status; if (return_to_normal) pdm_format_normal_displays(); else { /************************/ /* Setup upper display. */ /************************/ if (pdm_test_display_case >= 1) { g_uart1_tx_buff [pdm_uart1_wr_index++] = UPPER_DISPLAY_WRITE; pdm_upper_display_data_index = pdm_uart1_wr_index; sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",upper_display_data); pdm_uart1_wr_index += 8; /************************/ /* Setup middle display.*/ /************************/ /*g_uart1_tx_buff [pdm_uart1_wr_index++] = MIDDLE_DISPLAY_WRITE; */ pdm_middle_display_data_index = pdm_uart1_wr_index; sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",middle_display_data); pdm_uart1_wr_index += 8; /************************/ /* Setup lower display. */ /************************/ /*g_uart1_tx_buff [pdm_uart1_wr_index++] = LOWER_DISPLAY_WRITE;*/ pdm_lower_display_data_index = pdm_uart1_wr_index; sprintf(&g_uart1_tx_buff[pdm_uart1_wr_index],"%s",lower_display_data); pdm_uart1_wr_index += 8; } } } #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : pdm_replace_char */ /* Description : This unit replaces all occurrances of the number 0 with */ /* the letter zero for display purposes. */ /* Inputs : g_uart1_tx_buff */ /* Outputs : None */ /* Called by : pdm_talk_to_repeaters */ /* Calls : None */ /***************************************************************************/ void pdm_replace_char(void) { uchar *zero_digit_pointer; /***********************************************/ /* Search transmit buffer for the number 0 */ /* being displayed. If found then replace */ /* with the letter O. */ /***********************************************/ zero_digit_pointer = g_uart1_tx_buff; while(zero_digit_pointer != NULL) { zero_digit_pointer = memchr(g_uart1_tx_buff, '0', sizeof(g_uart1_tx_buff)); if (zero_digit_pointer != NULL) *zero_digit_pointer = 'O'; } } #pragma EJECT /***************************************************************************/ /* Unit Name : pdm_exit_test_mode */ /* Description : This unit resets all flags and counters to exit the test */ /* display mode. */ /* Inputs : None */ /* Outputs : None */ /* Called by : pdm_format_test_displays */ /* Calls : None */ /***************************************************************************/ void pdm_exit_test_mode (void) { /***************************************************/ /* Reset all flags and counters for test display. */ /* mode. */ /***************************************************/ pdm_display_timer = RESET; pdm_test_mode = RESET; pdm_test_display_case = RESET; } /* */ #pragma EJECT /***************************************************************************/ /* Unit Name : pdm_uint_print */ /* Description : This unit prints integer values into the input buffer. */ /* Inputs : from_data */ /* Outputs : to_data */ /* Called by : pdm_format_normal_displays */ /* : pdm_format_test_displays */ /* Calls : None */ /***************************************************************************/ void pdm_uint_print (uchar *to_data, uint from_data) { #define BLANK_DATA ' ' #define ZERO_CHAR '0' #define DIGIT_LIMIT 100000 code uint DENO_VALUE[5] = {10000, 1000, 100, 10, 0}; xdata uint result; xdata uchar deno_index; xdata uchar *output_buff; bit leading_zero; deno_index = RESET; output_buff = to_data; leading_zero = SET; G_NUMERATOR_W = from_data; if (G_NUMERATOR_W >= DIGIT_LIMIT) { /***************************************/ /* Return all blanks. */ /***************************************/ } else { /***************************************/ /* Process data. */ /* result = numerator / denominator */ /***************************************/ G_DENOMINATOR_W = DENO_VALUE[deno_index++]; while (G_DENOMINATOR_W != ZERO) { DIV_16(); result = G_QUOTIENT_W; if ((ZERO == result) & (SET == leading_zero)) *output_buff++ = BLANK_DATA; else { *output_buff++ = result + ZERO_CHAR; leading_zero = RESET; } G_DENOMINATOR_W = DENO_VALUE[deno_index++]; G_NUMERATOR_W = G_REMAINDER_W; } /* end while */ /**********************************************/ /* Last digit is always zero when in lbs mode */ /**********************************************/ if (ZERO == G_DENOMINATOR_W) if (!g_own_lbs_kgs_mode) *output_buff++ = ZERO_CHAR; else if (g_selected_qty != from_data) *output_buff++ = ZERO_CHAR; else *output_buff++ = G_REMAINDER_W + ZERO_CHAR ; } } /* pdm_uint_print */