/***************************************************************************/ /***************************************************************************/ /***************************************************************************/ /******* *******/ /******* 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 : main.c */ /* CPC : Startup Initialization & Task Scheduler */ /* Engineer : Katherine Monroe */ /* Criticality Level : Level C */ /* */ /* Contents : sui_hw_init */ /* sui_set_timers */ /* sui_enable_interrupts */ /* sui_init_internal_uart */ /* sui_processor_shutdown */ /* sui_determine_start_status */ /* sui_write_warm_start_patterns */ /* main (background scheduler) */ /* */ /* Description : This CPC schedules the execution of the units in */ /* this CPCI and initializes the software & hardware. */ /* */ /* */ /* */ /* 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 /* declare all global variables public here */ #define MAIN_FILE 1 #include #include #include "asicaddr.h" #include "defines.h" #pragma listinclude #include "typedefs.h" #include "globals.h" #include "prototyp.h" /**************************/ /* Module level variables */ /**************************/ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : sui_init_internal_uart */ /* Description : This unit initializes 8031 internal UART. */ /* Inputs : None */ /* Outputs : None */ /* Called by : main (background executive) */ /* Calls : */ /* */ /***************************************************************************/ void sui_init_internal_uart (void) { /***********************/ /* Initialize the UART */ /***********************/ SCON = 0xD0; /* 4800 n 8 1 */ PCON = 0x0; TH1 = 245; TR1 = 1; TB8 = 1; } /* end sui_init_internal_uart */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : sui_enable_interrupts */ /* Description : This unit enables the 8031 interrupts. */ /* */ /* Inputs : None */ /* Outputs : None */ /* Called by : main (background executive) */ /* Calls : None */ /* */ /***************************************************************************/ void sui_enable_interrupts (void) { /*************************************************************/ /* Acknowledge all interrupts before turning them on */ /*************************************************************/ /* */ /* PIC_PEND bit map (D201h): */ /*************************************************************/ XBYTE [PIC_PEND_ADDR] = 0xff; /*************************************************************/ /* Enable interrupts IRQ3 & IRQ4 */ /*************************************************************/ /* */ /* PIC_ENA bit map (D200h): */ /* enable 16ms frame clock, sample & PDM interrupts */ /*************************************************************/ XBYTE [PIC_ENA_ADDR] = 0x98; EA = SET; // global enable of 8031 interrupts } /* end sui_enable_interrupts */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : sui_hw_init */ /* Description : This unit initializes all hardware controls. */ /* Inputs : None */ /* Outputs : None */ /* Called by : main (background executive) */ /* Calls : None */ /* */ /***************************************************************************/ void sui_hw_init (void) { #define SERIAL_PORT_ENABLED 0x10 /* used to set the IE register */ #define EXT_INTERRUPT_1_ENABLED 0x04 /* used to set the IE register */ #define TIMER1_8BIT_AUTO_RELOAD 0x20 P0 = P1 = P2 = P3 = 0xff; TCON = 0x0; /* EX1 (PIC) as level sensitive */ IP = 0x4; /* PIC is high and internal UART is low */ TMOD = TIMER1_8BIT_AUTO_RELOAD; /**************************************************************/ /* 80C51 family Interrupt Enable Register (IE) */ /**************************************************************/ IE = SERIAL_PORT_ENABLED | /* Enable UART & EX1 */ EXT_INTERRUPT_1_ENABLED; /***************************************************/ /* Set bits 5 & 6 in the control word (60H). */ /***************************************************/ XBYTE [CONTROL1_ADDR] = 0x70; // IRQ7 & 6 and UART1 enabled XBYTE [CONTROL2_ADDR] = 0x0f; // turn on int filter, external PDM /********************************************************************/ /* Initialize the Programmable Interrupt Controller (PIC) */ /********************************************************************/ /*************************************************************/ /* Initialize polarity for UART's 1&2 and PDM bit operation */ /* to active high */ /*************************************************************/ /* */ /* PIC_POL bit map (D202h): */ /*************************************************************/ XBYTE [PIC_POL_ADDR] = 0xc7; // 0xc7 = 1100$0111 binary /*************************************************************/ /* Initialize UART's 1&2 and ARINC to be level */ /*************************************************************/ /* */ /* PIC_LEV bit map (D203h): */ /*************************************************************/ XBYTE [PIC_LEV_ADDR] = 0xe0; // 0xe0 = 1110$0000 binary } /* end sui_hw_init */ #pragma EJECT /***************************************************************************/ /* */ /* Unit Name : main (background scheduler) */ /* Description : This unit executes the main executive loop. */ /* */ /* Inputs : g_task_flag */ /* g_task_counter */ /* g_wdt_pattern */ /* */ /* Outputs : g_task_flag */ /* g_wdt_pattern */ /* */ /* Called by : invoked upon reset */ /* */ /* Calls : sui_hw_init */ /* sui_set_timers */ /* sui_enable_interrupts */ /* */ /* arn_hw_init */ /* arn_sw_init */ /* arn_tx_task */ /* arn_formatter */ /* arn_process_wrap */ /* */ /* pdm_sw_init */ /* pdm_hw_init */ /* */ /* acq_sw_init */ /* acq_hw_init */ /* acq_setup_tu_status */ /* acq_slosh_filter */ /* acq_analog_bit */ /* */ /* dsc_sw_init */ /* dsc_hw_init */ /* dsc_process_discretes */ /* dsc_output_discrete_data */ /* dsc_read_config */ /* */ /* pdm_talk_to_repeaters */ /* pdm_invoke_wrap */ /* */ /* refuel_defuel_init */ /* ref_refuel_processing */ /* def_defuel_processing */ /* */ /* fqc_sw_init */ /* fqc_compute_mass */ /* */ /* fai_initialization */ /* fai_fault_determination */ /* */ /* */ /* bit_cpu_test */ /* bit_entire_rom_test */ /* bit_probe_bit */ /* */ /* */ /* intp_tx_task */ /* intp_setup_current_fault_data */ /* intp_report_others_faults */ /* */ /* */ /* nvm_initialization */ /***************************************************************************/ void main (void) { /*******************/ /* Local variables */ /*******************/ xdata uchar wdog; bit_entire_rom_test(); /* Failure of this test halts processing */ bit_cpu_test(); /***************************/ /* Initialize the software */ /***************************/ g_start_status = COLD ; acq_sw_init(); /* Data Acquisition CSC */ nvm_initialization(); /* Nonvolatile RAM initialization */ fai_initialization (); /* Fault isolation initialization */ dsc_read_config(); /* Discrete Processing CSC */ dsc_sw_init (); /* Discrete SW initialization */ refuel_defuel_init(); /* Refuel Defuel Processing CSC */ pdm_sw_init(); /* PDM/FSK Communications CSC */ /***************************/ /* Initialize the hardware */ /***************************/ sui_hw_init(); sui_init_internal_uart(); /* must be called after sui_hw_init */ pdm_hw_init(); /* PDM/FSK HW initialization */ arn_hw_init(); /* Arinc HW initialization */ dsc_hw_init(); /* Discrete HW initialization */ /***************************************/ /* Initialize the TUI control register */ /***************************************/ acq_hw_init(); SUI_HW_INIT_END: /*********************/ /* Enable interrupts */ /*********************/ sui_enable_interrupts(); #pragma EJECT /************************************/ /* Execute the main background loop */ /************************************/ SUI_MAIN_LOOP: for (;;) { // do forever if (g_task_flag) { acq_slosh_filter(); // filter the acquired data intp_rx_task(); // process received interprocessor stuff dsc_process_discretes(); // read and process discrete input data // hit the watchdog every 65 msec wdog = XBYTE [WDS_ADDR]; // strobe wdog switch (g_task_counter) { // 30 tasks in 65.535 msec slots each = 2 sec case 0: pdm_talk_to_repeaters(); break; case 1: fqc_compute_mass(); arn_formatter(); break; case 2: arn_tx_task(); break; case 3: pdm_talk_to_repeaters(); break; case 4: ref_refuel_processing(); def_defuel_processing(); break; case 5: arn_tx_task(); bit_probe_bit(); break; case 6: intp_setup_current_fault_data (); pdm_talk_to_repeaters(); break; case 7: intp_tx_task(); acq_setup_tu_status(); break; case 8: arn_tx_task(); break; case 9: arn_process_wrap(); pdm_talk_to_repeaters(); break; case 10: intp_report_others_faults (); fai_fault_determination(); LOG_FAULTS: break; case 11: arn_tx_task(); break; case 12: pdm_talk_to_repeaters(); break; case 13: dsc_output_discrete_data(); break; case 14: arn_tx_task(); break; case 15: pdm_talk_to_repeaters(); break; case 16: break; case 17: arn_tx_task(); break; case 18: pdm_talk_to_repeaters(); break; case 19: acq_analog_bit (); break; case 20: arn_tx_task(); intp_setup_current_fault_data (); break; case 21: pdm_talk_to_repeaters(); break; case 22: intp_tx_task(); acq_setup_tu_status(); break; case 23: arn_tx_task(); break; case 24: pdm_talk_to_repeaters(); break; case 25: intp_report_others_faults (); break; case 26: pdm_invoke_wrap(); arn_tx_task(); break; case 27: pdm_talk_to_repeaters(); break; case 28: dsc_output_discrete_data(); break; case 29: arn_tx_task(); break; default: break; } // switch TASK_LIST_END: g_task_flag = RESET; } // task flag if (!g_task_flag) bit_ram_test(); if (!g_task_flag) bit_periodic_rom_test(); } /* do forever */ } /* end main */