Index: firmware/source/sys_main.c =================================================================== diff -u -r9b262ba08e3180f121c3cf19d8d25e565183f87d -rd6c75118f4e5792b40b744a0b29e44c78368a469 --- firmware/source/sys_main.c (.../sys_main.c) (revision 9b262ba08e3180f121c3cf19d8d25e565183f87d) +++ firmware/source/sys_main.c (.../sys_main.c) (revision d6c75118f4e5792b40b744a0b29e44c78368a469) @@ -56,28 +56,36 @@ #include "can.h" #include "etpwm.h" #include "gio.h" +#include "het.h" #include "mibspi.h" #include "sci.h" #include "rti.h" #include "HDCommon.h" +#include "Accel.h" +#include "AirTrap.h" #include "AlarmLamp.h" #include "BloodFlow.h" #include "Buttons.h" #include "CommBuffers.h" #include "CPLD.h" #include "DialInFlow.h" #include "DialOutFlow.h" +#include "FluidLeak.h" #include "FPGA.h" #include "InternalADC.h" +#include "Interrupts.h" #include "MsgQueues.h" +#include "NVDataMgmt.h" #include "OperationModes.h" #include "PresOccl.h" #include "RTC.h" #include "SafetyShutdown.h" +#include "SyringePump.h" #include "SystemComm.h" #include "TaskBG.h" #include "Timers.h" +#include "Valves.h" #include "WatchdogMgmt.h" static void initProcessor( void ); @@ -101,12 +109,12 @@ { /* USER CODE BEGIN (3) */ - initProcessor(); // configure processor - initSoftware(); // initialize software modules - initHardware(); // configure external hardware - initTasks(); // setup and start the scheduled tasks + initProcessor(); // Configure processor + initSoftware(); // Initialize software modules + initHardware(); // Configure external hardware + initTasks(); // Setup and start the scheduled tasks - // start task background (will not return) + // Start task background (will not return) #ifndef _VECTORCAST_ taskBackground(); #endif @@ -123,17 +131,17 @@ * @brief initProcessor * The initProcessor function initializes and configures the processor \n * peripherals. - * @details - * Inputs : none - * Outputs : Processor peripherals initialized and configured. + * @details Inputs: none + * @details Outputs: Processor peripherals initialized and configured. * @return none *************************************************************************/ static void initProcessor( void ) { - gioInit(); // configure GPIO pins - adcInit(); // configure internal ADC channels - mibspiInit(); // re-purposing MIBSPI5 I/O/C pins as GPIO - etpwmInit(); // configure PWMs + gioInit(); // Configure GPIO pins + hetInit(); // Configure HET1 + adcInit(); // Configure internal ADC channels + mibspiInit(); // Re-purposing MIBSPI5 I/O/C pins as GPIO + etpwmInit(); // Configure PWMs etpwmSetCmpA( etpwmREG1, 0 ); etpwmSetCmpA( etpwmREG2, 0 ); etpwmSetCmpA( etpwmREG3, 0 ); @@ -142,47 +150,60 @@ etpwmSetCmpA( etpwmREG7, etpwmREG7->TBPRD / 3 ); etpwmStartTBCLK(); canInit(); // CAN1 = CAN, re-purposing CAN2 and CAN3 Rx and Tx pins as GPIO - //canEnableloopback( canREG1, External_Lbk ); // TODO - debug code sciInit(); // SCI1 used for PC serial interface, SCI2 used for FPGA serial interface - dmaEnable(); // enable DMA + dmaEnable(); // Enable DMA } /************************************************************************* * @brief initSoftware * The initSoftware function calls all software module initialize functions. - * @details - * Inputs : none - * Outputs : All modules initialized. + * @details Inputs: none + * @details Outputs: All modules initialized. * @return none *************************************************************************/ static void initSoftware( void ) { - initAlarmMgmt(); + // Initialize ms timer counter initTimers(); + // Initialize alarm manager + initAlarmMgmt(); + // Initialize drivers initCPLD(); initSafetyShutdown(); - initWatchdogMgmt(); - initFPGA(); - initAlarmLamp(); - initButtons(); initInternalADC(); + initRTC(); + initNVDataMgmt(); + // Initialize services initCommBuffers(); + initFPGA(); initMsgQueues(); + initNVDataMgmt(); initSystemComm(); + initWatchdogMgmt(); + // Initialize monitors + initAccel(); + initButtons(); initPresOccl(); + // Initialize controllers + initAirTrap(); + initAlarmLamp(); initBloodFlow(); initDialInFlow(); initDialOutFlow(); + initSyringePump(); + initValves(); + initFluidLeak(); + // Initialize modes initOperationModes(); - initRTC(); + // Initialize async interrupt handlers + initInterrupts(); } /************************************************************************* * @brief initHardware * The initHardware function initializes and configures external hardware. - * @details - * Inputs : none - * Outputs : External hardware initialized and configured. + * @details Inputs: none + * @details Outputs: External hardware initialized and configured. * @return none *************************************************************************/ static void initHardware( void ) @@ -192,20 +213,19 @@ /************************************************************************* * @brief initTasks * The initTasks function sets up and starts the scheduled tasks. - * @details - * Inputs : none - * Outputs : Scheduled tasks set up and started. + * @details Inputs: none + * @details Outputs: Scheduled tasks set up and started. * @return none *************************************************************************/ static void initTasks( void ) { - // initialize RTI to setup the 3 tasks + // Initialize RTI to setup the 3 tasks rtiInit(); rtiEnableNotification( rtiNOTIFICATION_COMPARE0 | rtiNOTIFICATION_COMPARE1 | rtiNOTIFICATION_COMPARE3 ); rtiStartCounter( rtiCOUNTER_BLOCK0 ); - // the timer task (and other comm related interrupts) require FIQ enabled + // The timer task requires FIQ enabled _enable_FIQ(); - // the general and priority tasks require IRQ enabled + // The general and priority tasks require IRQ enabled _enable_IRQ(); }