Index: firmware/App/Controllers/AlarmLamp.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Controllers/AlarmLamp.c (.../AlarmLamp.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -16,7 +16,7 @@ ***************************************************************************/ #include "AlarmLamp.h" -//#include "CPLD.h" +#include "CpldInterface.h" #include "Messaging.h" #include "TaskGeneral.h" #include "Timers.h" @@ -89,9 +89,9 @@ /*********************************************************************//** * @brief - * The initAlarmLamp function initializes the AlarmLamp module. - * @details Inputs: none - * @details Outputs: AlarmLamp module initialized. + * The initAlarmLamp function initializes the AlarmLamp unit. + * @details \b Inputs: none + * @details \b Outputs: AlarmLamp unit initialized. * @return none *************************************************************************/ void initAlarmLamp( void ) @@ -107,11 +107,11 @@ /*********************************************************************//** * @brief - * The execAlarmLamp function executes the alarm lamp service for the - * current lamp pattern. - * @details Inputs: pendingLampPattern, currentLampPattern, lampPatternStepTimer, + * The execAlarmLamp function executes the alarm lamp service to output + * the currently set lamp pattern. + * @details \b Inputs: pendingLampPattern, currentLampPattern, lampPatternStepTimer, * lampPatterns. - * @details Outputs: currentLampPattern + * @details \b Outputs: currentLampPattern * @return none *************************************************************************/ void execAlarmLamp( void ) @@ -150,10 +150,11 @@ /*********************************************************************//** * @brief - * The requestAlarmLampPattern function sets a request for a new lamp pattern. - * @details Inputs: none - * @details Outputs: pendingLampPattern - * @param lampPattern new lamp pattern + * The requestAlarmLampPattern function sets a request for a new lamp pattern. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given lamp patter ID invalid. + * @details \b Inputs: none + * @details \b Outputs: pendingLampPattern + * @param lampPattern new lamp pattern being requested * @return none *************************************************************************/ void requestAlarmLampPattern( LAMP_PATTERN_T lampPattern ) @@ -172,8 +173,8 @@ * @brief * The getCurrentAlarmLampPattern function gets the current alarm lamp * pattern in effect. - * @details Inputs: currentLampPattern - * @details Outputs: none + * @details \b Inputs: currentLampPattern + * @details \b Outputs: none * @return currentLampPattern *************************************************************************/ LAMP_PATTERN_T getCurrentAlarmLampPattern( void ) @@ -191,9 +192,9 @@ /*********************************************************************//** * @brief * The getAlarmLampOn function gets the current alarm lamp on flag. - * @details Inputs: alarmLampOn - * @details Outputs: none - * @return alarmLampOn + * @details \b Inputs: alarmLampOn + * @details \b Outputs: none + * @return TRUE if the alarm lamp is currently on, FALSE if not *************************************************************************/ BOOL getAlarmLampOn( void ) { @@ -202,11 +203,13 @@ /*********************************************************************//** * @brief - * The execAlarmLampTest function executes the alarm lamp test. - * This function should be called periodically until a pass or fail - * result is returned. - * @details Inputs: alarmLampSelfTestState, alarmLampSelfTestStepTimerCount - * @details Outputs: alarmLampSelfTestState, alarmLampSelfTestStepTimerCount + * The execAlarmLampTest function executes the alarm lamp self-test state machine. + * @note This function should be called periodically until a pass or fail + * result is returned. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if current alarm lamp self-test + * state is invalid. + * @details \b Inputs: alarmLampSelfTestState, alarmLampSelfTestStepTimerCount + * @details \b Outputs: alarmLampSelfTestState, alarmLampSelfTestStepTimerCount * @return in progress, passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execAlarmLampTest( void ) @@ -218,15 +221,15 @@ case ALARM_LAMP_SELF_TEST_STATE_START: alarmLampSelfTestState = ALARM_LAMP_SELF_TEST_STATE_RED; alarmLampSelfTestStepTimerCount = getMSTimerCount(); -// setCPLDLampRed( PIN_SIGNAL_HIGH ); + setCPLDLampRed( PIN_SIGNAL_HIGH ); break; case ALARM_LAMP_SELF_TEST_STATE_RED: if ( TRUE == didTimeout( alarmLampSelfTestStepTimerCount, POST_LAMP_STEP_TIME_MS ) ) { alarmLampSelfTestState = ALARM_LAMP_SELF_TEST_STATE_YELLOW; alarmLampSelfTestStepTimerCount = getMSTimerCount(); -// setCPLDLampGreen( PIN_SIGNAL_HIGH ); // Green + red = yellow + setCPLDLampGreen( PIN_SIGNAL_HIGH ); // Green + red = yellow } break; @@ -235,15 +238,15 @@ { alarmLampSelfTestState = ALARM_LAMP_SELF_TEST_STATE_GREEN; alarmLampSelfTestStepTimerCount = getMSTimerCount(); -// setCPLDLampRed( PIN_SIGNAL_LOW ); + setCPLDLampRed( PIN_SIGNAL_LOW ); } break; case ALARM_LAMP_SELF_TEST_STATE_GREEN: if ( TRUE == didTimeout( alarmLampSelfTestStepTimerCount, POST_LAMP_STEP_TIME_MS ) ) { alarmLampSelfTestState = ALARM_LAMP_SELF_TEST_STATE_COMPLETE; -// setCPLDLampGreen( PIN_SIGNAL_LOW ); + setCPLDLampGreen( PIN_SIGNAL_LOW ); requestAlarmLampPattern( LAMP_PATTERN_OK ); result = SELF_TEST_STATUS_PASSED; } @@ -265,9 +268,9 @@ /*********************************************************************//** * @brief - * The resetAlarmLampPOSTState function resets the alarm lamp post state. - * @details Inputs: none - * @details Outputs: alarmLampSelfTestState + * The resetAlarmLampPOSTState function resets the alarm lamp self-test state. + * @details \b Inputs: none + * @details \b Outputs: alarmLampSelfTestState * @return none *************************************************************************/ void resetAlarmLampPOSTState( void ) @@ -277,10 +280,10 @@ /*********************************************************************//** * @brief - * The setAlarmLampToPatternStep function sets the lamps according to the + * The setAlarmLampToPatternStep function sets the lamp LEDs according to the * current lamp pattern and lamp pattern step. - * @details Inputs: lampPatterns[], currentLampPatternStep - * @details Outputs: lampPatternStepTimer reset. Lamps set per current pattern. + * @details \b Inputs: lampPatterns[], currentLampPatternStep + * @details \b Outputs: lampPatternStepTimer reset. Lamps set per current pattern. * @return none *************************************************************************/ static void setAlarmLampToPatternStep( void ) @@ -296,23 +299,21 @@ green = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; } -#if 0 // This is dead code until blue color is used somewhere if ( LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].blue[ currentLampPatternStep ] == LAMP_STATE_ON ) { blue = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; } -#endif if ( LAMP_PATTERNS[ getCurrentAlarmLampPattern() ].red[ currentLampPatternStep ] == LAMP_STATE_ON ) { red = PIN_SIGNAL_HIGH; alarmLampOn = TRUE; } #ifndef TASK_TIMING_OUTPUT_ENABLED -// setCPLDLampGreen( green ); -// setCPLDLampBlue( blue ); -// setCPLDLampRed( red ); + setCPLDLampGreen( green ); + setCPLDLampBlue( blue ); + setCPLDLampRed( red ); #endif } @@ -324,11 +325,11 @@ /*********************************************************************//** * @brief - * The testSetCurrentLampPatternOverride function overrides the state of the - * current alarm lamp pattern with a given pattern. - * @details Inputs: none - * @details Outputs: currentLampPattern - * @param value override state for the alarm lamp pattern + * The testSetCurrentLampPatternOverride function overrides the current + * alarm lamp pattern with a given pattern. + * @details \b Inputs: none + * @details \b Outputs: currentLampPattern + * @param value Value to override the alarm lamp pattern to * @return TRUE if override successful, FALSE if not *************************************************************************/ BOOL testSetCurrentLampPatternOverride( U32 value ) @@ -348,9 +349,9 @@ /*********************************************************************//** * @brief * The testResetCurrentLampPatternOverride function resets the override of the - * state of the alarm lamp pattern. - * @details Inputs: none - * @details Outputs: currentLampPattern + * alarm lamp pattern. + * @details \b Inputs: none + * @details \b Outputs: currentLampPattern * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetCurrentLampPatternOverride( void ) Index: firmware/App/Controllers/AlarmLamp.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Controllers/AlarmLamp.h (.../AlarmLamp.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,7 +22,9 @@ /** * @defgroup AlarmLamp AlarmLamp - * @brief The Alarm Lamp module manages the state of the alarm lamp. + * @brief The Alarm Lamp unit manages the state of the alarm lamp and + * provides functions for requesting alarm lamp patterns, testing the + * alarm lamp, and getting the alarm lamp state. * * @addtogroup AlarmLamp * @{ @@ -46,14 +48,15 @@ // ********** public function prototypes ********** void initAlarmLamp( void ); -void execAlarmLamp( void ); -void requestAlarmLampPattern( LAMP_PATTERN_T lampPattern ); -SELF_TEST_STATUS_T execAlarmLampTest( void ); -void resetAlarmLampPOSTState( void ); +void execAlarmLamp( void ); +void requestAlarmLampPattern( LAMP_PATTERN_T lampPattern ); LAMP_PATTERN_T getCurrentAlarmLampPattern( void ); -BOOL getAlarmLampOn( void ); +BOOL getAlarmLampOn( void ); +SELF_TEST_STATUS_T execAlarmLampTest( void ); +void resetAlarmLampPOSTState( void ); + BOOL testSetCurrentLampPatternOverride( U32 value ); BOOL testResetCurrentLampPatternOverride( void ); Index: firmware/App/Drivers/GPIO.c =================================================================== diff -u -r055108714c39391276fc1ae1f404237627306b92 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/GPIO.c (.../GPIO.c) (revision 055108714c39391276fc1ae1f404237627306b92) +++ firmware/App/Drivers/GPIO.c (.../GPIO.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -83,8 +83,8 @@ * @brief * The toggleWatchdogPetSignal function toggles the watchdog pet output * signal on its GPIO pin. - * @details Inputs: none - * @details Outputs: Watchdog pet output signal toggled + * @details \b Inputs: none + * @details \b Outputs: Watchdog pet output signal toggled * @return none *************************************************************************/ void toggleWatchdogPetSignal( void ) @@ -96,8 +96,8 @@ * @brief * The setWatchdogPetSignal function sets the watchdog pet output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Watchdog pet output signal set high + * @details \b Inputs: none + * @details \b Outputs: Watchdog pet output signal set high * @return none *************************************************************************/ void setWatchdogPetSignal( void ) @@ -109,8 +109,8 @@ * @brief * The clrWatchdogPetSignal function sets the watchdog pet output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Watchdog pet output signal set low + * @details \b Inputs: none + * @details \b Outputs: Watchdog pet output signal set low * @return none *************************************************************************/ void clrWatchdogPetSignal( void ) @@ -122,8 +122,8 @@ * @brief * The togglePowerOffRequestSignal function toggles the power off output * signal on its GPIO pin. - * @details Inputs: none - * @details Outputs: Power off output signal toggled + * @details \b Inputs: none + * @details \b Outputs: Power off output signal toggled * @return none *************************************************************************/ void togglePowerOffRequestSignal( void ) @@ -135,8 +135,8 @@ * @brief * The setPowerOffRequestSignal function sets the power off output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Power off output signal set high + * @details \b Inputs: none + * @details \b Outputs: Power off output signal set high * @return none *************************************************************************/ void setPowerOffRequestSignal( void ) @@ -148,8 +148,8 @@ * @brief * The clrPowerOffRequestSignal function sets the power off output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Power off output signal set low + * @details \b Inputs: none + * @details \b Outputs: Power off output signal set low * @return none *************************************************************************/ void clrPowerOffRequestSignal( void ) @@ -161,8 +161,8 @@ * @brief * The getACPowerPresentSignal function gets the AC power present input * signal currently seen on its GPIO pin. - * @details Inputs: AC power present input signal - * @details Outputs: none + * @details \b Inputs: AC power present input signal + * @details \b Outputs: none * @return AC power present input signal *************************************************************************/ PIN_SIGNAL_STATE_T getACPowerPresentSignal( void ) @@ -176,8 +176,8 @@ * @brief * The setAlarmLampGreenSignal function sets the alarm lamp green output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Alarm lamp green output signal set high + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp green output signal set high * @return none *************************************************************************/ void setAlarmLampGreenSignal( void ) @@ -189,8 +189,8 @@ * @brief * The setAlarmLampBlueSignal function sets the alarm lamp blue output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Alarm lamp blue output signal set high + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp blue output signal set high * @return none *************************************************************************/ void setAlarmLampBlueSignal( void ) @@ -202,8 +202,8 @@ * @brief * The setAlarmLampRedSignal function sets the alarm lamp red output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Alarm lamp red output signal set high + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp red output signal set high * @return none *************************************************************************/ void setAlarmLampRedSignal( void ) @@ -215,8 +215,8 @@ * @brief * The clrAlarmLampGreenSignal function sets the alarm lamp green output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Alarm lamp green output signal set low + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp green output signal set low * @return none *************************************************************************/ void clrAlarmLampGreenSignal( void ) @@ -228,8 +228,8 @@ * @brief * The clrAlarmLampBlueSignal function sets the alarm lamp blue output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Alarm lamp blue output signal set low + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp blue output signal set low * @return none *************************************************************************/ void clrAlarmLampBlueSignal( void ) @@ -241,8 +241,8 @@ * @brief * The clrAlarmLampRedSignal function sets the alarm lamp red output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Alarm lamp red output signal set low + * @details \b Inputs: none + * @details \b Outputs: Alarm lamp red output signal set low * @return none *************************************************************************/ void clrAlarmLampRedSignal( void ) @@ -254,8 +254,8 @@ * @brief * The setSafetyShutdownSignal function sets the safety shutdown output * signal on its GPIO pin to HIGH. - * @details Inputs: none - * @details Outputs: Safety shutdown output signal set high + * @details \b Inputs: none + * @details \b Outputs: Safety shutdown output signal set high * @return none *************************************************************************/ void setSafetyShutdownSignal( void ) @@ -267,8 +267,8 @@ * @brief * The clrSafetyShutdownSignal function sets the safety shutdown output * signal on its GPIO pin to LOW. - * @details Inputs: none - * @details Outputs: Safety shutdown output signal set low + * @details \b Inputs: none + * @details \b Outputs: Safety shutdown output signal set low * @return none *************************************************************************/ void clrSafetyShutdownSignal( void ) @@ -280,8 +280,8 @@ * @brief * The getSafetySignal function gets the safety shutdown input signal * currently seen on its GPIO pin. - * @details Inputs: Safety shutdown input signal - * @details Outputs: none + * @details \b Inputs: Safety shutdown input signal + * @details \b Outputs: none * @return Safety shutdown input signal *************************************************************************/ PIN_SIGNAL_STATE_T getSafetySignal( void ) @@ -295,8 +295,8 @@ * @brief * The getOffButtonSignal function gets the off button input signal * currently seen on its GPIO pin. - * @details Inputs: Off button input signal - * @details Outputs: none + * @details \b Inputs: Off button input signal + * @details \b Outputs: none * @return Off button input signal *************************************************************************/ PIN_SIGNAL_STATE_T getOffButtonSignal( void ) @@ -310,8 +310,8 @@ * @brief * The getStopButtonSignal function gets the stop button input signal * currently seen on its GPIO pin. - * @details Inputs: stop button input signal - * @details Outputs: none + * @details \b Inputs: stop button input signal + * @details \b Outputs: none * @return Stop button input signal *************************************************************************/ PIN_SIGNAL_STATE_T getStopButtonSignal( void ) Index: firmware/App/Drivers/GPIO.h =================================================================== diff -u -r772fdd144e4006fada12a2e91519378b29d54bae -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/GPIO.h (.../GPIO.h) (revision 772fdd144e4006fada12a2e91519378b29d54bae) +++ firmware/App/Drivers/GPIO.h (.../GPIO.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,7 +22,7 @@ /** * @defgroup GPIO GPIO - * @brief The GPIO module provides definitions and GPIO pin access abstraction + * @brief The GPIO unit provides definitions and GPIO pin access abstraction * functions to provide low-level GPIO interface. * * @addtogroup GPIO Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -r766e65a173747dd60a9faae1cac228cd5f8a55a6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 766e65a173747dd60a9faae1cac228cd5f8a55a6) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -98,9 +98,9 @@ /*********************************************************************//** * @brief - * The initInternalADC function initializes the InternalADC module. - * @details Inputs: none - * @details Outputs: InternalADC module is initialized. + * The initInternalADC function initializes the InternalADC unit. + * @details \b Inputs: none + * @details \b Outputs: InternalADC unit is initialized. * @return none *************************************************************************/ void initInternalADC( void ) @@ -130,8 +130,8 @@ * @brief * The adcNotification function handles an ADC conversion complete interrupt. * All channel readings in the FIFO are retrieved. - * @details Inputs: ADC FIFO - * @details Outputs: adcRawReadingsCount, adcRawReadings[] + * @details \b Inputs: ADC FIFO + * @details \b Outputs: adcRawReadingsCount, adcRawReadings[] * @param adc pointer to the ADC1 controller * @param group ADC channel group ID * @return none @@ -147,9 +147,11 @@ /*********************************************************************//** * @brief * The execInternalADC function processes the last set of raw ADC channel - * readings and kicks off the next conversion of ADC channels. - * @details Inputs: adcRawReadingsCount, adcRawReadings[] - * @details Outputs: adcReadings[][], adcReadingsIdx[], adcReadingsTotals[], adcReadingsAvgs[] + * readings and kicks off the next conversion of ADC channels. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if raw readings count exceeds + * ADC channel count + * @details \b Inputs: adcRawReadingsCount, adcRawReadings[] + * @details \b Outputs: adcReadings[][], adcReadingsIdx[], adcReadingsTotals[], adcReadingsAvgs[] * @return none *************************************************************************/ void execInternalADC( void ) @@ -182,11 +184,12 @@ /*********************************************************************//** * @brief * The getIntADCReading function gets the latest average reading for a given - * channel. - * @details Inputs: adcReadingsAvgs[] - * @details Outputs: none + * channel. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given channel invalid. + * @details \b Inputs: adcReadingsAvgs[] + * @details \b Outputs: none * @param channel adc channel to retrieve a reading for - * @return average reading for the given channel + * @return The rolling averaged reading for the given channel *************************************************************************/ U16 getIntADCReading( INT_ADC_CHANNEL_T channel ) { @@ -208,10 +211,11 @@ * @brief * The getIntADCVoltageConverted function gets the latest average voltage * (converted per transfer function) for a given channel. - * @details Inputs: adcReadingsAvgs[], ADC_CHANNEL_READ_TO_UNITS[] - * @details Outputs: none - * @param channel adc channel to retrieve a converted voltage for - * @return average converted voltage for the given channel + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given channel invalid + * @details \b Inputs: adcReadingsAvgs[], ADC_CHANNEL_READ_TO_UNITS[] + * @details \b Outputs: none + * @param channel The ADC channel to retrieve a converted voltage for + * @return The rolling averaged, converted voltage for the given channel *************************************************************************/ F32 getIntADCVoltageConverted( INT_ADC_CHANNEL_T channel ) { Index: firmware/App/Drivers/InternalADC.h =================================================================== diff -u -r766e65a173747dd60a9faae1cac228cd5f8a55a6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/InternalADC.h (.../InternalADC.h) (revision 766e65a173747dd60a9faae1cac228cd5f8a55a6) +++ firmware/App/Drivers/InternalADC.h (.../InternalADC.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,7 +22,7 @@ /** * @defgroup InternalADC InternalADC - * @brief The internal ADC module provides functions for reading the sampled + * @brief The internal ADC unit provides functions for reading the sampled * internal ADC channel data. * * @addtogroup InternalADC Index: firmware/App/Drivers/PAL.c =================================================================== diff -u -r01892698468068bb97a80a84c96a6d7c5d6fde9b -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/PAL.c (.../PAL.c) (revision 01892698468068bb97a80a84c96a6d7c5d6fde9b) +++ firmware/App/Drivers/PAL.c (.../PAL.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -30,8 +30,8 @@ /*********************************************************************//** * @brief * The setSystemREG1_SYSECR function sets the SYSECR register to a given value. - * @details Inputs: none - * @details Outputs: SYSECR register set to given value + * @details \b Inputs: none + * @details \b Outputs: SYSECR register set to given value * @return none *************************************************************************/ void setSystemREG1_SYSECR( U32 regval ) @@ -42,8 +42,8 @@ /*********************************************************************//** * @brief * The getSystemREG1_SYSECR function gets the current value of the SYSECR register. - * @details Inputs: SYSECR register - * @details Outputs: none + * @details \b Inputs: SYSECR register + * @details \b Outputs: none * @return Value of the SYSECR register *************************************************************************/ U32 getSystemREG1_SYSECR( void ) @@ -55,8 +55,8 @@ * @brief * The setCrcREG_PSA_SIGREGL1 function sets the CRC PSA_SIGREGL1 register * to a given value. - * @details Inputs: none - * @details Outputs: PSA_SIGREGL1 register set to given value + * @details \b Inputs: none + * @details \b Outputs: PSA_SIGREGL1 register set to given value * @return none *************************************************************************/ void setCrcREG_PSA_SIGREGL1( U32 regval ) @@ -68,8 +68,8 @@ * @brief * The getCrcREG_PSA_SIGREGL1 function gets the current value of the CRC * PSA_SIGREGL1 register. - * @details Inputs: PSA_SIGREGL1 register - * @details Outputs: none + * @details \b Inputs: PSA_SIGREGL1 register + * @details \b Outputs: none * @return Value of the PSA_SIGREGL1 register *************************************************************************/ U32 getCrcREG_PSA_SIGREGL1( void ) Index: firmware/App/Drivers/PAL.h =================================================================== diff -u -r3b3713c0d5445b83f339021972728ff58bd3e6e5 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Drivers/PAL.h (.../PAL.h) (revision 3b3713c0d5445b83f339021972728ff58bd3e6e5) +++ firmware/App/Drivers/PAL.h (.../PAL.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,7 +22,7 @@ /** * @defgroup PAL PAL - * @brief The PAL (processor abstraction layer) module provides abstraction + * @brief The PAL (processor abstraction layer) unit provides abstraction * of processor register access via access functions. * * @addtogroup PAL Index: firmware/App/Modes/ModeFault.c =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeFault.c (.../ModeFault.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -37,9 +37,9 @@ /*********************************************************************//** * @brief - * The initFaultMode function initializes the Fault Mode module. - * @details Inputs: none - * @details Outputs: Fault Mode module initialized. + * The initFaultMode function initializes the Fault Mode unit. + * @details \b Inputs: none + * @details \b Outputs: Fault Mode unit initialized. * @return none *************************************************************************/ void initFaultMode( void ) @@ -51,8 +51,8 @@ /*********************************************************************//** * @brief * The transitionToFaultMode function prepares for transition to fault mode. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return initial state of the fault mode state machine *************************************************************************/ U32 transitionToFaultMode( void ) @@ -71,7 +71,7 @@ setAlarmUserActionEnabled( ALARM_USER_ACTION_RESUME, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_RINSEBACK, FALSE ); setAlarmUserActionEnabled( ALARM_USER_ACTION_END_TREATMENT, FALSE ); - // Stop trimmer heater +// // Stop trimmer heater // cmdStopDGTrimmerHeater(); // // Stop syringe pump // stopSyringePump(); @@ -99,8 +99,8 @@ /*********************************************************************//** * @brief * The execFaultMode function executes the Fault Mode state machine. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return current state of the fault mode *************************************************************************/ U32 execFaultMode( void ) @@ -155,8 +155,8 @@ * @brief * The signalAlarmActionToFaultMode function executes the given alarm action * as appropriate while in Fault Mode. - * @details Inputs: none - * @details Outputs: given alarm action executed + * @details \b Inputs: none + * @details \b Outputs: given alarm action executed * @param action ID of alarm action to execute * @return none *************************************************************************/ @@ -168,8 +168,8 @@ /*********************************************************************//** * @brief * The handleFaultStartState function handles the start state of the fault mode. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return next state *************************************************************************/ static HD_FAULT_STATE_T handleFaultStartState( void ) @@ -198,8 +198,8 @@ /*********************************************************************//** * @brief * The handleFaultRunNVPOSTsState function handles running non-volatile POSTs. - * @details Inputs: faultPOSTSelfTestResult - * @details Outputs: faultPOSTSelfTestResult + * @details \b Inputs: faultPOSTSelfTestResult + * @details \b Outputs: faultPOSTSelfTestResult * @return next state *************************************************************************/ static HD_FAULT_STATE_T handleFaultRunNVPOSTsState( void ) Index: firmware/App/Modes/ModeFault.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,15 +23,15 @@ /** * @defgroup TDFaultMode TDFaultMode - * @brief FaultMode module. + * @brief FaultMode unit. * * @addtogroup TDFaultMode * @{ */ // ********** public function prototypes ********** -void initFaultMode( void ); // Initialize this module +void initFaultMode( void ); // Initialize this unit U32 transitionToFaultMode( void ); // Prepares for transition to fault mode U32 execFaultMode( void ); // Execute the fault mode state machine (call from OperationModes) void signalAlarmActionToFaultMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -r01892698468068bb97a80a84c96a6d7c5d6fde9b -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 01892698468068bb97a80a84c96a6d7c5d6fde9b) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -31,7 +31,7 @@ //#include "NVDataMgmt.h" #include "OperationModes.h" #include "PAL.h" -//#include "PresOccl.h" +//#include "Pressures.h" //#include "SyringePump.h" #include "SystemCommTD.h" #include "TaskGeneral.h" @@ -83,9 +83,9 @@ /*********************************************************************//** * @brief - * The initInitAndPOSTMode function initializes the Initialize & POST Mode module. - * @details Inputs: none - * @details Outputs: Initialize & POST Mode module initialized. + * The initInitAndPOSTMode function initializes the Initialize & POST Mode unit. + * @details \b Inputs: none + * @details \b Outputs: Initialize & POST Mode unit initialized. * @return none *************************************************************************/ void initInitAndPOSTMode( void ) @@ -107,8 +107,8 @@ * @brief * The transitionToInitAndPOSTMode function prepares for transition to * initialize & POST mode. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return initial state *************************************************************************/ U32 transitionToInitAndPOSTMode( void ) @@ -135,8 +135,8 @@ * @brief * The execInitAndPOSTMode function executes the Initialize & POST Mode * state machine. - * @details Inputs: postState - * @details Outputs: postState, postPassed, postCompleted + * @details \b Inputs: postState + * @details \b Outputs: postState, postPassed, postCompleted * @return current state (sub-mode) *************************************************************************/ U32 execInitAndPOSTMode( void ) @@ -295,8 +295,8 @@ * @brief * The signalAlarmActionToInitAndPOSTMode function executes the given alarm action * as appropriate while in InitAndPOST Mode. - * @details Inputs: none - * @details Outputs: given alarm action executed + * @details \b Inputs: none + * @details \b Outputs: given alarm action executed * @param action ID of alarm action to execute * @return none *************************************************************************/ @@ -309,8 +309,8 @@ * @brief * The signalUIPOSTFinalResult function records the final POST result for * the UI. - * @details Inputs: none - * @details Outputs: uiPOSTPassed + * @details \b Inputs: none + * @details \b Outputs: uiPOSTPassed * @param passed TRUE if UI POST tests all passed, FALSE if any UI POST test failed * @return none *************************************************************************/ @@ -324,8 +324,8 @@ * @brief * The signalDDPOSTFinalResult function records the final POST result for * the DD. - * @details Inputs: none - * @details Outputs: dgPOSTPassed, dgPOSTResultReceived + * @details \b Inputs: none + * @details \b Outputs: dgPOSTPassed, dgPOSTResultReceived * @param passed TRUE if DD POST tests all passed, FALSE if any DD POST test failed * @return none *************************************************************************/ @@ -338,8 +338,8 @@ /*********************************************************************//** * @brief * The getDDPOSTPassed function gets the POST passed status of the DD sub-system. - * @details Inputs: dgPOSTPassed, dgPOSTResultReceived - * @details Outputs: none + * @details \b Inputs: dgPOSTPassed, dgPOSTResultReceived + * @details \b Outputs: none * @return TRUE if DD POST result received and passed, FALSE if not *************************************************************************/ BOOL getDDPOSTPassed( void ) @@ -352,8 +352,8 @@ /*********************************************************************//** * @brief * The signalUIVersion function records the reported UI version information. - * @details Inputs: none - * @details Outputs: uiVersion + * @details \b Inputs: none + * @details \b Outputs: uiVersion * @param version Version information reported by UI * @return none *************************************************************************/ @@ -365,8 +365,8 @@ /*********************************************************************//** * @brief * The signalDDVersion function records the reported DD version information. - * @details Inputs: none - * @details Outputs: dgVersion + * @details \b Inputs: none + * @details \b Outputs: dgVersion * @param version Version information reported by DD * @return none *************************************************************************/ @@ -378,8 +378,8 @@ /*********************************************************************//** * @brief * The getDDVersion function returns the DD version information. - * @details Inputs: dgVersion - * @details Outputs: none + * @details \b Inputs: dgVersion + * @details \b Outputs: none * @return dgVersion *************************************************************************/ DD_VERSIONS_T getDDVersion( void ) @@ -392,8 +392,8 @@ * The isPOSTCompleted function determines whether all HD POST have * been run and completed. If true, call the isPOSTPassed() to see final * result (pass/fail). - * @details Inputs: postCompleted - * @details Outputs: none + * @details \b Inputs: postCompleted + * @details \b Outputs: none * @return true if all HD POST tests have completed, false if not *************************************************************************/ BOOL isPOSTCompleted( void ) @@ -405,8 +405,8 @@ * @brief * The isPOSTPassed function determines whether all HD POST have passed. * Call this function after POST is complete (call isPOSTCompleted function). - * @details Inputs: postPassed - * @details Outputs: none + * @details \b Inputs: postPassed + * @details \b Outputs: none * @return true if all HD POST tests have passed, false if not *************************************************************************/ BOOL isPOSTPassed( void ) @@ -417,8 +417,8 @@ /*********************************************************************//** * @brief * The isDGPOSTPassed function determines whether all DG POST have passed. - * @details Inputs: dgPOSTPassed - * @details Outputs: none + * @details \b Inputs: dgPOSTPassed + * @details \b Outputs: none * @return true if all DG POST tests have passed, false if not *************************************************************************/ BOOL isDGPOSTPassed( void ) @@ -430,8 +430,8 @@ * @brief * The handlePOSTStatus function handles a status result returned by a * POST function. - * @details Inputs: testStatus - * @details Outputs: tempPOSTPassed + * @details \b Inputs: testStatus + * @details \b Outputs: tempPOSTPassed * @param testStatus status reported by last test * @return recommended next POST state *************************************************************************/ @@ -471,8 +471,8 @@ /*********************************************************************//** * @brief * The handlePOSTStateStart function handles the POST start state. - * @details Inputs: startPOSTDelayCounter - * @details Outputs: startPOSTDelayCounter + * @details \b Inputs: startPOSTDelayCounter + * @details \b Outputs: startPOSTDelayCounter * @return next POST state *************************************************************************/ static HD_POST_STATE_T handlePOSTStateStart( void ) @@ -512,8 +512,8 @@ /*********************************************************************//** * @brief * The execFWCompatibilityTest function executes the firmware compatibility test. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return in progress, passed, or failed *************************************************************************/ static SELF_TEST_STATUS_T execFWCompatibilityTest( void ) @@ -532,8 +532,8 @@ /*********************************************************************//** * @brief * The execUITest function executes the UI POST passed test. - * @details Inputs: uiPOSTResultReceived, uiPOSTPassed, waitForUIPostTimerCtr - * @details Outputs: waitForUIPostTimerCtr + * @details \b Inputs: uiPOSTResultReceived, uiPOSTPassed, waitForUIPostTimerCtr + * @details \b Outputs: waitForUIPostTimerCtr * @return in progress, passed, or failed *************************************************************************/ static SELF_TEST_STATUS_T execUITest( void ) Index: firmware/App/Modes/ModeInitPOST.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,7 +23,7 @@ /** * @defgroup TDInitAndPOSTMode TDInitAndPOSTMode - * @brief Initialization and POST mode module. Manages initialization and POST + * @brief Initialization and POST mode unit. Manages initialization and POST * mode functions via a state machine. * * @addtogroup TDInitAndPOSTMode @@ -32,17 +32,20 @@ // ********** public function prototypes ********** -void initInitAndPOSTMode( void ); // Initialize this module +void initInitAndPOSTMode( void ); // Initialize this unit U32 transitionToInitAndPOSTMode( void ); // Prepares for transition to init. & POST mode U32 execInitAndPOSTMode( void ); // Execute the init. & POST mode state machine (call from OperationModes) + BOOL isPOSTCompleted( void ); // Determine whether POST has completed yet BOOL isPOSTPassed( void ); // Determine whether POST has passed BOOL isDGPOSTPassed( void ); // Determine whether DG POST has passed + void signalAlarmActionToInitAndPOSTMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for fault mode void signalUIPOSTFinalResult( BOOL passed ); // Record UI POST result void signalDDPOSTFinalResult( BOOL passed ); // Record DD POST result void signalUIVersion( UI_VERSIONS_T version ); // Record UI version info void signalDDVersion( DD_VERSIONS_T version ); // Record DD version info + DD_VERSIONS_T getDDVersion( void ); // Get DD version info BOOL getDDPOSTPassed( void ); // Get DD POST pass/fail status Index: firmware/App/Modes/ModeService.c =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeService.c (.../ModeService.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -38,9 +38,9 @@ /*********************************************************************//** * @brief - * The initServiceMode function initializes the Service Mode module. - * @details Inputs: none - * @details Outputs: Service Mode module initialized. + * The initServiceMode function initializes the Service Mode unit. + * @details \b Inputs: none + * @details \b Outputs: Service Mode unit initialized. * @return none *************************************************************************/ void initServiceMode( void ) @@ -50,8 +50,8 @@ /*********************************************************************//** * @brief * The transitionToServiceMode function prepares for transition to service mode. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return initial state *************************************************************************/ U32 transitionToServiceMode( void ) @@ -82,8 +82,8 @@ /*********************************************************************//** * @brief * The execServiceMode function executes the Service Mode state machine. - * @details Inputs: none - * @details Outputs: none + * @details \b Inputs: none + * @details \b Outputs: none * @return current state (sub-mode) *************************************************************************/ U32 execServiceMode( void ) @@ -102,8 +102,8 @@ * @brief * The signalAlarmActionToServiceMode function executes the given alarm action * as appropriate while in Service Mode. - * @details Inputs: none - * @details Outputs: given alarm action executed + * @details \b Inputs: none + * @details \b Outputs: given alarm action executed * @param action ID of alarm action to execute * @return none *************************************************************************/ Index: firmware/App/Modes/ModeService.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeService.h (.../ModeService.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeService.h (.../ModeService.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,17 +23,18 @@ /** * @defgroup TDServiceMode TDServiceMode - * @brief Service mode module. + * @brief Service mode unit. * * @addtogroup TDServiceMode * @{ */ // ********** public function prototypes ********** -void initServiceMode( void ); // Initialize this module +void initServiceMode( void ); // Initialize this unit U32 transitionToServiceMode( void ); // Prepares for transition to service mode U32 execServiceMode( void ); // Execute the service mode state machine (call from OperationModes) + void signalAlarmActionToServiceMode( ALARM_ACTION_T action ); // Execute alarm action as appropriate for Service mode /**@}*/ Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -40,9 +40,9 @@ /*********************************************************************//** * @brief - * The initStandbyMode function initializes the Standby Mode module. - * @details Inputs: none - * @details Outputs: currentStandbyState, treatStartReqReceived, + * The initStandbyMode function initializes the Standby Mode Unit. + * @details \b Inputs: none + * @details \b Outputs: currentStandbyState, treatStartReqReceived, * disinfectCancelReqID, homingInitiated * @return none *************************************************************************/ @@ -55,8 +55,8 @@ /*********************************************************************//** * @brief * The transitionToStandbyMode function prepares for transition to standby mode. - * @details Inputs: none - * @details Outputs: Standby Mode module re-initialized, DG interface initialized, + * @details \b Inputs: none + * @details \b Outputs: Standby Mode unit re-initialized, DG interface initialized, * blood & dialysate pumps shut off. * @return initial state *************************************************************************/ @@ -96,8 +96,8 @@ /*********************************************************************//** * @brief * The execStandbyMode function executes the Standby Mode state machine. - * @details Inputs: currentStandbyState - * @details Outputs: currentStandbyState + * @details \b Inputs: currentStandbyState + * @details \b Outputs: currentStandbyState * @return current state (sub-mode) *************************************************************************/ U32 execStandbyMode( void ) @@ -129,8 +129,8 @@ * The handleStandbyModeStartState function handles the standby start state. * This state waits for the door to be closed and then initiates homing of * pumps and valves and transitions to the wait for treatment state. - * @details Inputs: - * @details Outputs: + * @details \b Inputs: + * @details \b Outputs: * @return next state of the standby mode state machine *************************************************************************/ static HD_STANDBY_STATE_T handleStandbyModeStartState( void ) @@ -186,8 +186,8 @@ * @brief * The handleStandbyModeWaitForTreatmentState function handles wait for * treatment state. - * @details Inputs: treatStartReqReceived - * @details Outputs: treatStartReqReceived + * @details \b Inputs: treatStartReqReceived + * @details \b Outputs: treatStartReqReceived * @return next state of the standby mode state machine *************************************************************************/ static HD_STANDBY_STATE_T handleStandbyModeWaitForTreatmentState( void ) @@ -256,8 +256,8 @@ * @brief * The signalAlarmActionToStandbyMode function executes the given alarm action * as appropriate while in Standby Mode. - * @details Inputs: none - * @details Outputs: given alarm action executed + * @details \b Inputs: none + * @details \b Outputs: given alarm action executed * @param action ID of alarm action to execute * @return none *************************************************************************/ Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,7 +23,7 @@ /** * @defgroup TDStandbyMode TDStandbyMode - * @brief StandbyMode module. + * @brief StandbyMode unit. * * @addtogroup TDStandbyMode * @{ @@ -33,7 +33,7 @@ // ********** public function prototypes ********** -void initStandbyMode( void ); // Initialize this module +void initStandbyMode( void ); // Initialize this unit U32 transitionToStandbyMode( void ); // Prepares for transition to standby mode U32 execStandbyMode( void ); // Execute the standby mode state machine (call from OperationModes) Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -46,10 +46,10 @@ /// Structure for confirmation request. typedef struct { - GENERIC_CONFIRM_ID_T requestID; ///< Request ID - GENERIC_CONFIRM_COMMAND_T requestType; ///< Request Type - U32 timeStamp; ///< Timestamp for request - CONFIRMATION_REQUEST_STATUS_T status; ///< Request status (pending, accepted, rejected) + GENERIC_CONFIRM_ID_T requestID; ///< Request ID + GENERIC_CONFIRM_COMMAND_T requestType; ///< Request Type + U32 timeStamp; ///< Timestamp for request + CONFIRMATION_REQUEST_STATUS_T status; ///< Request status (pending, accepted, rejected) } CONFIRMATION_REQUEST_T; // ********** private data ********** @@ -91,9 +91,9 @@ /*********************************************************************//** * @brief - * The initOperationModes function initializes the Operation Modes module. - * @details Inputs: none - * @details Outputs: Operation Modes module initialized. + * The initOperationModes function initializes the Operation Modes unit. + * @details \b Inputs: none + * @details \b Outputs: Operation Modes unit initialized. * @return none *************************************************************************/ void initOperationModes( void ) @@ -130,8 +130,9 @@ /*********************************************************************//** * @brief * The execOperationModes function executes the Operation Modes state machine. - * @details Inputs: none - * @details Outputs: currentMode is set by state machine. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if current mode is invalid. + * @details \b Inputs: none + * @details \b Outputs: currentMode is set by state machine. * @return none *************************************************************************/ void execOperationModes( void ) @@ -236,8 +237,9 @@ * The requestNewOperationMode function requests transition to a new * operation mode. The request will be arbitrated when the state machine * is next executed. - * @details Inputs: none - * @details Outputs: modeRequest[] + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given new mode is invalid. + * @details \b Inputs: none + * @details \b Outputs: modeRequest[] * @return none *************************************************************************/ void requestNewOperationMode( TD_OP_MODE_T newMode ) @@ -257,8 +259,8 @@ /*********************************************************************//** * @brief * The getCurrentOperationMode function gets the current operation mode. - * @details Inputs: currentMode - * @details Outputs: none + * @details \b Inputs: currentMode + * @details \b Outputs: none * @return the current operation mode *************************************************************************/ TD_OP_MODE_T getCurrentOperationMode( void ) @@ -269,8 +271,8 @@ /*********************************************************************//** * @brief * The getPreviousOperationMode function gets the previous operation mode. - * @details Inputs: lastMode - * @details Outputs: none + * @details \b Inputs: lastMode + * @details \b Outputs: none * @return the previous operation mode *************************************************************************/ TD_OP_MODE_T getPreviousOperationMode( void ) @@ -281,8 +283,8 @@ /*********************************************************************//** * @brief * The getCurrentSubMode function gets the current operation sub-mode. - * @details Inputs: currentSubMode - * @details Outputs: none + * @details \b Inputs: currentSubMode + * @details \b Outputs: none * @return the current operation sub-mode *************************************************************************/ U32 getCurrentSubMode( void ) @@ -294,8 +296,9 @@ * @brief * The initiateAlarmAction function initiate an alarm or alarm recovery * action according to the current operation mode. - * @details Inputs: currentMode - * @details Outputs: given action forwarded to current operation mode for execution + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given alarm action is invalid. + * @details \b Inputs: currentMode + * @details \b Outputs: given action forwarded to current operation mode for execution * @param action ID of action to be initiated * @return none *************************************************************************/ @@ -338,8 +341,10 @@ * @brief * The arbitrateModeRequest function arbitrates any pending mode transition * requests. - * @details Inputs: modeRequest[] - * @details Outputs: modeRequest[] is reset + * @note Thread protection prevents new mode requests from being made while + * arbitration is in progress. + * @details \b Inputs: modeRequest[] + * @details \b Outputs: modeRequest[] is reset * @return the next operation mode (current mode if no requests pending) *************************************************************************/ static TD_OP_MODE_T arbitrateModeRequest( void ) @@ -376,8 +381,9 @@ * @brief * The transitionToNewOperationMode function calls the transition to function * for a new operation mode that we are transitioning to. - * @details Inputs: none - * @details Outputs: transition function called for new mode + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given new mode is invalid. + * @details \b Inputs: none + * @details \b Outputs: transition function called for new mode * @return none *************************************************************************/ static void transitionToNewOperationMode( TD_OP_MODE_T newMode ) @@ -419,8 +425,8 @@ * @brief * The broadcastOperationMode function sends the current operation mode at * the prescribed interval. - * @details Inputs: broadcastModeIntervalCtr - * @details Outputs: HD operation mode broadcast message sent. + * @details \b Inputs: broadcastModeIntervalCtr + * @details \b Outputs: HD operation mode broadcast message sent. * @return none *************************************************************************/ static void broadcastOperationMode( void ) @@ -439,8 +445,8 @@ /*********************************************************************//** * @brief * The getConfirmationRequestStatus function returns the status of a confirmation request - * @details Inputs: confirmRequests[] - * @details Outputs: confirmRequests[] consumed/cleared if completed. + * @details \b Inputs: confirmRequests[] + * @details \b Outputs: confirmRequests[] consumed/cleared if completed. * @param requestID ID of confirmation being requested * @return Status of given confirmation *************************************************************************/ @@ -505,8 +511,8 @@ /*********************************************************************//** * @brief * The setConfirmationRequestStatus function sets the status of a confirmation request - * @details Inputs: confirmRequests[] - * @details Outputs: confirmRequests[]. + * @details \b Inputs: confirmRequests[] + * @details \b Outputs: confirmRequests[]. * @param requestID ID of confirmation being requested * @param status Status to set for given confirmation (open, close, reject) * @return none @@ -528,8 +534,8 @@ /*********************************************************************//** * @brief * The addConfirmationRequest function sends a confirmation request to UI - * @details Inputs: confirmRequests[] - * @details Outputs: confirmRequests[] new added. + * @details \b Inputs: confirmRequests[] + * @details \b Outputs: confirmRequests[] new added. * @param requestID ID of confirmation being requested * @param requestType Type of confirmation being requested (open, close, reject) * @param rejectReason Reason for reject if type is reject @@ -577,8 +583,8 @@ /*********************************************************************//** * @brief * The setCurrentSubState function sets the current subState. - * @details Inputs: subState - * @details Outputs: currentSubState + * @details \b Inputs: none + * @details \b Outputs: currentSubState * @param subState the enumerated sub state. * @return none *************************************************************************/ @@ -590,8 +596,8 @@ /*********************************************************************//** * @brief * The setCurrent4thLevelState function sets the current 4th level state. - * @details Inputs: state - * @details Outputs: current4thLevelState + * @details \b Inputs: none + * @details \b Outputs: current4thLevelState * @param subState the enumerated sub state. * @return none *************************************************************************/ @@ -604,9 +610,9 @@ * @brief * The sendOperationStatusEvent function constructs and sends an HD operation * status event. - * @details Inputs: currentMode, currentSubMode, currentSubState, current4thLevelState - * @details Outputs: dat1, dat2. - * @param none + * @details \b Message \b Sent: MSG_ID_TD_EVENT + * @details \b Inputs: currentMode, currentSubMode, currentSubState, current4thLevelState + * @details \b Outputs: none * @return none *************************************************************************/ void sendOperationStatusEvent( void ) @@ -637,8 +643,8 @@ * @brief * The testSetOperationMode function will transition to a given operation * mode if the transition is legal. - * @details Inputs: none - * @details Outputs: modeRequest[] + * @details \b Inputs: none + * @details \b Outputs: modeRequest[] * @param newMode ID of requested mode to transition to * @return TRUE if request successful, FALSE if not *************************************************************************/ @@ -665,8 +671,8 @@ * @brief * The testSetOpModePublishIntervalOverride function sets the override of the * operation mode publication interval. - * @details Inputs: none - * @details Outputs: opModePublishInterval + * @details \b Inputs: none + * @details \b Outputs: opModePublishInterval * @param ms milliseconds between operation mode broadcasts * @return TRUE if override set successful, FALSE if not *************************************************************************/ @@ -690,8 +696,8 @@ * @brief * The testResetOpModePublishIntervalOverride function resets the override of the * operation mode data publication interval. - * @details Inputs: none - * @details Outputs: opModePublishInterval + * @details \b Inputs: none + * @details \b Outputs: opModePublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetOpModePublishIntervalOverride( void ) Index: firmware/App/Modes/OperationModes.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,37 +23,42 @@ /** * @defgroup TDOperationModes TDOperationModes - * @brief Operation Modes module. + * @brief Operation Modes unit. * * @addtogroup TDOperationModes * @{ */ // ********** public definitions ********** -#define NO_SUB_STATE 0xFF ///< value for when submode does not have specific substates and is not applicable. +#define NO_SUB_STATE 0xFF ///< value for when submode does not have specific substates and is not applicable. /// Payload record structure for op mode broadcast message typedef struct { - U32 opMode; ///< Current operating mode - U32 subMode; ///< Current sub-mode of current operating mode + U32 opMode; ///< Current operating mode + U32 subMode; ///< Current sub-mode of current operating mode } OP_MODE_PAYLOAD_T; // ********** public function prototypes ********** -void initOperationModes( void ); // Initialize this module +void initOperationModes( void ); // Initialize this unit void execOperationModes( void ); // Execute the operation modes state machine (scheduled periodic call) + void requestNewOperationMode( TD_OP_MODE_T newMode ); // Request a transition to a new operation mode TD_OP_MODE_T getCurrentOperationMode( void ); // Get the current operation mode TD_OP_MODE_T getPreviousOperationMode( void ); // Get the previous operation mode U32 getCurrentSubMode( void ); // Get the current sub-mode + void initiateAlarmAction( ALARM_ACTION_T action ); // Initiate an alarm or alarm recovery action according to current op mode + CONFIRMATION_REQUEST_STATUS_T getConfirmationRequestStatus( GENERIC_CONFIRM_ID_T requestID ); // Get the current confirmation request status void setConfirmationRequestStatus( GENERIC_CONFIRM_ID_T requestID, CONFIRMATION_REQUEST_STATUS_T status ); // Set the confirmation request status GENERIC_CONFIRM_ID_T addConfirmationRequest( GENERIC_CONFIRM_ID_T requestID, GENERIC_CONFIRM_COMMAND_T requestType, U32 rejectReason ); // Add a new confirmation request + void setCurrentSubState( U32 subState ); // Set the current substate. void setCurrent4thLevelState( U32 state ); // Set the current 4th level state. + void sendOperationStatusEvent( void ); // Constructs and sends operation status event BOOL testSetOperationMode( TD_OP_MODE_T newMode ); // Force transition to a given mode (if allowed) Index: firmware/App/Monitors/FluidLeak.c =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Monitors/FluidLeak.c (.../FluidLeak.c) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Monitors/FluidLeak.c (.../FluidLeak.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -16,8 +16,8 @@ ***************************************************************************/ #include "TDCommon.h" +#include "FpgaTD.h" #include "FluidLeak.h" -//#include "FPGA.h" #include "Messaging.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -43,6 +43,7 @@ /// Interval (in ms) at which to publish fluid leak data to CAN bus. static OVERRIDE_U32_T fluidLeakStatePublishInterval = { FLUID_LEAK_PUB_INTERVAL, FLUID_LEAK_PUB_INTERVAL, 0, 0 }; + static OVERRIDE_U32_T fluidLeakState; ///< Detected fluid leak state for fluid leak detector. // ********** private function prototypes ********** @@ -51,9 +52,9 @@ /*********************************************************************//** * @brief - * The initFluidLeak function initializes the Fluid Leak module. - * @details Inputs: none - * @details Outputs: Fluid Leak module initialized. + * The initFluidLeak function initializes the Fluid Leak unit. + * @details \b Inputs: none + * @details \b Outputs: Fluid Leak unit initialized. * @return none *************************************************************************/ void initFluidLeak( void ) @@ -64,19 +65,20 @@ fluidLeakState.override = OVERRIDE_RESET; fluidLeakStatePublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; -// initPersistentAlarm( ALARM_ID_HD_FLUID_LEAK_DETECTED, 0, FLUID_LEAK_ERROR_PERSIST_MS ); +// initPersistentAlarm( ALARM_ID_TD_FLUID_LEAK_DETECTED, 0, FLUID_LEAK_ERROR_PERSIST_MS ); } /*********************************************************************//** * @brief * The execFluidLeak function executes the fluid leak monitor. - * @details Inputs: FPGA fluid leak state GPIO pin state - * @details Outputs: fluidLeakState + * @details \b Alarm: ALARM_ID_TD_FLUID_LEAK_DETECTED if fluid leak detected. + * @details \b Inputs: FPGA fluid leak state GPIO pin state + * @details \b Outputs: fluidLeakState * @return none *************************************************************************/ void execFluidLeak( void ) { - BOOL noFluidLeakDetected = TRUE;// = noFPGAFluidLeakDetected(); + BOOL noFluidLeakDetected = noFPGAFluidLeakDetected(); if ( getCurrentOperationMode() != MODE_INIT ) { @@ -93,9 +95,9 @@ // Check state reading and act upon if ( FLUID_LEAK_STATE_WET == getFluidLeakState() ) { -// if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_FLUID_LEAK_DETECTED, TRUE ) ) +// if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_TD_FLUID_LEAK_DETECTED, TRUE ) ) // { -// activateAlarmNoData( ALARM_ID_HD_FLUID_LEAK_DETECTED ); +// activateAlarmNoData( ALARM_ID_TD_FLUID_LEAK_DETECTED ); // } } else // FLUID_LEAK_STATE_DRY == getFluidLeakState() @@ -113,8 +115,8 @@ * @brief * The getFluidLeakState function gets the current reading for the fluid * leak detector. - * @details Inputs: fluidLeakState - * @details Outputs: none + * @details \b Inputs: fluidLeakState + * @details \b Outputs: none * @param none * @return the current fluid leak state. *************************************************************************/ @@ -132,9 +134,11 @@ /*********************************************************************//** * @brief - * The publishFluidLeakState function publishes fluid leak state at the set interval. - * @details Inputs: fluidLeakState - * @details Outputs: if broadcast is due, send fluid leak state + * The publishFluidLeakState function publishes fluid leak state at the set + * interval. + * @details \b Message \b Sent: MSG_ID_TD_FLUID_LEAK_STATE_DATA if time to publish fluid leak sensor data. + * @details \b Inputs: fluidLeakState, fluidLeakStatePublicationTimerCounter + * @details \b Outputs: fluidLeakStatePublicationTimerCounter * @return none *************************************************************************/ static void publishFluidLeakState( void ) @@ -161,8 +165,8 @@ * @brief * The testSetFluidLeakStatePublishIntervalOverride function overrides the * fluid leak state publish interval. - * @details Inputs: none - * @details Outputs: fluidLeakStatePublishInterval + * @details \b Inputs: none + * @details \b Outputs: fluidLeakStatePublishInterval * @param value override fluid leak state publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -186,8 +190,8 @@ * @brief * The testResetFluidLeakStatePublishIntervalOverride function resets the override * of the fluid leak state publish interval. - * @details Inputs: none - * @details Outputs: fluidLeakStatePublishInterval + * @details \b Inputs: none + * @details \b Outputs: fluidLeakStatePublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetFluidLeakStatePublishIntervalOverride( void ) @@ -208,8 +212,8 @@ * @brief * The testSetFluidLeakStateOverride function overrides the state * of the fluid leak detector. - * @details Inputs: none - * @details Outputs: fluidLeakState + * @details \b Inputs: none + * @details \b Outputs: fluidLeakState * @param none * @param state override fluid leak detector with this * @return TRUE if override successful, FALSE if not @@ -235,8 +239,8 @@ * @brief * The testResetFluidLeakStateOverride function resets the override of the * fluid leak detector. - * @details Inputs: none - * @details Outputs: fluidLeakState + * @details \b Inputs: none + * @details \b Outputs: fluidLeakState * @param none * @return TRUE if reset successful, FALSE if not *************************************************************************/ Index: firmware/App/Monitors/FluidLeak.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Monitors/FluidLeak.h (.../FluidLeak.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Monitors/FluidLeak.h (.../FluidLeak.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,10 +22,8 @@ /** * @defgroup FluidLeak FluidLeak - * @brief Fluid Leak detector monitor module. Monitors the - * fluid leak detector. - * - * SMD Fluid Controls - OS3 Industrial Optical Float Switch Part No. OS3-C2 10D3 003 + * @brief Fluid Leak detector monitor unit. Monitors the fluid leak detector. + * Mfg by SMD Fluid Controls: OS3 Industrial Optical Float Switch Part No. OS3-C2 10D3 003 * * @addtogroup FluidLeak * @{ Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r68d1bb7585a72c6d46608bb7d84da14220b78796 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 68d1bb7585a72c6d46608bb7d84da14220b78796) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -102,6 +102,8 @@ SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_GET_RANK = 71, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR_COND = 72, SW_FAULT_ID_INVALID_ALARM_ID_REFERENCED3 = 73, + SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX1 = 74, + SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX2 = 74, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/AlarmMgmtTD.c =================================================================== diff -u -r68d1bb7585a72c6d46608bb7d84da14220b78796 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision 68d1bb7585a72c6d46608bb7d84da14220b78796) +++ firmware/App/Services/AlarmMgmtTD.c (.../AlarmMgmtTD.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -159,9 +159,9 @@ /*********************************************************************//** * @brief - * The initAlarmMgmtTD function initializes the AlarmMgmt module. + * The initAlarmMgmtTD function initializes the AlarmMgmt unit. * @details Inputs: none - * @details Outputs: AlarmMgmtTD module initialized. + * @details Outputs: AlarmMgmtTD unit initialized. * @return none *************************************************************************/ void initAlarmMgmtTD( void ) Index: firmware/App/Services/AlarmMgmtTD.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Services/AlarmMgmtTD.h (.../AlarmMgmtTD.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -24,7 +24,7 @@ /** * @defgroup AlarmManagementTD AlarmManagementTD - * @brief Alarm Management service module for TD firmware. Provides general + * @brief Alarm Management service unit for TD firmware. Provides general * alarm managementfunctionality including support functions for triggering * and clearingspecific alarms. * Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -15,11 +15,10 @@ * ***************************************************************************/ -#include -#include #include // For memcpy() #include "CommBuffers.h" +#include "Messaging.h" #include "SystemCommTD.h" #include "Timers.h" @@ -30,16 +29,16 @@ // ********** private definitions ********** -#define COMM_BUFFER_LENGTH 768 ///< Max bytes in each comm buffer (each side of double buffer is this size) -#define DOUBLE_BUFFERS 2 ///< Need 2 buffers for double buffering -#define BUFFER_OVERFLOW_PERSISTENCE_MS 5000 ///< How many ms buffer overflows must persist before fault +#define COMM_BUFFER_LENGTH 768 ///< Max bytes in each comm buffer (each side of double buffer is this size) +#define DOUBLE_BUFFERS 2 ///< Need 2 buffers for double buffering +#define BUFFER_OVERFLOW_PERSISTENCE_MS 5000 ///< How many ms buffer overflows must persist before fault // ********** private data ********** -static volatile U32 commBufferByteCount[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ]; ///< For each buffer, how many bytes does it contain? (also index to next available) -static volatile U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; ///< For each buffer, which double buffer is being fed right now? -static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; ///< Each is double buffered to avoid thread contention -static U32 firstBufferOverflowTimeStamp = 0; ///< Time stamp of a prior overflow event - allows for an overflow persistence check +static volatile U32 commBufferByteCount[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ]; ///< For each buffer, how many bytes does it contain? (also index to next available) +static volatile U32 activeDoubleBuffer[ NUM_OF_COMM_BUFFERS ]; ///< For each buffer, which double buffer is being fed right now? +static U08 commBuffers[ NUM_OF_COMM_BUFFERS ][ DOUBLE_BUFFERS ][ COMM_BUFFER_LENGTH ]; ///< Each is double buffered to avoid thread contention +static U32 firstBufferOverflowTimeStamp = 0; ///< Time stamp of a prior overflow event - allows for an overflow persistence check // ********** private function prototypes ********** @@ -48,9 +47,9 @@ /*********************************************************************//** * @brief - * The initCommBuffers function initializes the CommBuffers module. + * The initCommBuffers function initializes the CommBuffers unit. * @details Inputs: none - * @details Outputs: CommBuffers module initialized. + * @details Outputs: CommBuffers unit initialized. * @return none *************************************************************************/ void initCommBuffers( void ) @@ -67,11 +66,11 @@ /*********************************************************************//** * @brief * The clearBuffer function clears (empties) a given buffer. - * Caller should ensure buffer won't be used while this function is clearing - * the buffer. + * @note This function is thread safe. IRQ interrupts are disabled while + * buffers are being cleared. * @details Inputs: none * @details Outputs: given buffer is cleared. - * @param buffer the buffer to clear + * @param buffer ID of the buffer to clear * @return none *************************************************************************/ void clearBuffer( COMM_BUFFER_T buffer ) @@ -97,16 +96,18 @@ /*********************************************************************//** * @brief - * The addToCommBuffer function adds data of specified length to a specified - * communication buffer. S/W fault if buffer too full to add data. - * This function will always add to the active double buffer. - * This function should only be called from the background, general, or - * priority tasks (BG or IRQ) for thread safety. + * The addToCommBuffer function adds data of specified length to a given + * communication buffer. + * @note This function will add to the active side of the double buffer. + * @note This function is thread safe. IRQ interrupts are disabled during + * buffer operations. + * @details Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer is invalid or + * it is full. * @details Inputs: commBufferByteCount[], activeDoubleBuffer[] * @details Outputs: commBuffers[], commBufferByteCount[] - * @param buffer which comm buffer to add data to - * @param data pointer to byte array containing data to add - * @param len length of data (in bytes) + * @param buffer ID of buffer to add data to + * @param data Pointer to byte array containing data to add to buffer + * @param len Length of data (in bytes) * @return TRUE if data added to buffer successfully, FALSE if not *************************************************************************/ BOOL addToCommBuffer( COMM_BUFFER_T buffer, U08* data, U32 len ) @@ -186,19 +187,20 @@ /*********************************************************************//** * @brief - * The getFromCommBuffer function fills a given byte array with a given + * The getFromCommBuffer function fills a given byte array with a specified * number of bytes from a given buffer and returns the number of bytes - * retrieved from the buffer. This function will draw from the inactive - * double buffer first and, if needed, switch double buffers to draw the - * rest of the requested data. - * Only one function in one thread should be calling this function for a given - * buffer. + * retrieved from the buffer. + * @note This function will draw from the inactive side of the double buffer + * and, if needed, switch double buffers to draw the rest of the requested data. + * @note This function is thread safe. IRQ interrupts are disabled during buffer + * operations. + * @details Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer is invalid. * @details Inputs: commBuffers[], commBufferByteCount[], activeDoubleBuffer[] * @details Outputs: commBuffers[], commBufferByteCount[], activeDoubleBuffer[], * and the given data array is populated with data from the buffer. - * @param buffer which comm buffer to retrieve data from - * @param data pointer to byte array to stuff data into - * @param len number of bytes to retrieve into given data array. + * @param buffer ID of buffer to retrieve data from + * @param data Pointer to byte array to populate with buffer data + * @param len Number of bytes to retrieve from buffer into given byte array. * @return the number of bytes retrieved. *************************************************************************/ U32 getFromCommBuffer( COMM_BUFFER_T buffer, U08* data, U32 len ) @@ -247,16 +249,17 @@ /*********************************************************************//** * @brief * The peekFromCommBuffer function fills a given byte array with a given - * number of bytes from a given buffer. This function does NOT consume - * the bytes - it only peeks at them. A call to numberOfBytesInCommBuffer() - * should be made before calling this function to determine how many bytes - * are currently in the buffer. Do not call this function with a "len" - * longer than what is currently in the buffer. + * number of bytes from a given buffer. + * @note This function does NOT consume the bytes - it only peeks at them. + * A call to numberOfBytesInCommBuffer() should be made prior to calling + * this function to determine how many bytes are currently in the buffer. + * @warning Do not call this function with a "len" greater than the number + * of bytes currently in the buffer. * @details Inputs: commBuffers[], commBufferByteCount[], activeDoubleBuffer[] * @details Outputs: given array populated with requested number of bytes from the buffer. - * @param buffer which comm buffer to retrieve data from - * @param data pointer to byte array to stuff data into - * @param len number of bytes to retrieve into given data array. + * @param buffer ID of buffer to retrieve data from + * @param data Pointer to byte array to populate with buffer data + * @param len Number of bytes to retrieve from the given buffer. * @return the number of bytes retrieved. *************************************************************************/ U32 peekFromCommBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ) @@ -304,12 +307,13 @@ /*********************************************************************//** * @brief * The numberOfBytesInCommBuffer function determines how many bytes - * are currently contained in a given comm buffer. Both double buffers - * are considered for this. + * are currently contained in a given comm buffer. Both sides of the + * double buffers are considered for this. + * @details Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer is invalid. * @details Inputs: activeDoubleBuffer[], commBufferByteCount[] * @details Outputs: none - * @param buffer which comm buffer to get byte count for - * @return the number of bytes in the given comm buffer. + * @param buffer ID of buffer to get byte count for + * @return the number of bytes currently in the given comm buffer. *************************************************************************/ U32 numberOfBytesInCommBuffer( COMM_BUFFER_T buffer ) { @@ -333,14 +337,15 @@ /*********************************************************************//** * @brief - * The switchDoubleBuffer function switches the active and inactive buffers - * for the given buffer. - * This function should only be called when the current inactive buffer has - * been emptied. Any unconsumed data in inactive buffer will be lost. + * The switchDoubleBuffer function switches the active and inactive sides + * of the given buffer. + * @warning This function should only be called when the current inactive + * buffer has been emptied. Any unconsumed data in inactive buffer will be + * lost. * @details Inputs: activeDoubleBuffer[] * @details Outputs: activeDoubleBuffer[], commBufferByteCount[] - * @param buffer which comm buffer to switch double buffers on - * @return the new active buffer for the given buffer. + * @param buffer ID of buffer to switch double buffers + * @return the new active side of the given double buffer (0 or 1) *************************************************************************/ static U32 switchDoubleBuffer( COMM_BUFFER_T buffer ) { @@ -359,13 +364,15 @@ /*********************************************************************//** * @brief * The getDataFromInactiveBuffer function retrieves a given number of bytes - * from the inactive buffer of a given buffer. This function should only be - * called by getFromCommBuffer(). Params will be pre-validated there. + * from the inactive side of a given buffer. + * @warning This function should only be called by getFromCommBuffer(). + * Parameters will be pre-validated there. * @details Inputs: commBuffers[], activeDoubleBuffer[], commBufferByteCount[] * @details Outputs: commBuffers[], activeDoubleBuffer[], commBufferByteCount[] - * @param buffer which comm buffer get data from - * @param data pointer to byte array to populate with data - * @param len number of bytes to get from comm buffer + * @param buffer ID of buffer to get data from inactive side of + * @param data Pointer to byte array to populate with data from inactive + * side of buffer + * @param len Number of bytes to get from the buffer * @return none *************************************************************************/ static void getDataFromInactiveBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ) Index: firmware/App/Services/CommBuffers.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/CommBuffers.h (.../CommBuffers.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Services/CommBuffers.h (.../CommBuffers.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -18,11 +18,11 @@ #ifndef __COMM_BUFFERS_H__ #define __COMM_BUFFERS_H__ -#include "../TDCommon.h" +#include "TDCommon.h" /** * @defgroup CommBuffers CommBuffers - * @brief The communication buffers module provides buffering services for + * @brief The communication buffers unit provides buffering services for * incoming and outgoing CAN data. A separate buffer is provided for each * CAN ID (channel) so that frame order is maintained for a given channel. * @@ -36,20 +36,20 @@ typedef enum Comm_Buffers { COMM_BUFFER_NOT_USED = 0, ///< CAN message boxes start at 1 so we will not use this buffer - COMM_BUFFER_OUT_CAN_TD_ALARM, ///< Buffer for outgoing HD alarm messages + COMM_BUFFER_OUT_CAN_TD_ALARM, ///< Buffer for outgoing TD alarm messages COMM_BUFFER_IN_CAN_DD_ALARM, ///< Buffer for incoming DD alarm messages COMM_BUFFER_IN_CAN_RO_ALARM, ///< Buffer for incoming RO alarm messages COMM_BUFFER_IN_CAN_UI_ALARM, ///< Buffer for incoming UI alarm messages - COMM_BUFFER_OUT_CAN_TD_2_DD, ///< Buffer for outgoing HD to DD messages + COMM_BUFFER_OUT_CAN_TD_2_DD, ///< Buffer for outgoing TD to DD messages COMM_BUFFER_IN_CAN_DD_2_TD, ///< Buffer for incoming DD to HD messages - COMM_BUFFER_OUT_CAN_TD_2_UI, ///< Buffer for outgoing HD to UI messages - COMM_BUFFER_IN_CAN_UI_2_TD, ///< Buffer for incoming UI to HD messages - COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for outgoing HD broadcast messages + COMM_BUFFER_OUT_CAN_TD_2_UI, ///< Buffer for outgoing TD to UI messages + COMM_BUFFER_IN_CAN_UI_2_TD, ///< Buffer for incoming UI to TD messages + COMM_BUFFER_OUT_CAN_TD_BROADCAST, ///< Buffer for outgoing TD broadcast messages COMM_BUFFER_IN_CAN_DD_BROADCAST, ///< Buffer for incoming DD broadcast messages COMM_BUFFER_IN_CAN_RO_BROADCAST, ///< Buffer for incoming RO broadcast messages COMM_BUFFER_IN_CAN_UI_BROADCAST, ///< Buffer for incoming UI broadcast messages - COMM_BUFFER_IN_CAN_PC, ///< Buffer for incoming PC to HD messages - COMM_BUFFER_OUT_CAN_PC, ///< Buffer for outgoing HD to PC messages + COMM_BUFFER_IN_CAN_PC, ///< Buffer for incoming PC to TD messages + COMM_BUFFER_OUT_CAN_PC, ///< Buffer for outgoing TD to PC messages NUM_OF_COMM_BUFFERS ///< Number of CAN communication buffers } COMM_BUFFER_T; Index: firmware/App/Services/CpldInterface.c =================================================================== diff -u -r772fdd144e4006fada12a2e91519378b29d54bae -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/CpldInterface.c (.../CpldInterface.c) (revision 772fdd144e4006fada12a2e91519378b29d54bae) +++ firmware/App/Services/CpldInterface.c (.../CpldInterface.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -62,10 +62,11 @@ /*********************************************************************//** * @brief - * The initCPLD function initializes the CPLD module. All outputs to CPLD - * (watchdog pet, off request, and alarm lamp LEDs) are set to low. - * @details Inputs: none - * @details Outputs: CPLD module signal outputs set to initial states. + * The initCPLD function initializes the CPLD unit. All outputs to CPLD + * (watchdog pet,power off request, alarm lamp LEDs and safety shutdown) + * are set to low. + * @details \b Inputs: none + * @details \b Outputs: CPLD unit signal outputs set to initial states. * @return none *************************************************************************/ void initCPLD( void ) @@ -93,8 +94,8 @@ /*********************************************************************//** * @brief * The toggleCPLDWatchdog function toggles the watchdog pet signal to CPLD. - * @details Inputs: none - * @details Outputs: watchdog pet signal toggled. + * @details \b Inputs: none + * @details \b Outputs: watchdog pet signal toggled. * @return none *************************************************************************/ void toggleCPLDWatchdog( void ) @@ -104,13 +105,13 @@ /*********************************************************************//** * @brief - * The getCPLDWatchdogExpired function determines the current signal level - * on the watchdog expired pin from the CPLD. - * @details Inputs: Signal from CPLD on watchdog expired pin. - * @details Outputs: none - * @return level (LOW or HIGH) + * The getCPLDSafety function determines the current signal level for the + * safety shutdown pin from the CPLD. + * @details \b Inputs: Signal from CPLD on safety input pin. + * @details \b Outputs: none + * @return level of safety line (LOW=active or HIGH=inactive) *************************************************************************/ -PIN_SIGNAL_STATE_T getCPLDWatchdogExpired( void ) +PIN_SIGNAL_STATE_T getCPLDSafety( void ) { PIN_SIGNAL_STATE_T level = getSafetySignal(); @@ -121,8 +122,8 @@ * @brief * The getCPLDACPowerLossDetected function determines whether the CPLD is * reporting A/C power has been lost. - * @details Inputs: Signal from CPLD on A/C presence pin. - * @details Outputs: none + * @details \b Inputs: Signal from CPLD on A/C presence pin (LOW=AC Power Lost). + * @details \b Outputs: none * @return TRUE if A/C power loss is detected, FALSE if not *************************************************************************/ BOOL getCPLDACPowerLossDetected( void ) @@ -137,9 +138,9 @@ * @brief * The setCPLDLampGreen function sets the alarm lamp green signal to CPLD * to given level. - * @details Inputs: none - * @details Outputs: alarm lamp green signal set to given level. - * @param level LOW or HIGH + * @details \b Inputs: none + * @details \b Outputs: alarm lamp green signal set to given level. + * @param level LOW (green off) or HIGH (green on) * @return none *************************************************************************/ void setCPLDLampGreen( PIN_SIGNAL_STATE_T level ) @@ -158,9 +159,9 @@ * @brief * The setCPLDLampBlue function sets the alarm lamp blue signal to CPLD * to given level. - * @details Inputs: none - * @details Outputs: alarm lamp blue signal set to given level. - * @param level LOW or HIGH + * @details \b Inputs: none + * @details \b Outputs: alarm lamp blue signal set to given level. + * @param level LOW (blue off) or HIGH (blue on) * @return none *************************************************************************/ void setCPLDLampBlue( PIN_SIGNAL_STATE_T level ) @@ -179,9 +180,9 @@ * @brief * The setCPLDLampRed function sets the alarm lamp red signal to CPLD * to given level. - * @details Inputs: none - * @details Outputs: alarm lamp red signal set to given level. - * @param level LOW or HIGH + * @details \b Inputs: none + * @details \b Outputs: alarm lamp red signal set to given level. + * @param level LOW (red off) or HIGH (red on) * @return none *************************************************************************/ void setCPLDLampRed( PIN_SIGNAL_STATE_T level ) @@ -202,8 +203,8 @@ * The off request signal must be toggled 4 times, once every 50 ms, in order * for the CPLD to accept the off request sequence and initiate system power * down. - * @details Inputs: none - * @details Outputs: off request signal toggled. + * @details \b Inputs: none + * @details \b Outputs: off request signal toggled. * @return none *************************************************************************/ void toggleCPLDOffRequest( void ) @@ -215,9 +216,9 @@ * @brief * The getCPLDOffButton function determines the current signal level * on the off button pin from the CPLD. - * @details Inputs: Signal from CPLD on off button pin. - * @details Outputs: none - * @return level (LOW or HIGH) + * @details \b Inputs: Signal from CPLD on off button pin. + * @details \b Outputs: none + * @return level (LOW=released or HIGH=depressed) *************************************************************************/ PIN_SIGNAL_STATE_T getCPLDOffButton( void ) { @@ -230,9 +231,9 @@ * @brief * The getCPLDStopButton function determines the current signal level * on the stop button pin from the CPLD. - * @details Inputs: Signal from CPLD on off button pin. - * @details Outputs: none - * @return level (LOW or HIGH) + * @details \b Inputs: Signal from CPLD on stop button pin. + * @details \b Outputs: none + * @return level (LOW=released or HIGH=depressed) *************************************************************************/ PIN_SIGNAL_STATE_T getCPLDStopButton( void ) { @@ -244,24 +245,29 @@ /*********************************************************************//** * @brief * The activateSafetyShutdown function activates the safety shutdown signal. - * @details Inputs: none - * @details Outputs: Safety Shutdown signal output set to active state. + * @details \b Message \b Sent: MSG_ID_TD_EVENT for software activated safety + * shutdown event. + * @details \b Inputs: none + * @details \b Outputs: safetyShutdownActivated, Safety Shutdown signal output + * set to active state. * @return none *************************************************************************/ void activateSafetyShutdown( void ) { safetyShutdownActivated = TRUE; setSafetyShutdownSignal(); -// SEND_EVENT_WITH_2_U32_DATA( HD_EVENT_SAFETY_LINE, 1, 0 ) + SEND_EVENT_WITH_2_U32_DATA( TD_EVENT_SAFETY_LINE, 1, 0 ) } /*********************************************************************//** * @brief * The isSafetyShutdownActivated function returns whether the safety shutdown - * signal has been activated. - * @details Inputs: none - * @details Outputs: none - * @return safetyShutdownActivated + * signal has been activated by software. + * @note The safety shutdown signal can also be activated by other causes + * (e.g. watchdog expiration). + * @details \b Inputs: safetyShutdownActivated + * @details \b Outputs: none + * @return TRUE if software has activated safety shutdown, FALSE if not *************************************************************************/ BOOL isSafetyShutdownActivated( void ) { @@ -273,8 +279,10 @@ * The execSafetyShutdownTest function executes the safety shutdown test. * This function should be called periodically until a pass or fail * result is returned. - * @details Inputs: safetyShutdownSelfTestState - * @details Outputs: safetyShutdownSelfTestState + * @details \b Alarm: ALARM_ID_HD_SAFETY_SHUTDOWN_POST_TEST_FAILED if self-test fails. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if self-test state is invalid. + * @details \b Inputs: safetyShutdownSelfTestState + * @details \b Outputs: safetyShutdownSelfTestState * @return in progress, passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execSafetyShutdownTest( void ) @@ -358,8 +366,8 @@ /*********************************************************************//** * @brief * The resetSafetyShutdownPOSTState function resets safety shutdown POST state. - * @details Inputs: none - * @details Outputs: safetyShutdownSelfTestState + * @details \b Inputs: none + * @details \b Outputs: safetyShutdownSelfTestState * @return none *************************************************************************/ void resetSafetyShutdownPOSTState( void ) @@ -369,10 +377,10 @@ /*********************************************************************//** * @brief - * The testSetSafetyShutdownOverride function overrides the HD safety + * The testSetSafetyShutdownOverride function overrides the safety * shutdown. - * @details Inputs: none - * @details Outputs: HD safety shutdown overridden + * @details \b Inputs: none + * @details \b Outputs: HD safety shutdown overridden * @param value TRUE to activate safety shutdown, FALSE to de-activate it. * @return TRUE if override successful, FALSE if not *************************************************************************/ @@ -403,9 +411,9 @@ /*********************************************************************//** * @brief * The testResetSafetyShutdownOverride function resets the override of the - * HD safety shutdown. - * @details Inputs: none - * @details Outputs: shutdown override reset + * safety shutdown. + * @details \b Inputs: none + * @details \b Outputs: shutdown override reset * @return TRUE if override reset successful, FALSE if not *************************************************************************/ BOOL testResetSafetyShutdownOverride( void ) Index: firmware/App/Services/CpldInterface.h =================================================================== diff -u -r772fdd144e4006fada12a2e91519378b29d54bae -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/CpldInterface.h (.../CpldInterface.h) (revision 772fdd144e4006fada12a2e91519378b29d54bae) +++ firmware/App/Services/CpldInterface.h (.../CpldInterface.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -22,7 +22,7 @@ /** * @defgroup CPLD_Interface CPLD_Interface - * @brief The CPLD interface module provides functions to interface with the + * @brief The CPLD interface unit provides functions to interface with the * CPLD (watchdog, safety, alarm lamp, off/stop buttons, power off request). * * @addtogroup CPLD_Interface @@ -42,7 +42,7 @@ void initCPLD( void ); void toggleCPLDWatchdog( void ); -PIN_SIGNAL_STATE_T getCPLDWatchdogExpired( void ); +PIN_SIGNAL_STATE_T getCPLDSafety( void ); void setCPLDLampGreen( PIN_SIGNAL_STATE_T level ); void setCPLDLampBlue( PIN_SIGNAL_STATE_T level ); Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -56,9 +56,9 @@ /*********************************************************************//** * @brief - * The initDDInterface function initializes the DDInterface module. - * @details Inputs: none - * @details Outputs: DDInterface module initialized. + * The initDDInterface function initializes the DDInterface unit. + * @details \b Inputs: none + * @details \b Outputs: DDInterface unit initialized. * @return none *************************************************************************/ void initDDInterface( void ) @@ -84,12 +84,15 @@ /**********************************************************************//** * @brief - * The checkDGDataFreshness function checks the condition - * for triggering an alarm if the DG fresh data is not received for 2 seconds. - * @details Inputs: none - * @details Outputs: an alarm is triggered or an alarm condition is cleared + * The checkDGDataFreshness function checks the freshness of data coming from + * the DD sub-system. + * @details \b Alarm: Given alarm is triggered if DD is communicating but has + * not published new data for too long. + * @details \b Inputs: DD communicating flag + * @details \b Outputs: none * @param alarm ID of alarm to check - * @param flag to signal the fresh data processing + * @param dgFreshDataFlag Pointer to flag indicating whether new data has been + * received since last time this function has seen it. * @return None *************************************************************************/ static void checkDGDataFreshness( ALARM_ID_T alarmID, BOOL *dgFreshDataFlag ) @@ -114,27 +117,22 @@ /*********************************************************************//** * @brief - * The execDGInterfaceMonitor function executes the DG Interface monitoring - * function. Ensures DG is sending fresh data in a timely manner. - * @details Inputs: dgLoadCellDataFreshFlag, dgDialysateTemperatureDataFreshFlag, - * dgReservoirsDataFreshFlag, dgOpModeDataFreshFlag - * @details Outputs: dgLoadCellDataFreshFlag, dgDialysateTemperatureDataFreshFlag, - * dgReservoirsDataFreshFlag, dgOpModeDataFreshFlag + * The execDGInterfaceMonitor function executes the DD Interface monitoring + * function. Ensures DD is sending fresh data in a timely manner. + * @details \b Inputs: ddOpModeDataFreshFlag + * @details \b Outputs: ddOpModeDataFreshFlag * @return none *************************************************************************/ void execDDInterfaceMonitor( void ) { // if ( getCPLDACPowerLossDetected() != TRUE ) { - // Trigger alarm if not receiving new dialysate temperature data message in timely manner -// checkDGDataFreshness( ALARM_ID_HD_NEW_DIALYSATE_TEMP_DATA_MESSAGE_NOT_RECEIVE, &dgDialysateTemperatureDataFreshFlag ); - - // Trigger alarm if not receiving new DG op mode message in timely manner -// checkDGDataFreshness( ALARM_ID_HD_DG_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &dgOpModeDataFreshFlag ); -// if ( TRUE == isAlarmActive( ALARM_ID_HD_DG_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE ) ) + // Trigger alarm if not receiving new DD op mode message in timely manner +// checkDDDataFreshness( ALARM_ID_TD_DD_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE, &ddOpModeDataFreshFlag ); +// if ( TRUE == isAlarmActive( ALARM_ID_TD_DD_NEW_OPERATION_MODE_MESSAGE_NOT_RECEIVE ) ) // { -// // we don't want to keep thinking DG is in a useful mode - set it to fault mode until DG is able to report its' true mode status -// setDGOpMode( DG_MODE_FAUL, 0 ); +// // we don't want to keep thinking DD is in a useful mode - set it to fault mode until DD is able to report its' true mode status +// setDDOpMode( DD_MODE_FAUL, 0 ); // } // Check to see if DD has restarted @@ -144,10 +142,10 @@ /*********************************************************************//** * @brief - * The getDDOpMode function gets the current DD operating mode. - * @details Inputs: ddCurrentOpMode - * @details Outputs: none - * @return Current DD operating mode. + * The getDDOpMode function gets the current latest reported DD operating mode. + * @details \b Inputs: ddCurrentOpMode + * @details \b Outputs: none + * @return Latest reported DD operating mode. *************************************************************************/ DD_OP_MODE_T getDDOpMode( void ) { @@ -156,10 +154,10 @@ /*********************************************************************//** * @brief - * The getDGSubMode function gets the current DG operating sub-mode. - * @details Inputs: dgSubMode - * @details Outputs: none - * @return Current DG operating sub-mode. + * The getDGSubMode function gets the latest reported DD operating sub-mode. + * @details \b Inputs: ddSubMode + * @details \b Outputs: none + * @return Latest reported DD operating sub-mode. *************************************************************************/ U32 getDDSubMode( void ) { @@ -168,12 +166,13 @@ /*********************************************************************//** * @brief - * The setDGOpMode function sets the latest DG operating mode reported by - * the DG. - * @details Inputs: none - * @details Outputs: dgCurrentOpMode, dgSubMode, dgOpModeDataFreshFlag - * @param opMode operating mode reported by DG - * @param subMode sub-mode (current state) of operating mode reported by DG + * The setDDOpMode function sets the latest DD operating mode reported by + * the DD (called by DD published message handler). + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if reported DD mode is invalid. + * @details \b Inputs: none + * @details \b Outputs: ddCurrentOpMode, ddSubMode, ddOpModeDataFreshFlag + * @param opMode The operating mode reported by DD + * @param subMode The sub-mode of operating mode reported by DD * @return none *************************************************************************/ void setDDOpMode( U32 opMode, U32 subMode ) @@ -200,9 +199,13 @@ /*********************************************************************//** * @brief * The handleDDCommandResponse function processes the latest DD command response. - * @details Inputs: none - * @details Outputs: process command response from DD - * @param ddCmdRespPtr pointer to DD command response data record + * @details \b Alarm: ALARM_ID_TD_DD_COMMAND_INVALID_PARAMETER_FAULT if reported + * response indicates DD rejected command due to invalid parameter. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if reported response is to an + * invalid command. + * @details \b Inputs: none + * @details \b Outputs: ddCmdResp[] + * @param ddCmdRespPtr Pointer to the received DD command response * @return none *************************************************************************/ void handleDDCommandResponse( DD_CMD_RESPONSE_T *ddCmdRespPtr ) @@ -224,14 +227,13 @@ switch ( ddCmdRespPtr->rejectCode ) { case DD_CMD_REQUEST_REJECT_REASON_INVALID_PARAMETER: -// SET_ALARM_WITH_1_U32_DATA( ALARM_ID_HD_DG_COMMAND_INVALID_PARAMETER_FAULT, ddCmdRespPtr->commandID ); +// SET_ALARM_WITH_1_U32_DATA( ALARM_ID_TD_DD_COMMAND_INVALID_PARAMETER_FAULT, ddCmdRespPtr->commandID ); break; case DD_CMD_REQUEST_REJECT_REASON_NONE: case DD_CMD_REQUEST_REJECT_REASON_INVALID_MODE: default: - // Our state machines will detect and handle DG mode out of sync - // TODO Consider a generic handler for all state machine + // Our state machines will detect and handle DD mode out of sync break; } } @@ -240,11 +242,13 @@ /*********************************************************************//** * @brief * The getDDCommandResponse function gets the latest command response from DD. - * @details Inputs: ddCmdResp - * @details Outputs: none - * @param commandID id of specific interested command response - * @param cmdRespPtr pointer to data record to copy DD command response to - * @return TRUE if a specific command response has been received, otherwise FALSE + * @details \b Inputs: ddCmdResp[] + * @details \b Outputs: cmdRespPtr reference variable is set to the received + * command response. + * @param commandID ID of specific command that caller wants a response to + * @param cmdRespPtr Pointer to command response record to populate with received + * response + * @return TRUE if a response was received for the given command, FALSE if not. *************************************************************************/ BOOL getDDCommandResponse( U32 commandID, DD_CMD_RESPONSE_T *cmdRespPtr ) { @@ -261,10 +265,11 @@ /*********************************************************************//** * @brief - * The checkDDRestart function checks to see if DD has restarted after started - * by TD and triggers appropriate alarm. - * @details Inputs: ddStartCommandSent, ddStarted, ddCurrentOpMode - * @details Outputs: ddStartCommandSent, ddStarted, triggers a fault alarm if DD restarted + * The checkDDRestart function checks to see if the DD sub-system has restarted + * after an operation was started by TD. + * @details \b Alarm: ALARM_ID_TD_DD_RESTARTED_FAULT if DD has restarted unexpectedly. + * @details \b Inputs: ddStartCommandSent, ddStarted, ddCurrentOpMode + * @details \b Outputs: ddStartCommandSent, ddStarted * @return none *************************************************************************/ static void checkDDRestart( void ) @@ -280,7 +285,7 @@ // if ( ( DG_MODE_FAUL != ddCurrentOpMode ) && ( DG_MODE_GEND != ddCurrentOpMode ) && // ( DG_MODE_FILL != ddCurrentOpMode ) && ( DG_MODE_DRAI != ddCurrentOpMode ) ) // { -// activateAlarmNoData( ALARM_ID_HD_DG_RESTARTED_FAULT ); +// activateAlarmNoData( ALARM_ID_TD_DD_RESTARTED_FAULT ); // ddStarted = FALSE; // do not want to re-trigger alarm after alarm is cleared // } // } Index: firmware/App/Services/DDInterface.h =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,7 +23,7 @@ /** * @defgroup DDInterface DDInterface - * @brief DDG interface/monitor module. Interfaces with and monitors the + * @brief DD interface & monitor unit. Interfaces with and monitors the * DD (dialysate delivery) sub-system. * * @addtogroup DDInterface Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r01892698468068bb97a80a84c96a6d7c5d6fde9b -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 01892698468068bb97a80a84c96a6d7c5d6fde9b) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -37,14 +37,41 @@ // ********** private definitions ********** -#define FPGA_EXPECTED_ID 0x5A ///< Expected ID for HD FPGA. +#define FPGA_EXPECTED_ID 0x5A ///< Expected ID for HD FPGA. -#define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. +#define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. -#define MAX_FPGA_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< FPGA comm failures window -#define MAX_FPGA_COMM_FAILURES 3 ///< FPGA maximum comm failures per MAX_FPGA_COMM_FAILURES_WINDOW_MS -#define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up +#define MAX_FPGA_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< FPGA comm failures window +#define MAX_FPGA_COMM_FAILURES 3 ///< FPGA maximum comm failures per MAX_FPGA_COMM_FAILURES_WINDOW_MS +#define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up +#define FPGA_FLUID_LEAK_STATE_MASK 0x0040 ///< Bit mask for fluid leak detector. + +#define FPGA_VALVES_MIN_PWM_MODE_COUNT 2500 ///< FPGA valves minimum PWM in PWM mode in counts. + +#define FPGA_INPUT_VOLTAGE_SCALE 3.0F ///< FPGA source and aux voltage. +#define FPGA_PVN_VOLTAGE_SCALE 1.0F ///< FPGA pvn voltage. + +#define FPGA_ALARM_AUDIO_VOLUME_SHIFT 3 ///< Shift alarm audio volume 3 bits to left before writing to register. +#define FPGA_ALARM_AUDIO_DIVIDE_SHIFT 6 ///< Shift alarm audio volume divider 6 bits to left before writing to register. + +#define FPGA_BACKUP_ALARM_AUDIO_CONVERT 0.4F ///< Converts backup (piezo) alarm audio ADC volts to amps. + +#define FRONT_DOOR_SWITCH_MASK 0x0010 ///< Front door switch bit mask. Bit 4 of the GPIO register. +#define PUMP_TRACK_SWITCH_MASK 0x0020 ///< Pump track switch bit mask. Bit 5 of the GPIO register. + +#define FPGA_AIRTRAP_LEVEL_LOW_MASK 0x0008 ///< Bit mask for air trap lower level sensor. +#define FPGA_AIRTRAP_LEVEL_HIGH_MASK 0x0004 ///< Bit mask for air trap upper level sensor. + +#define FPGA_ADA_BUBBLE_STATUS_MASK 0x0001 ///< Bit mask for arterial air bubble detector input status. +#define FPGA_ADV_BUBBLE_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. +#define FPGA_ADA_BUBBLE_SELF_TEST_CMD 0x04 ///< Bit for arterial air bubble detector self-test command. +#define FPGA_ADV_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. + +#define FPGA_PBO_TEMP_DIVISOR 2047.0F ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_GAIN 200.0F ///< Used in conversion of PBo temperature reading to deg C. +#define FPGA_PBO_TEMP_OFFSET 50.0F ///< Used in conversion of PBo temperature reading to deg C. + // FPGA Sensors Record #pragma pack(push,1) /// Record structure for FPGA header read. @@ -213,9 +240,9 @@ /*********************************************************************//** * @brief - * The initFpgaTD function initializes the TD FPGA module. - * @details Inputs: none - * @details Outputs: TD FPGA module initialized. + * The initFpgaTD function initializes the TD FPGA unit. + * @details \b Inputs: none + * @details \b Outputs: TD FPGA unit initialized. * @return none *************************************************************************/ void initFpgaTD( void ) @@ -231,10 +258,8 @@ // Set the HD valves fixed PWM mode to 2500, so if it was commanded to be in PWM mode rather than PID control // the valves will not move to 0 position -// fpgaActuatorSetPoints.VDiPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; -// fpgaActuatorSetPoints.VDoPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; -// fpgaActuatorSetPoints.VBAPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; -// fpgaActuatorSetPoints.VBVPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; + fpgaActuatorSetPoints.VBAPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; + fpgaActuatorSetPoints.VBVPWMFixed = FPGA_VALVES_MIN_PWM_MODE_COUNT; // initialize FPGA comm failures windowed timer count initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES_WINDOW_MS); @@ -243,9 +268,10 @@ /*********************************************************************//** * @brief * The execFPGATest function executes the FPGA self-test. - * @details Inputs: fpgaHeader - * @details Outputs: none - * @return passed, or failed + * @details \b Alarm: ALARM_ID_TD_FPGA_POST_TEST_FAILED if self-test fails. + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none + * @return passed or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) { @@ -277,9 +303,9 @@ /*********************************************************************//** * @brief * The getFPGATimerCount function gets the latest FPGA timer millisecond count. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last FPGA timer count + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last FPGA millisecond timer count *************************************************************************/ U16 getFPGATimerCount( void ) { @@ -290,9 +316,11 @@ * @brief * The execFPGAClockSpeedTest function verifies the processor clock speed * against the FPGA clock. - * @details Inputs: fpgaHeader - * @details Outputs: none - * @return passed, or failed + * @details \b Alarm: ALARM_ID_TD_FPGA_CLOCK_SPEED_CHECK_FAILURE if test fails. + * @details \b Inputs: fpgaSensorReadings.fpgaTimerCount_ms, msTimerCount, + * currentFPGATimerCount_ms, currentTimerCount_ms + * @details \b Outputs: currentFPGATimerCount_ms, currentTimerCount_ms + * @return none *************************************************************************/ void execFPGAClockSpeedTest( void ) { @@ -323,8 +351,8 @@ /*********************************************************************//** * @brief * The getFPGAVersions function gets the fpga version numbers. - * @details Inputs: fpgaHeader - * @details Outputs: none + * @details \b Inputs: fpgaHeader + * @details \b Outputs: Given version reference variables are populated. * @return none *************************************************************************/ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) @@ -338,8 +366,8 @@ /*********************************************************************//** * @brief * The getFPGATemperature function gets the fpga internal die temperature. - * @details Inputs: fpgaHeader - * @details Outputs: none + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none * @return current internal FPGA die temperature (in counts) *************************************************************************/ U16 getFPGATemperature( void ) @@ -350,41 +378,41 @@ /*********************************************************************//** * @brief * The getFPGAVcc function gets the fpga input voltage. - * @details Inputs: fpgaHeader - * @details Outputs: none + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none * @return current FPGA input voltage (in volts) *************************************************************************/ F32 getFPGAVcc( void ) { - F32 result = 0.0;//(F32)fpgaSensorReadings.fpgaIntVoltage * FPGA_INPUT_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; + F32 result = (F32)fpgaSensorReadings.fpgaIntVoltage * FPGA_INPUT_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; return result; } /*********************************************************************//** * @brief * The getFPGAVccAux function gets the fpga aux. voltage. - * @details Inputs: fpgaHeader - * @details Outputs: none + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none * @return current FPGA aux. voltage (in volts) *************************************************************************/ F32 getFPGAVccAux( void ) { - F32 result = 0.0;//(F32)fpgaSensorReadings.fpgaAuxVoltage * FPGA_INPUT_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; + F32 result = (F32)fpgaSensorReadings.fpgaAuxVoltage * FPGA_INPUT_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; return result; } /*********************************************************************//** * @brief * The getFPGAVpvn function gets the fpga pvn voltage. - * @details Inputs: fpgaHeader - * @details Outputs: none + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none * @return current FPGA pvn voltage (in volts) *************************************************************************/ F32 getFPGAVpvn( void ) { - F32 result = 0.0;//(F32)fpgaSensorReadings.fpgaVpvn * FPGA_PVN_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; + F32 result = (F32)fpgaSensorReadings.fpgaVpvn * FPGA_PVN_VOLTAGE_SCALE / (F32)BITS_12_FULL_SCALE; return result; } @@ -393,8 +421,10 @@ * @brief * The setAlarmAudioState function sets the fpga audio control to the given * state and volume. - * @details Inputs: none - * @details Outputs: alarm audio state and attenuation set + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given state or volume + * level is invalid. + * @details \b Inputs: none + * @details \b Outputs: alarm audio state and attenuation set * @param state the state of alarm audio to command (3..5): * 0 - No alarm tone * 1 - Low priority alarm tone (c e) @@ -416,24 +446,24 @@ *************************************************************************/ void setAlarmAudioState( U32 state, U32 volumeLevel, U32 volumeDivider ) { -// U08 audioCmd = (U08)state; -// -// audioCmd |= ( (U08)volumeLevel << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); -// audioCmd |= ( (U08)volumeDivider << FPGA_ALARM_AUDIO_DIVIDE_SHIFT ); -// -// if ( ( state <= NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) -// { -// fpgaActuatorSetPoints.alarmControl = audioCmd; -// } -// else -// { -// // S/w fault to indicate issue w/ s/w -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, (U32)audioCmd ) -// // Set alarm audio to high priority, max volume for safety since s/w seems to be having trouble setting audio correctly -// audioCmd = (U08)ALARM_PRIORITY_HIGH; -// audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); -// fpgaActuatorSetPoints.alarmControl = audioCmd; -// } + U08 audioCmd = (U08)state; + + audioCmd |= ( (U08)volumeLevel << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); + audioCmd |= ( (U08)volumeDivider << FPGA_ALARM_AUDIO_DIVIDE_SHIFT ); + + if ( ( state <= NUM_OF_ALARM_PRIORITIES ) && ( volumeLevel <= MAX_ALARM_VOLUME_ATTENUATION ) ) + { + fpgaActuatorSetPoints.alarmControl = audioCmd; + } + else + { + // S/w fault to indicate issue w/ s/w + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_FPGA_INVALID_ALARM_AUDIO_PARAM, (U32)audioCmd ) + // Set alarm audio to high priority, max volume for safety since s/w seems to be having trouble setting audio correctly + audioCmd = (U08)ALARM_PRIORITY_HIGH; + audioCmd |= ( (U08)MIN_ALARM_VOLUME_ATTENUATION << FPGA_ALARM_AUDIO_VOLUME_SHIFT ); + fpgaActuatorSetPoints.alarmControl = audioCmd; + } } /*********************************************************************//** @@ -443,9 +473,9 @@ * counting up, indicates motor is running in forward direction. If counter is * counting down, indicates motor is running in reverse direction. Counter will * wrap at 0/65535. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last blood pump hall sensor count reading. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest blood pump hall sensor count reading. *************************************************************************/ U16 getFPGABloodPumpHallSensorCount( void ) { @@ -459,9 +489,9 @@ * Bit 7 - Derived direction of the blood pump motor (0=Fwd, 1=Rev) * Bit 6 - Unused * Bit 5-0 - Direction error count since power-up (rolls over) - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last blood pump hall sensor status reading. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest blood pump hall sensor status reading. *************************************************************************/ U08 getFPGABloodPumpHallSensorStatus( void ) { @@ -470,115 +500,13 @@ /*********************************************************************//** * @brief - * The getFPGADialInPumpHallSensorCount function gets the latest dialysate inlet pump - * hall sensor count. Count is a 16 bit free running counter. If counter is - * counting up, indicates motor is running in forward direction. If counter is - * counting down, indicates motor is running in reverse direction. Counter will - * wrap at 0/65535. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last dialysate inlet pump hall sensor count reading. - *************************************************************************/ -U16 getFPGADialInPumpHallSensorCount( void ) -{ - return fpgaSensorReadings.dialInPumpHallSensorCount; -} - -/*********************************************************************//** - * @brief - * The getFPGADialInPumpHallSensorStatus function gets the latest dialysate inlet pump - * hall sensor status. - * Bit 7 - Derived direction of the dialysate inlet pump motor (0=Fwd, 1=Rev) - * Bit 6 - Unused - * Bit 5-0 - Direction error count since power-up (rolls over) - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last dialysate inlet pump hall sensor status reading. - *************************************************************************/ -U08 getFPGADialInPumpHallSensorStatus( void ) -{ - return fpgaSensorReadings.dialInPumpHallSensorStatus; -} - -/*********************************************************************//** - * @brief - * The getFPGADialOutPumpHallSensorCount function gets the latest dialysate outlet pump - * hall sensor count. Count is a 16-bit free running counter. If counter is - * counting up, indicates motor is running in forward direction. If counter is - * counting down, indicates motor is running in reverse direction. Counter will - * wrap at 0/65535. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last dialysate outlet pump hall sensor count reading. - *************************************************************************/ -U16 getFPGADialOutPumpHallSensorCount( void ) -{ - return fpgaSensorReadings.dialOutPumpHallSensorCount; -} - -/*********************************************************************//** - * @brief - * The getFPGADialOutPumpHallSensorStatus function gets the latest dialysate outlet pump - * hall sensor status. - * Bit 7 - Derived direction of the dialysate outlet pump motor (0=Fwd, 1=Rev) - * Bit 6 - Unused - * Bit 5-0 - Direction error count since power-up (rolls over) - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last dialysate outlet pump hall sensor status reading. - *************************************************************************/ -U08 getFPGADialOutPumpHallSensorStatus( void ) -{ - return fpgaSensorReadings.dialOutPumpSensorStatus; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodPumpOcclusion function gets the latest blood occlusion reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last blood occlusion reading - *************************************************************************/ -U16 getFPGABloodPumpOcclusion( void ) -{ - return fpgaSensorReadings.bloodOcclusionData; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodPumpOcclusionReadCounter function gets the latest blood - * pump occlusion read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last blood pump occlusion read counter - *************************************************************************/ -U08 getFPGABloodPumpOcclusionReadCounter( void ) -{ - return fpgaSensorReadings.bloodOcclusionReadCount; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodPumpOcclusionErrorCounter function gets the latest blood - * pump occlusion error counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last blood pump occlusion error counter - *************************************************************************/ -U08 getFPGABloodPumpOcclusionErrorCounter( void ) -{ - return fpgaSensorReadings.bloodOcclusionErrorCount; -} - -/*********************************************************************//** - * @brief * The getFPGAArterialPressure function gets the latest arterial pressure reading. * High byte indicates alarm status for ADC channel. - * Low 24-bits are channel reading. Subtract 2^23 from low 24 bits to get + * @note Low 24-bits are channel reading. Subtract 2^23 from low 24 bits to get * signed channel reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure reading *************************************************************************/ U32 getFPGAArterialPressure( void ) { @@ -589,9 +517,9 @@ * @brief * The getFPGAArterialPressureReadCounter function gets the latest arterial * pressure sensor read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure sensor read counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure sensor read counter *************************************************************************/ U08 getFPGAArterialPressureReadCounter( void ) { @@ -602,9 +530,9 @@ * @brief * The getFPGAArterialPressureErrorCounter function gets the latest arterial * pressure sensor error counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure sensor error counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure sensor error counter *************************************************************************/ U08 getFPGAArterialPressureErrorCounter( void ) { @@ -614,9 +542,9 @@ /*********************************************************************//** * @brief * The getFPGADVTArterialPressure function gets the latest arterial pressure reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure reading *************************************************************************/ U16 getFPGADVTArterialPressure( void ) { @@ -627,9 +555,9 @@ * @brief * The getFPGADVTArterialTemperature function gets the latest arterial pressure * sensor temperature reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure sensor temperature reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure sensor temperature reading *************************************************************************/ U16 getFPGADVTArterialTemperature( void ) { @@ -640,9 +568,9 @@ * @brief * The getFPGADVTArterialPressureReadCounter function gets the latest arterial * pressure sensor read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure sensor read counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure sensor read counter *************************************************************************/ U08 getFPGADVTArterialPressureReadCounter( void ) { @@ -653,9 +581,9 @@ * @brief * The getFPGATDVTArterialPressureErrorCounter function gets the latest arterial * pressure sensor error counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last arterial pressure sensor error counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest arterial pressure sensor error counter *************************************************************************/ U08 getFPGATDVTArterialPressureErrorCounter( void ) { @@ -668,9 +596,9 @@ * The high 2 bits are status bits: 00=ok, 01=cmd mode, 10=stale data, 11=diag * The low 14 bits are data. Zero is at 1638. Values above are positive, * below are negative. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last venous pressure reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest venous pressure reading *************************************************************************/ U16 getFPGAVenousPressure( void ) { @@ -681,9 +609,9 @@ * @brief * The getFPGAVenousPressureTemperature function gets the latest venous pressure * sensor temperature reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last venous pressure sensor temperature reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest venous pressure sensor temperature reading *************************************************************************/ U16 getFPGAVenousPressureTemperature( void ) { @@ -694,9 +622,9 @@ * @brief * The getFPGAVenousPressureReadCounter function gets the latest venous pressure * sensor read counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last venous pressure sensor read counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest venous pressure sensor read counter *************************************************************************/ U08 getFPGAVenousPressureReadCounter( void ) { @@ -707,9 +635,9 @@ * @brief * The getFPGAVenousPressureErrorCounter function gets the latest venous pressure * sensor error counter. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last venous pressure sensor error counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest venous pressure sensor error counter *************************************************************************/ U08 getFPGAVenousPressureErrorCounter( void ) { @@ -720,9 +648,14 @@ * @brief * The setFPGASyringePumpControlFlags function sets the syringe pump control * register per given bit flags. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints - * @param bitFlags control bit settings for syringe pump + * 0x40 - Sleep off + * 0x20 - Not reset + * 0x10 - Disable + * 0x08 - Reverse direction + * 0x01/02 - Microstep setting + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param bitFlags Desired control bit settings for syringe pump * @return none *************************************************************************/ void setFPGASyringePumpControlFlags( U08 bitFlags ) @@ -734,8 +667,11 @@ * @brief * The setFPGASyringePumpADCandDACControlFlags function sets the syringe pump * ADC/DAC control register per given bit flags. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints + * 0x04 - Write ADC setup + * 0x02 - Read DAC on ADC + * 0x01 - Enable DAC (not ADC) + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints * @param bitFlags ADC/DAC control bit settings for syringe pump * @return none *************************************************************************/ @@ -748,8 +684,8 @@ * @brief * The setFPGASyringePumpDACOutputLevel function sets the syringe pump force * sensor DAC output level register to a given value. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints * @param counts level to set syringe pump force sensor DAC to * @return none *************************************************************************/ @@ -762,8 +698,8 @@ * @brief * The setFPGASyringePumpStepToggleTime function sets the syringe pump stepper * toggle time register to a given period (in uSec). - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints * @param microSeconds toggle the stepper motor at this time interval to set pump speed * @return none *************************************************************************/ @@ -776,9 +712,9 @@ * @brief * The getFPGASyringePumpStatus function gets the latest syringe pump status * register reading. Bit 0 indicates a fault. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump status reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump status reading *************************************************************************/ U08 getFPGASyringePumpStatus( void ) { @@ -789,9 +725,9 @@ * @brief * The getFPGASyringePumpADCReadCounter function gets the latest syringe pump * ADC read counter. Counter is 8-bit and rolls over when exceeding 255. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC read counter + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC read counter *************************************************************************/ U08 getFPGASyringePumpADCReadCounter( void ) { @@ -805,9 +741,9 @@ * Bit 7 = DAC write and read-back done * Bit 6 = I2C error on DAC data transfer * Bit 0..5 = count of I2C errors, rolls over after 63 - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC/DAC status reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC/DAC status reading *************************************************************************/ U08 getFPGASyringePumpADCandDACStatus( void ) { @@ -820,9 +756,9 @@ * encoder status register reading. * Bit 7 = direction (0=fwd, 1=rev) * Bit 0..5 = direction error count (# of errors after power up, rolls over after 63) - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump encoder status reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump encoder status reading *************************************************************************/ U08 getFPGASyringePumpEncoderStatus( void ) { @@ -833,9 +769,9 @@ * @brief * The getFPGASyringePumpEncoderPosition function gets the latest syringe pump * encoder position reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump encoder position reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump encoder position reading *************************************************************************/ U32 getFPGASyringePumpEncoderPosition( void ) { @@ -846,9 +782,9 @@ * @brief * The getFPGASyringePumpADCChannel0 function gets the latest syringe pump ADC * channel 0 register reading (syringe pump force sensor). - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC channel 0 reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC channel 0 reading *************************************************************************/ U16 getFPGASyringePumpADCChannel0( void ) { @@ -859,9 +795,9 @@ * @brief * The getFPGASyringePumpADCChannel1 function gets the latest syringe pump ADC * channel 1 register reading (syringe detection switch). - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC channel 1 reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC channel 1 reading *************************************************************************/ U16 getFPGASyringePumpADCChannel1( void ) { @@ -872,9 +808,9 @@ * @brief * The getFPGASyringePumpADCChannel2 function gets the latest syringe pump ADC * channel 2 register reading (syringe pump home position sensor). - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC channel 2 reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC channel 2 reading *************************************************************************/ U16 getFPGASyringePumpADCChannel2( void ) { @@ -885,9 +821,9 @@ * @brief * The getFPGASyringePumpADCChannel3 function gets the latest syringe pump ADC * channel 3 register reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump ADC channel 3 reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump ADC channel 3 reading *************************************************************************/ U16 getFPGASyringePumpADCChannel3( void ) { @@ -903,9 +839,9 @@ * Bit 2: POR * Bit 3: Ready (not busy) * Bits 4..7: N/A - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump DAC status reading + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump DAC status reading *************************************************************************/ U08 getFPGASyringePumpDACStatus( void ) { @@ -916,9 +852,9 @@ * @brief * The getFPGASyringePumpDACSetting function gets the latest syringe pump * DAC setting. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump DAC setting + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump DAC setting *************************************************************************/ U16 getFPGASyringePumpDACSetting( void ) { @@ -929,9 +865,9 @@ * @brief * The getFPGASyringePumpDACStoredSetting function gets the latest syringe * pump DAC setting stored in sensor's EEPROM. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return last syringe pump DAC setting stored in EEPROM + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest syringe pump DAC setting stored in EEPROM *************************************************************************/ U16 getFPGASyringePumpDACStoredSetting( void ) { @@ -940,69 +876,16 @@ /*********************************************************************//** * @brief - * The getFPGAAccelAxes function gets the accelerometer axis readings. - * Axis readings are in ADC counts. 0.004 g per LSB. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @param x Populate this param with X axis reading - * @param y Populate this param with Y axis reading - * @param z Populate this param with Z axis reading - * @return none - *************************************************************************/ -void getFPGAAccelAxes( S16 *x, S16 *y, S16 *z ) -{ - *x = (S16)fpgaSensorReadings.accelX; - *y = (S16)fpgaSensorReadings.accelY; - *z = (S16)fpgaSensorReadings.accelZ; -} - -/*********************************************************************//** - * @brief - * The getFPGAAccelMaxes function gets the maximum accelerometer axis readings. - * from last FPGA read (every 10ms). - * Axis readings are in ADC counts. 0.004 g per LSB. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @param x Populate this param with maximum X axis reading - * @param y Populate this param with maximum Y axis reading - * @param z Populate this param with maximum Z axis reading - * @return none - *************************************************************************/ -void getFPGAAccelMaxes( S16 *xmax, S16*ymax, S16*zmax ) -{ - *xmax = (S16)fpgaSensorReadings.accelXMax; - *ymax = (S16)fpgaSensorReadings.accelYMax; - *zmax = (S16)fpgaSensorReadings.accelZMax; -} - -/*********************************************************************//** - * @brief - * The getFPGAAccelStatus function gets the accelerometer reading count - * and error register values. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @param cnt Populate this param with latest sample counter value - * @param err Populate this param with latest error - * @return none - *************************************************************************/ -void getFPGAAccelStatus( U16 *cnt, U16 *err ) -{ - *cnt = fpgaSensorReadings.accelSampleCounter; - *err = fpgaSensorReadings.accelFaultRegister; -} - -/*********************************************************************//** - * @brief * The getFPGABackupAlarmAudioCurrent function gets the latest piezo alarm * audio current reading. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none * @return Latest piezo alarm audio current reading *************************************************************************/ F32 getFPGABackupAlarmAudioCurrent( void ) { -// U16 adcCnts = fpgaSensorReadings.backupAlarmAudioPeakCurrent; - F32 result = 0.0;//( ( (F32)adcCnts / (F32)BITS_12_FULL_SCALE ) * FPGA_BACKUP_ALARM_AUDIO_CONVERT ) * (F32)MA_PER_AMP; + U16 adcCnts = fpgaSensorReadings.backupAlarmAudioPeakCurrent; + F32 result = ( ( (F32)adcCnts / (F32)BITS_12_FULL_SCALE ) * FPGA_BACKUP_ALARM_AUDIO_CONVERT ) * (F32)MA_PER_AMP; return result; } @@ -1011,15 +894,15 @@ * @brief * The getFPGAAirTrapLevels function gets the latest air trap level sensor * readings. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none * @return none *************************************************************************/ void getFPGAAirTrapLevels( BOOL *airAtLower, BOOL *airAtUpper ) { -// U16 fpgaGPIO = fpgaSensorReadings.fpgaGPIO; - U16 lower = 0;//fpgaGPIO & FPGA_AIRTRAP_LEVEL_LOW_MASK; - U16 upper = 0;//fpgaGPIO & FPGA_AIRTRAP_LEVEL_HIGH_MASK; + U16 fpgaGPIO = fpgaSensorReadings.fpgaGPIO; + U16 lower = fpgaGPIO & FPGA_AIRTRAP_LEVEL_LOW_MASK; + U16 upper = fpgaGPIO & FPGA_AIRTRAP_LEVEL_HIGH_MASK; *airAtLower = ( 0 == lower ? FALSE : TRUE ); *airAtUpper = ( 0 == upper ? FALSE : TRUE ); @@ -1028,8 +911,8 @@ /*********************************************************************//** * @brief * The setFPGAValvesControlMode function sets the valves control mode. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints + * @details \b Inputs: fpgaActuatorSetPoints + * @details \b Outputs: fpgaActuatorSetPoints * @param bits : The bits to enable the PID controller of a valve * @return none *************************************************************************/ @@ -1040,10 +923,10 @@ /*********************************************************************//** * @brief - * The getValvesStatus function reads the status of the valves - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return The status of the valves + * The getValvesStatus function reads the status of the valves. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest status of the valves *************************************************************************/ U16 getFPGAValvesStatus( void ) { @@ -1054,313 +937,67 @@ * @brief * The noFPGAFluidLeakDetected function returns TRUE if no fluid leak has been * detected (dry) and FALSE if a fluid leak has been detected (wet). - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return noFPGAFluidLeakDetected + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest fluid leak detected status *************************************************************************/ BOOL noFPGAFluidLeakDetected( void ) { - U16 noFPGAFluidLeakDetected = 0;//fpgaSensorReadings.fpgaGPIO & FPGA_FLUID_LEAK_STATE_MASK; + U16 noFPGAFluidLeakDetected = fpgaSensorReadings.fpgaGPIO & FPGA_FLUID_LEAK_STATE_MASK; return ( 0 == noFPGAFluidLeakDetected ? FALSE : TRUE ); } /*********************************************************************//** * @brief - * The getFPGABloodLeakStatus function returns the blood leak sensor's - * blood detection status bit. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return blood leak sensor self test status bit + * The noFPGAVenousBubbleDetected function returns TRUE if no air bubble has + * been detected and FALSE if an air bubble has been detected. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return Latest bubble detected status *************************************************************************/ -U08 getFPGABloodLeakStatus( void ) +BOOL noFPGAVenousBubbleDetected( void ) { - U08 selfTestStatus = 0;//(U08)( ( fpgaSensorReadings.fpgaGPIO & FPGA_BLOOD_LEAK_STATUS_MASK ) >> FPGA_BLOOD_LEAK_ST_BIT_INDEX ); - - return selfTestStatus; -} - -/*********************************************************************//** - * @brief - * The setFPGABloodLeakUARTControl function sets the blood leak sensor UART - * control value. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return none - *************************************************************************/ -void setFPGABloodLeakUARTControl( U08 value ) -{ - fpgaActuatorSetPoints.bloodLeakUARTControl = value; -} - -/*********************************************************************//** - * @brief - * The setFPGABloodLeakUARTTransmit function sets the blood leak sensor UART - * transmit value. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return none - *************************************************************************/ -void setFPGABloodLeakUARTTransmit( U08 value ) -{ - fpgaActuatorSetPoints.bloodLeakFIFOTransmit = value; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakTxFIFOCount function returns the blood leak transmit - * FIFO count. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakTxFIFOCount - *************************************************************************/ -U08 getFPGABloodLeakTxFIFOCount( void ) -{ - return fpgaSensorReadings.bloodLeakTxFIFOCount; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakRxFIFOCount function returns the blood leak receive - * FIFO count. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakRxFIFOCount - *************************************************************************/ -U16 getFPGABloodLeakRxFIFOCount( void ) -{ - return fpgaSensorReadings.bloodLeakRxFIFOCount; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakRxErrorCount function returns the blood leak receive - * error count. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakRxErrorCount - *************************************************************************/ -U08 getFPGABloodLeakRxErrorCount( void ) -{ - return fpgaSensorReadings.bloodLeakRxErrorCount; -} - -/*********************************************************************//** - * @brief - * The getFPGABloodLeakRxFIFODataOut function returns the blood leak receive - * FIFO data out. - * @details Inputs: none - * @details Outputs: none - * @return fpgaSensorReadings.bloodLeakRxFIFODataOut - *************************************************************************/ -U08 getFPGABloodLeakRxFIFODataOut( void ) -{ - return fpgaSensorReadings.bloodLeakRxFIFODataOut; -} - -/*********************************************************************//** - * @brief - * The noFPGABubbleDetected function returns TRUE if no air bubble has been - * detected and FALSE if an air bubble has been detected. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return noFPGABubbleDetected - *************************************************************************/ -BOOL noFPGABubbleDetected( U32 bubble ) -{ U16 noFPGABubbleDetected = 0; -// if ( bubble == ADV ) -// { -// noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; -// } -// else -// { -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_BUBBLE_ID, bubble ) -// } + noFPGABubbleDetected = fpgaSensorReadings.fpgaGPIO & FPGA_ADV_BUBBLE_STATUS_MASK; return ( 0 != noFPGABubbleDetected ? TRUE : FALSE ); } /*********************************************************************//** * @brief - * The setFPGABubbleSelfTest function sets the given air bubble detector into + * The setFPGAVenousBubbleSelfTest function sets the given air bubble detector into * self-test mode via the FPGA. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints * @return: none *************************************************************************/ -void setFPGABubbleSelfTest( U32 bubble ) +void setFPGAVenousBubbleSelfTest( void ) { -// if ( bubble == ADV ) -// { -// fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_ADV_BUBBLE_SELF_TEST_CMD; -// } + fpgaActuatorSetPoints.fpgaSensorTest |= FPGA_ADV_BUBBLE_SELF_TEST_CMD; } /*********************************************************************//** * @brief - * The clearFPGABubbleSelfTest function clears the given air bubble detector + * The clearFPGAVenousBubbleSelfTest function clears the given air bubble detector * from self-test mode via the FPGA. - * @details Inputs: none - * @details Outputs: fpgaActuatorSetPoints + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints * @return: none *************************************************************************/ -void clearFPGABubbleSelfTest( U32 bubble ) +void clearFPGAVenousBubbleSelfTest( void ) { -// if ( bubble == ADV ) -// { -// fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_ADV_BUBBLE_SELF_TEST_CMD; -// } -// else -// { -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_HD_SOFTWARE_FAULT, SW_FAULT_ID_HD_INVALID_BUBBLE_ID, bubble ) -// } + fpgaActuatorSetPoints.fpgaSensorTest &= ~FPGA_ADV_BUBBLE_SELF_TEST_CMD; } /*********************************************************************//** * @brief - * The setValveDialyzerInletPosition function sets the position of VDi - * in counts - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param setPoint : Next position of the valve in counts - * @return none - *************************************************************************/ -void setFPGAValveDialyzerInletPosition( S16 setPoint ) -{ - fpgaActuatorSetPoints.VDiSetPoint = setPoint; -} - -/*********************************************************************//** - * @brief - * The getValveDialyzerInletPosition function reads the current position - * of VDi in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current position of VDi - *************************************************************************/ -S16 getFPGAValveDialyzerInletPosition( void ) -{ - return fpgaSensorReadings.VDiPosition; -} - -/*********************************************************************//** - * @brief - * The getFPGAValveDialyzerInletCurrentCounts function reads the current \n - * of VDi in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current of VDi - *************************************************************************/ -U16 getFPGAValveDialyzerInletCurrentCounts( void ) -{ - return fpgaSensorReadings.VDiCurrent; -} - -#ifdef DEBUG_ENABLED -/*********************************************************************//** - * @brief - * The setFPGAValveDialyzerInletPWM function sets the PWM of VDI in counts. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param count which is the PWM of VDI in counts - * @return none - *************************************************************************/ -void setFPGAValveDialyzerInletPWM( U16 count ) -{ - fpgaActuatorSetPoints.VDiPWMFixed = count; -} - -/*********************************************************************//** - * @brief - * The getFPGAValveDialyzerInletPWM function reads the current PWM target - * of VDI. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current PWM of VDI - *************************************************************************/ -U16 getFPGAValveDialyzerInletPWM( void ) -{ - return fpgaSensorReadings.VDiPWMTarget; -} -#endif - -/*********************************************************************//** - * @brief - * The setFPGAValveDialyzerOutletPosition function sets the position of VDo - * in counts - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param setPoint : Next position of the valve in counts - * @return none - *************************************************************************/ -void setFPGAValveDialyzerOutletPosition( S16 setPoint ) -{ - fpgaActuatorSetPoints.VDoSetPoint = setPoint; -} - -/*********************************************************************//** - * @brief - * The getFPGAValveDialyzerOutletPosition function reads the current position - * of VDo in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current position of VDo - *************************************************************************/ -S16 getFPGAValveDialyzerOutletPosition( void ) -{ - return fpgaSensorReadings.VDoPosition; -} - -/*********************************************************************//** - * @brief - * The getFPGAValveDialyzerOutletCurrentCounts function reads the current - * of VDo in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current of VDo - *************************************************************************/ -U16 getFPGAValveDialyzerOutletCurrentCounts( void ) -{ - return fpgaSensorReadings.VDoCurrent; -} - -#ifdef DEBUG_ENABLED -/*********************************************************************//** - * @brief - * The setFPGAValveDialyzerOutletPWM function sets the PWM of VDO in counts. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param count which is the PWM of VDO in counts - * @return none - *************************************************************************/ -void setFPGAValveDialyzerOutletPWM( U16 count ) -{ - fpgaActuatorSetPoints.VDoPWMFixed = count; -} - -/*********************************************************************//** - * @brief - * The getFPGAValveDialyzerOutletPWM function reads the current PWM target - * of VDO. - * @details Inputs: fpgaSensorReadings - * @details Outputs: none - * @return current PWM of VDO - *************************************************************************/ -U16 getFPGAValveDialyzerOutletPWM( void ) -{ - return fpgaSensorReadings.VDoPWMTarget; -} -#endif - -/*********************************************************************//** - * @brief * The setValveBloodVenousPosition function sets the position of VBV * in counts - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param setPoint : Next position of the valve in counts + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param setPoint The next encoder position of the valve in counts * @return none *************************************************************************/ void setFPGAValveBloodVenousPosition( S16 setPoint ) @@ -1370,11 +1007,11 @@ /*********************************************************************//** * @brief - * The getValveBloodVenousPosition function reads the current position + * The getValveBloodVenousPosition function returns the current position * of VBV in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current position of VBV + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The current encoder position of VBV *************************************************************************/ S16 getFPGAValveBloodVenousPosition( void ) { @@ -1383,11 +1020,11 @@ /*********************************************************************//** * @brief - * The getFPGAValveBloodVenousCurrentCounts function reads the current + * The getFPGAValveBloodVenousCurrentCounts function returns the current * of VBV in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current of VBV + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest current of VBV *************************************************************************/ U16 getFPGAValveBloodVenousCurrentCounts( void ) { @@ -1398,9 +1035,9 @@ /*********************************************************************//** * @brief * The setFPGAValveBloodVenousPWM function sets the PWM of VBV in counts. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param count which is the PWM of VBV in counts + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param count PWM counts to set for VBV * @return none *************************************************************************/ void setFPGAValveBloodVenousPWM( U16 count ) @@ -1411,9 +1048,9 @@ /*********************************************************************//** * @brief * The getFPGAValveBloodVenousPWM function returns the PWM of VBV in counts. - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: none - * @return returns the PWM of VBV in counts + * @details \b Inputs: fpgaActuatorSetPoints + * @details \b Outputs: none + * @return The PWM counts for VBV *************************************************************************/ U16 getFPGAValveBloodVenousPWM( void ) { @@ -1425,9 +1062,9 @@ * @brief * The setValveBloodArterialPosition function sets the position of VBA * in counts - * @details Inputs: fpgaActuatorSetPoints - * @details Outputs: fpgaActuatorSetPoints - * @param setPoint : Next position of the valve in counts + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param setPoint The next position of the valve in counts * @return none *************************************************************************/ void setFPGAValveBloodArterialPosition( S16 setPoint ) @@ -1439,9 +1076,9 @@ * @brief * The getValveBloodArterialPosition function reads the current position * of VBA in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current position of VBA + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest encoder position of VBA *************************************************************************/ S16 getFPGAValveBloodArterialPosition( void ) { @@ -1452,9 +1089,9 @@ * @brief * The getFPGAValveBloodArterialCurrentCounts function reads the current * of VBA in counts - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return The current of VBA + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest current of VBA *************************************************************************/ U16 getFPGAValveBloodArterialCurrentCounts( void ) { @@ -1464,9 +1101,9 @@ /*********************************************************************//** * @brief * The getFPGABoardTemperature function reads the FPGA board temperature. - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return Current FPGA board temperature + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest FPGA board temperature in ADC counts *************************************************************************/ U16 getFPGABoardTemperature( void ) { @@ -1475,22 +1112,22 @@ /*********************************************************************//** * The getFPGAFrontDoorStatus function returns the FPGA front door status - * bit. - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return front door FPGA status bit + * bit (0x10). + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return front door FPGA status bit (0x10 = Open, 0x00 = Closed) *************************************************************************/ U16 getFPGAFrontDoorStatus( void ) { - return 0;//( fpgaSensorReadings.fpgaGPIO & FRONT_DOOR_SWITCH_MASK ); + return ( fpgaSensorReadings.fpgaGPIO & FRONT_DOOR_SWITCH_MASK ); } /*********************************************************************//** * @brief - * The getFPGAPBAADCTemperature function reads the PBA ADC temperature. - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return PBA ADC temperature + * The getFPGAPBAADCTemperature function returns the PBA ADC temperature. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest PBA temperature in ADC counts *************************************************************************/ U32 getFPGAPBAADCTemperature( void ) { @@ -1499,35 +1136,24 @@ /*********************************************************************//** * @brief - * The getFPGAInletFan1TogglePeriod function reads the inlet fan 1 pulse time. - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return Inlet fan 1 pulse time + * The getFPGAInletFan1TogglePeriod function returns the inlet fan 1 pulse time. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return The latest inlet fan 1 pulse time (in 2.5 uSec) *************************************************************************/ U16 getFPGAInletFan1TogglePeriod( void ) { return fpgaSensorReadings.fan1PulseTime; } /*********************************************************************//** - * The getFPGAPumpTrackSwitchStatus function returns the FPGA pump track - * switch status bit. - * @details Inputs: none - * @details Outputs: fpgaSensorReadings - * @return pump track switch FPGA status bit - *************************************************************************/ -U16 getFPGAPumpTrackSwitchStatus( void ) -{ - return 0;//( fpgaSensorReadings.fpgaGPIO & PUMP_TRACK_SWITCH_MASK ); -} - -/*********************************************************************//** * @brief * The checkFPGACommFailure function increments the FPGA comm failure * windowed timer and returns whether or not the number of failures in * the window have been reached. - * @details Inputs: ms counter - * @details Outputs: none + * @details \b Alarm: ALARM_ID_TD_FPGA_COMM_TIMEOUT if 3 comm failures in last 1 minute. + * @details \b Inputs: Millisecond counter + * @details \b Outputs: none * @return none *************************************************************************/ void checkFPGACommFailure( void ) @@ -1547,13 +1173,13 @@ * windowed timer if an FE or OE error has occurred and returns whether * or not the number of failures in * the window have been reached. - * @details Inputs: none - * @details Outputs: none - * @return TRUE if windowed count exceeded, else false. + * @details \b Alarm: ALARM_ID_TD_FPGA_COMM_TIMEOUT if 3 comm failures in last 1 minute. + * @details \b Inputs: Millisecond timer + * @details \b Outputs: none + * @return none *************************************************************************/ -BOOL checkFPGAFEOEFailure( void ) +void checkFPGAFEOEFailure( void ) { - BOOL status = false; BOOL FPGAFEOEError = getSci2FEOEError(); if ( TRUE == FPGAFEOEError) @@ -1563,12 +1189,9 @@ if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.errorCountProcessor ) - status = TRUE; } } } - - return status; } /**@}*/ Index: firmware/App/Services/FpgaTD.h =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/FpgaTD.h (.../FpgaTD.h) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Services/FpgaTD.h (.../FpgaTD.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -24,8 +24,8 @@ /** * @defgroup FpgaTD FpgaTD - * @brief FPGA service module for TD firmware. - * The FPGA module contains get/set functions for the TD FPGA registers. + * @brief FPGA service unit for TD firmware. + * The FPGA unit contains get/set functions for the TD FPGA registers. * * @addtogroup FpgaTD * @{ @@ -39,7 +39,7 @@ SELF_TEST_STATUS_T execFPGATest( void ); void execFPGAClockSpeedTest( void ); void checkFPGACommFailure( void ); -BOOL checkFPGAFEOEFailure( void ); +void checkFPGAFEOEFailure( void ); U16 getFPGATimerCount( void ); void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ); @@ -52,10 +52,6 @@ U16 getFPGABloodPumpHallSensorCount( void ); U08 getFPGABloodPumpHallSensorStatus( void ); -U16 getFPGADialInPumpHallSensorCount( void ); -U08 getFPGADialInPumpHallSensorStatus( void ); -U16 getFPGADialOutPumpHallSensorCount( void ); -U08 getFPGADialOutPumpHallSensorStatus( void ); U32 getFPGAArterialPressure( void ); U08 getFPGAArterialPressureReadCounter( void ); @@ -70,9 +66,6 @@ U16 getFPGAVenousPressureTemperature( void ); U08 getFPGAVenousPressureReadCounter( void ); U08 getFPGAVenousPressureErrorCounter( void ); -U16 getFPGABloodPumpOcclusion( void ); -U08 getFPGABloodPumpOcclusionReadCounter( void ); -U08 getFPGABloodPumpOcclusionErrorCounter( void ); void setFPGASyringePumpControlFlags( U08 bitFlags ); void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ); @@ -91,10 +84,6 @@ U16 getFPGASyringePumpDACSetting( void ); U16 getFPGASyringePumpDACStoredSetting( void ); -void getFPGAAccelAxes( S16 *x, S16 *y, S16 *z ); -void getFPGAAccelMaxes( S16 *xm, S16*ym, S16*zm ); -void getFPGAAccelStatus( U16 *cnt, U16 *accelFPGAFaultReg ); - F32 getFPGABackupAlarmAudioCurrent( void ); void getFPGAAirTrapLevels( BOOL *airAtLower, BOOL *airAtUpper ); @@ -104,41 +93,23 @@ BOOL noFPGAFluidLeakDetected( void ); -U08 getFPGABloodLeakStatus( void ); +BOOL noFPGAVenousBubbleDetected( void ); +void setFPGAVenousBubbleSelfTest( void ); +void clearFPGAVenousBubbleSelfTest( void ); -void setFPGABloodLeakUARTControl( U08 value ); -void setFPGABloodLeakUARTTransmit( U08 value ); - -U08 getFPGABloodLeakTxFIFOCount( void ); -U16 getFPGABloodLeakRxFIFOCount( void ); -U08 getFPGABloodLeakRxErrorCount( void ); -U08 getFPGABloodLeakRxFIFODataOut( void ); - -BOOL noFPGABubbleDetected( U32 bubble ); -void setFPGABubbleSelfTest( U32 bubble ); -void clearFPGABubbleSelfTest( U32 bubble ); - -void setFPGAValveDialyzerInletPosition( S16 setPoint ); -S16 getFPGAValveDialyzerInletPosition( void ); -U16 getFPGAValveDialyzerInletCurrentCounts( void ); - -void setFPGAValveDialyzerOutletPosition( S16 setPoint ); -S16 getFPGAValveDialyzerOutletPosition( void ); -U16 getFPGAValveDialyzerOutletCurrentCounts( void ); - void setFPGAValveBloodVenousPosition( S16 setPoint ); S16 getFPGAValveBloodVenousPosition( void ); U16 getFPGAValveBloodVenousCurrentCounts( void ); void setFPGAValveBloodArterialPosition( S16 setPoint ); S16 getFPGAValveBloodArterialPosition( void ); U16 getFPGAValveBloodArterialCurrentCounts( void ); + U16 getFPGABoardTemperature( void ); U32 getFPGAPBAADCTemperature( void ); U16 getFPGAInletFan1TogglePeriod( void ); U16 getFPGAFrontDoorStatus( void ); -U16 getFPGAPumpTrackSwitchStatus( void ); /**@}*/ Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -15,18 +15,16 @@ * ***************************************************************************/ -#include #include "can.h" #include "het.h" #include "rti.h" #include "sci.h" #include "sys_dma.h" -#include "TDCommon.h" //#include "BloodFlow.h" #include "Comm.h" #include "Interrupts.h" -//#include "FPGA.h" +#include "FPGA.h" #include "SystemComm.h" #include "TaskGeneral.h" #include "TaskPriority.h" @@ -59,9 +57,9 @@ /*********************************************************************//** * @brief - * The initInterrupts function initializes the Interrupts module. - * @details Inputs: none - * @details Outputs: Interrupts module initialized. + * The initInterrupts function initializes the Interrupts unit. + * @details \b Inputs: none + * @details \b Outputs: Interrupts unit initialized. * @return none *************************************************************************/ void initInterrupts( void ) @@ -74,8 +72,9 @@ /*********************************************************************//** * @brief * The phantomInterrupt function handles phantom interrupts. - * @details Inputs: none - * @details Outputs: phantom interrupt handled. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT + * @details \b Inputs: none + * @details \b Outputs: phantom interrupt handled. * @return none *************************************************************************/ void phantomInterrupt(void) @@ -86,9 +85,10 @@ /*********************************************************************//** * @brief * The rtiNotification function handles real-time interrupt notifications. - * @details Inputs: none - * @details Outputs: RTI notification handled. - * @param notification Which RTI timer caused this interrupt + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given notification is invalid/unexpected. + * @details \b Inputs: none + * @details \b Outputs: Task associated with given notification is executed. + * @param notification ID of RTI timer that caused this interrupt * @return none *************************************************************************/ void rtiNotification(uint32 notification) @@ -120,10 +120,10 @@ /*********************************************************************//** * @brief * The canMessageNotification function handles CAN message notifications. - * @details Inputs: none - * @details Outputs: CAN message notification handled. - * @param node which CAN controller - * @param messageBox which message box triggered the message notification + * @details \b Inputs: none + * @details \b Outputs: CAN message notification handled. + * @param node ID of CAN controller that given notification came from. + * @param messageBox ID of CAN mailbox that triggered the message notification * @return none *************************************************************************/ void canMessageNotification(canBASE_t *node, uint32 messageBox) @@ -137,8 +137,9 @@ /*********************************************************************//** * @brief * The canErrorNotification function handles CAN error notifications. - * @details Inputs: none - * @details Outputs: CAN error notification handled. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if CAN parity or off error detected. + * @details \b Inputs: none + * @details \b Outputs: CAN error notification handled. * @param node which CAN controller * @param notification canLEVEL_PASSIVE (0x20) : When RX- or TX error counter are between 32 and 63 * canLEVEL_WARNING (0x40) : When RX- or TX error counter are between 64 and 127 @@ -183,11 +184,11 @@ /*********************************************************************//** * @brief * The sciNotification function handles UART communication error interrupts. - * Frame and Over-run errors are handled. - * @details Inputs: none - * @details Outputs: UART error interrupts handled. + * Frame and Over-run errors are recorded and cleared. + * @details \b Inputs: none + * @details \b Outputs: sci2FEOEError, sci2FEOEError * @param sci Pointer to the SCI peripheral that detected the error - * @param flags error flag(s) + * @param flags 32 bits of error flags * @return none *************************************************************************/ void sciNotification(sciBASE_t *sci, uint32 flags) @@ -214,8 +215,9 @@ /*********************************************************************//** * @brief * The dmaGroupANotification function handles communication DMA interrupts. - * @details Inputs: none - * @details Outputs: DMA interrupt is handled. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given DMA channel is invalid/unexpected. + * @details \b Inputs: none + * @details \b Outputs: DMA interrupt is handled. * @param inttype type of DMA interrupt * @param channel DMA channel that caused the interrupt * @return none @@ -228,12 +230,12 @@ { case DMA_CH0: // FPGA receive channel clearSCI2DMAReceiveInterrupt(); -// signalFPGAReceiptCompleted(); + signalFPGAReceiptCompleted(); break; case DMA_CH2: // FPGA transmit channel clearSCI2DMATransmitInterrupt(); -// signalFPGATransmitCompleted(); + signalFPGATransmitCompleted(); break; default: @@ -245,11 +247,12 @@ /*********************************************************************//** * @brief - * The edgeNotification function handles rotor hall sensor interrupts. - * @details Inputs: none - * @details Outputs: Rotor hall sensor interrupt is handled according to pin associated with given edge. + * The edgeNotification function handles hall sensor interrupts. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given edge is invalid/unexpected. + * @details \b Inputs: none + * @details \b Outputs: Hall sensor interrupt is handled according given pulse edge. * @param hetREG HET controller associated with the edge - * @param edge Which edge was detected + * @param edge ID of pulse edge that triggered this interrupt * @return none *************************************************************************/ void edgeNotification(hetBASE_t * hetREG, uint32 edge) @@ -273,8 +276,8 @@ * @brief * The getSci2FEOEError function returns the sci2FEOEError (OE - Overrun, * FE - Framing Error) status and resets the status if TRUE - * @details Inputs: sci2FEOEError - * @details Outputs: none + * @details \b Inputs: sci2FEOEError + * @details \b Outputs: none * @return sci2 FE / OE error *************************************************************************/ BOOL getSci2FEOEError( void ) Index: firmware/App/Services/Interrupts.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/Interrupts.h (.../Interrupts.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Services/Interrupts.h (.../Interrupts.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -18,11 +18,11 @@ #ifndef __INTERRUPTS_H__ #define __INTERRUPTS_H__ -#include "../TDCommon.h" +#include "TDCommon.h" /** * @defgroup Interrupts Interrupts - * @brief Interrupts module handles various peripheral interrupts. + * @brief Interrupts unit handles various peripheral interrupts. * * @addtogroup Interrupts * @{ Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r01892698468068bb97a80a84c96a6d7c5d6fde9b -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 01892698468068bb97a80a84c96a6d7c5d6fde9b) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -34,11 +34,13 @@ #define MAX_MSGS_BLOCKED_FOR_XMIT 8 ///< Maximum number of messages to block transmission for. #pragma pack(push,1) + /// Payload record structure for block message transmission request. typedef struct { U16 blockedMessages[ MAX_MSGS_BLOCKED_FOR_XMIT ]; ///< Blocked messages. } BLOCKED_MSGS_DATA_T; + #pragma pack(pop) /// Array of CAN communication buffers to respond on (aligned with enum Comm_Buffers). @@ -93,17 +95,21 @@ /*********************************************************************//** * @brief - * The serializeMessage function serializes a given message into a given - * array of bytes. A sequence # is added to the message here and the ACK - * bit of the sequence # is set if ACK is required per parameter. A sync byte - * is inserted at the beginning of the message and an 8-bit CRC is appended to - * the end of the message. The message is queued for transmission in the given buffer. - * @details Inputs: blockedMessagesForXmit - * @details Outputs: given data array populated with serialized message data and queued for transmit. + * The serializeMessage function serializes a given message into an array + * of bytes that conform to our CAN message format. A sequence number is added + * and the ACK bit of the sequence number is set if ACK is required per parameter. + * A sync byte is inserted at the beginning and an 8-bit CRC is appended to + * the end. The serialized message data is queued for transmission in the given + * buffer. + * @details Alarm: ALARM_ID_TD_SOFTWARE_FAULT on failure to add a message to the + * pending ACK list (list is full). + * @details \b Inputs: blockedMessagesForXmit + * @details \b Outputs: given buffer is populated with serialized message data and + * queued for transmit. * @param msg message to serialize - * @param buffer outgoing buffer that message should be queued in - * @param ackReq is an acknowledgement from receiver required? - * @return size (in bytes) of serialized message populated in given data array. + * @param buffer outgoing buffer where serialized message should be queued + * @param ackReq Flag indicates whether an acknowledgement from receiver is required? + * @return Number of bytes of serialized message data added to the given buffer. *************************************************************************/ U32 serializeMessage( MESSAGE_T msg, COMM_BUFFER_T buffer, BOOL ackReq ) { @@ -200,10 +206,11 @@ * @brief * The sendACKMsg function constructs and queues for transmit an ACK message * for a given received message. - * @details Inputs: none - * @details Outputs: ACK message queued for transmit on broadcast CAN channel. - * @param message message to send an ACK for - * @return TRUE if ACK message queued successfully, FALSE if not + * @details \b Inputs: none + * @details \b Outputs: ACK message constructed and queued for transmit on broadcast + * CAN channel. + * @param message Pointer to message that is being ACKed + * @return TRUE if ACK message queued for transmit successfully, FALSE if not *************************************************************************/ BOOL sendACKMsg( MESSAGE_T *message ) { @@ -227,14 +234,13 @@ /*********************************************************************//** * @brief - * The sendAckResponseMsg function constructs a simple response - * message for a handled message and queues it for transmit on the - * appropriate CAN channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. + * The sendAckResponseMsg function constructs a simple response message for + * a handled message and queues it for transmit on the appropriate CAN channel. + * @details \b Inputs: none + * @details \b Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to - * @param buffer outgoing buffer that message should be queued in - * @param ack TRUE if test message was handled successfully, FALSE if not + * @param buffer outgoing buffer that message should be queued to + * @param ack TRUE to ACK, FALSE to NAK * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendAckResponseMsg( MSG_ID_T msgID, COMM_BUFFER_T buffer, BOOL ack ) @@ -259,12 +265,12 @@ /*********************************************************************//** * @brief - * The getMsgHandler function finds the appropriate handler function - * for the given message. - * @details Inputs: MSG_FUNCTION_HANDLER_LOOKUP[], MSG_FUNCTION_HANDLERS[] - * @details Outputs: none + * The getMsgHandler function finds the appropriate handler function for + * a given message. + * @details \b Inputs: MSG_FUNCTION_HANDLER_LOOKUP[], MSG_FUNCTION_HANDLERS[] + * @details \b Outputs: none * @param msgID ID of message to find handler function for - * @return pointer to appropriate function to handle given message + * @return pointer to appropriate function to handle the given message *************************************************************************/ static MsgFuncPtr getMsgHandler( U16 msgID ) { @@ -286,9 +292,9 @@ /*********************************************************************//** * @brief * The handleIncomingMessage function calls the appropriate handler function - * for the given message. - * @details Inputs: none - * @details Outputs: Appropriate message handler function called + * for a given message and sends appropriate ACK/NAK response. + * @details \b Inputs: none + * @details \b Outputs: Appropriate message handler function called * @param message Incoming message to handle * @return none *************************************************************************/ @@ -332,17 +338,20 @@ + // *********************************************************************** // ***************** Message Sending Helper Functions ******************** // *********************************************************************** + + /*********************************************************************//** * @brief - * The sendEvent function constructs an TD event message to the UI and - * queues the msg for transmit on the appropriate CAN channel. - * @details Inputs: none - * @details Outputs: TD event msg constructed and queued. + * The sendEvent function constructs a TD event message and queues the msg + * for transmit on the TD=>UI CAN channel. + * @details \b Inputs: none + * @details \b Outputs: TD event msg constructed and queued for transmit. * @param event Enumeration of event type that occurred * @param dat1 First data associated with event * @param dat2 Second data associated with event @@ -383,10 +392,10 @@ /*********************************************************************//** * @brief * The isTestingActivated function determines whether a tester has successfully - * logged in to activate testing functionality. - * @details Inputs: testerLoggedIn - * @details Outputs: none - * @return TRUE if a tester has logged in to activate testing, FALSE if not + * logged in to authorize testing functionality. + * @details \b Inputs: testerLoggedIn + * @details \b Outputs: none + * @return TRUE if a tester has logged in from Dialin, FALSE if not *************************************************************************/ BOOL isTestingActivated( void ) { @@ -395,10 +404,10 @@ /*********************************************************************//** * @brief - * The setTesterStatusToLoggedOut function sets the status of the tester to - * logged out. - * @details Inputs: none - * @details Outputs: testerLoggedIn + * The setTesterStatusToLoggedOut function logs Dialin out due to too much + * time since Dialin last checked in. + * @details \b Inputs: none + * @details \b Outputs: testerLoggedIn * @return none *************************************************************************/ void setTesterStatusToLoggedOut( void ) @@ -408,13 +417,13 @@ /*********************************************************************//** * @brief - * The sendTestAckResponseMsg function constructs a simple response - * message for a handled test message and queues it for transmit on the - * appropriate UART channel. - * @details Inputs: none - * @details Outputs: response message constructed and queued for transmit. + * The sendTestAckResponseMsg function constructs a simple response message + * for a handled test message and queues it for transmit on the TD=>PC CAN + * channel. + * @details \b Inputs: none + * @details \b Outputs: response message constructed and queued for transmit. * @param msgID ID of handled message that we are responding to - * @param ack TRUE if test message was handled successfully, FALSE if not + * @param ack TRUE to ACK, FALSE to NAK * @return TRUE if response message successfully queued for transmit, FALSE if not *************************************************************************/ static BOOL sendTestAckResponseMsg( MSG_ID_T msgID, BOOL ack ) @@ -436,12 +445,11 @@ /*********************************************************************//** * @brief - * The handleTesterLogInRequest function handles a request to login as a - * tester. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return TRUE if log in successful, FALSE if not + * The handleTesterLogInRequest function handles a Dialin request to login. + * @details \b Inputs: none + * @details \b Outputs: Dialin logged in if request is authenticated. + * @param message Pointer to the Dialin login message + * @return TRUE if login successful, FALSE if not *************************************************************************/ BOOL handleTesterLogInRequest( MESSAGE_T *message ) { @@ -468,10 +476,11 @@ * @brief * The handleTDSoftwareResetRequest function handles a request to reset the * TD firmware processor. - * @details Inputs: none - * @details Outputs: message handled - * @param message a pointer to the message to handle - * @return FALSE if reset command rejected (won't return if reset successful) + * @note If reset is successful, this function will not return. + * @details \b Inputs: none + * @details \b Outputs: TD processor soft reset if request is valid + * @param message Pointer to the reset request message + * @return FALSE if reset command rejected *************************************************************************/ BOOL handleTDSoftwareResetRequest( MESSAGE_T *message ) { Index: firmware/App/Services/Messaging.h =================================================================== diff -u -r9ea1971251bb0064e626c21e7d94215114254a98 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision 9ea1971251bb0064e626c21e7d94215114254a98) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -25,7 +25,7 @@ /** * @defgroup Messaging Messaging - * @brief The system communication messages module provides helper functions + * @brief The system communication messages unit provides helper functions * for sending outgoing system message and handling incoming system messages. * * @addtogroup Messaging Index: firmware/App/Services/MsgQueues.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/MsgQueues.c (.../MsgQueues.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Services/MsgQueues.c (.../MsgQueues.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -37,9 +37,9 @@ /*********************************************************************//** * @brief - * The initMsgQueues function initializes the MsgQueues module. - * @details Inputs: none - * @details Outputs: msgQueueCounts[], msgQueueStarts[], msgQueueNexts[], msgQueues[][] + * The initMsgQueues function initializes the MsgQueues unit. + * @details \b Inputs: none + * @details \b Outputs: The MsgQueues unit is initialized. * @return none *************************************************************************/ void initMsgQueues( void ) @@ -62,12 +62,15 @@ /*********************************************************************//** * @brief * The addToMsgQueue function adds a message to a given message queue. - * This function should only be called from the General Task. - * @details Inputs: none - * @details Outputs: message added to queue - * @param queue the message queue to add to - * @param msg a pointer to a message structure to add to the queue - * @return TRUE if message added to queue, FALSE if could not + * @warning This function is not thread safe and should only be called from + * the General Task. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given queue is invalid + * or full. + * @details \b Inputs: msgQueueCounts[] + * @details \b Outputs: msgQueues[], msgQueueNexts[], msgQueueCounts[] + * @param queue the message queue to add a message to + * @param msg a pointer to a message to add to the queue + * @return TRUE if message added to queue successfully, FALSE if not *************************************************************************/ BOOL addToMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ) { @@ -102,12 +105,14 @@ /*********************************************************************//** * @brief * The getFromMsgQueue function retrieves the next message from a given - * message queue. This function should only be called from the General Task. - * @details Inputs: queue - * @details Outputs: message retrieved from the queue - * @param queue the message queue to retrieve from - * @param msg a pointer to a message structure to populate with the retrieved - * message. + * message queue. + * @warning This function is not thread safe and should only be called from + * the General Task. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given queue is invalid. + * @details \b Inputs: msgQueueCounts[] + * @details \b Outputs: msgQueues[], msgQueueStarts[], msgQueueCounts[] + * @param queue the message queue to retrieve a message from + * @param msg a pointer to a message to populate with the retrieved message. * @return TRUE if a message was found to retrieve, FALSE if not *************************************************************************/ BOOL getFromMsgQueue( MSG_QUEUE_T queue, MESSAGE_WRAPPER_T *msg ) @@ -142,9 +147,10 @@ /*********************************************************************//** * @brief - * The isMsgQueueEmpty function determines whether a given message queue is empty. - * @details Inputs: msgQueueCounts[] - * @details Outputs: none + * The isMsgQueueEmpty function determines whether a given message queue is empty. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if the given queue is invalid. + * @details \b Inputs: msgQueueCounts[] + * @details \b Outputs: none * @param queue the message queue to check * @return TRUE if a given message queue is empty, FALSE if not *************************************************************************/ @@ -170,9 +176,10 @@ /*********************************************************************//** * @brief - * The isMsgQueueFull function determines whether a given message queue is full. - * @details Inputs: msgQueueCounts[] - * @details Outputs: none + * The isMsgQueueFull function determines whether a given message queue is full. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if the given queue is invalid. + * @details \b Inputs: msgQueueCounts[] + * @details \b Outputs: none * @param queue the message queue to check * @return TRUE if the given message queue is full, FALSE if not *************************************************************************/ @@ -199,8 +206,8 @@ /*********************************************************************//** * @brief * The blankMessage function blanks a given message. - * @details Inputs: none - * @details Outputs: given message is blanked + * @details \b Inputs: none + * @details \b Outputs: given message is blanked * @param message Pointer to the message to blank * @return none *************************************************************************/ @@ -220,8 +227,8 @@ /*********************************************************************//** * @brief * The blankMessageInWrapper function blanks a given message in a wrapper. - * @details Inputs: none - * @details Outputs: given wrapped message is blanked + * @details \b Inputs: none + * @details \b Outputs: given wrapped message is blanked * @param message Pointer to the message in a wrapper to blank * @return none *************************************************************************/ Index: firmware/App/Services/MsgQueues.h =================================================================== diff -u -r1631728a0f2506fb4e29c5f6c6e1a5f55018caab -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision 1631728a0f2506fb4e29c5f6c6e1a5f55018caab) +++ firmware/App/Services/MsgQueues.h (.../MsgQueues.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,7 +23,7 @@ /** * @defgroup MsgQueues MsgQueues - * @brief The message queues module provides queuing services for + * @brief The message queues unit provides queuing services for * incoming CAN messages. * * @addtogroup MsgQueues @@ -65,6 +65,7 @@ MESSAGE_T msg; ///< Message U08 crc; ///< Message CRC } MESSAGE_WRAPPER_T; + #pragma pack(pop) #define MESSAGE_OVERHEAD_SIZE (sizeof(MESSAGE_HEADER_T) + sizeof(U08)) ///< Byte size of a message's overhead (fixed at 6 bytes). Index: firmware/App/Services/SystemCommTD.c =================================================================== diff -u -r3b3713c0d5445b83f339021972728ff58bd3e6e5 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/SystemCommTD.c (.../SystemCommTD.c) (revision 3b3713c0d5445b83f339021972728ff58bd3e6e5) +++ firmware/App/Services/SystemCommTD.c (.../SystemCommTD.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -15,15 +15,15 @@ * ***************************************************************************/ -#include #include // For memcpy() #include "can.h" #include "sci.h" #include "sys_dma.h" #include "Comm.h" -#include "Interrupts.h" +#include "Interrupts.h" +#include "Messaging.h" #include "OperationModes.h" #include "SystemCommTD.h" #include "Timers.h" @@ -36,57 +36,58 @@ // ********** private definitions ********** -#define UI_COMM_TIMEOUT_IN_MS 7500 ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD. +#define UI_COMM_TIMEOUT_IN_MS 7500 ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD. #define UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS (2 * SEC_PER_MIN * MS_PER_SECOND) ///< Maximum time (in ms) that UI is allowed to wait before checking in with HD when in service mode. -#define DG_COMM_TIMEOUT_IN_MS 1000 ///< DG has not checked in for this much time +#define DG_COMM_TIMEOUT_IN_MS 1000 ///< DG has not checked in for this much time -#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm #define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window -#define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm +#define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm #define MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< FPGA clock speed error window -// ********** private data ********** - /// Array of out-going CAN buffers. -const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = -{ - COMM_BUFFER_OUT_CAN_TD_ALARM, - COMM_BUFFER_OUT_CAN_TD_2_DD, - COMM_BUFFER_OUT_CAN_TD_2_UI, - COMM_BUFFER_OUT_CAN_TD_BROADCAST, - COMM_BUFFER_OUT_CAN_PC -}; - +const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = +{ + COMM_BUFFER_OUT_CAN_TD_ALARM, + COMM_BUFFER_OUT_CAN_TD_2_DD, + COMM_BUFFER_OUT_CAN_TD_2_UI, + COMM_BUFFER_OUT_CAN_TD_BROADCAST, + COMM_BUFFER_OUT_CAN_PC +}; + /// Array of in-coming CAN buffers. -const COMM_BUFFER_T CAN_IN_BUFFERS[ NUM_OF_CAN_IN_BUFFERS ] = -{ +const COMM_BUFFER_T CAN_IN_BUFFERS[ NUM_OF_CAN_IN_BUFFERS ] = +{ COMM_BUFFER_IN_CAN_DD_ALARM, - COMM_BUFFER_IN_CAN_RO_ALARM, - COMM_BUFFER_IN_CAN_UI_ALARM, - COMM_BUFFER_IN_CAN_DD_2_TD, + COMM_BUFFER_IN_CAN_RO_ALARM, + COMM_BUFFER_IN_CAN_UI_ALARM, + COMM_BUFFER_IN_CAN_DD_2_TD, COMM_BUFFER_IN_CAN_UI_2_TD, COMM_BUFFER_IN_CAN_DD_BROADCAST, - COMM_BUFFER_IN_CAN_RO_BROADCAST, - COMM_BUFFER_IN_CAN_UI_BROADCAST, - COMM_BUFFER_IN_CAN_PC, -}; + COMM_BUFFER_IN_CAN_RO_BROADCAST, + COMM_BUFFER_IN_CAN_UI_BROADCAST, + COMM_BUFFER_IN_CAN_PC, +}; + +// ********** private data ********** -static volatile BOOL tdIsOnlyCANNode = TRUE; ///< Flag indicating whether HD is alone on CAN bus. -static volatile BOOL ddIsCommunicating = FALSE; ///< Has DD sent a message since last check -static U32 timeOfLastDGCheckIn = 0; ///< Last time DG checked in -static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check -static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in -static volatile BOOL uiDidCommunicate = FALSE; ///< Has UI every sent a message +static volatile BOOL tdIsOnlyCANNode = TRUE; ///< Flag indicating whether HD is alone on CAN bus. +static volatile BOOL ddIsCommunicating = FALSE; ///< Has DD sent a message since last check +static U32 timeOfLastDDCheckIn = 0; ///< Last time DD checked in +static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check +static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in +static volatile BOOL uiDidCommunicate = FALSE; ///< Has UI every sent a message // ********** private function prototypes ********** /*********************************************************************//** * @brief - * The initSystemCommTD function initializes the SystemComm module. - * @details Inputs: none - * @details Outputs: SystemComm module initialized. + * The initSystemCommTD function initializes the system communication unit + * for the TD firmware. + * @details \b Inputs: none + * @details \b Outputs: SystemComm unit initialized. * @return none *************************************************************************/ void initSystemCommTD( void ) @@ -103,16 +104,16 @@ /*********************************************************************//** * @brief - * The checkInFromDG function checks in the DG with the HD - indicating that - * the DG is communicating. - * @details Inputs: none - * @details Outputs: ddIsCommunicating + * The checkInFromDG function checks in the DD with the TD - indicating that + * the DD is communicating. + * @details \b Inputs: none + * @details \b Outputs: ddIsCommunicating, timeOfLastDDCheckIn * @return none *************************************************************************/ void checkInFromDG( void ) { ddIsCommunicating = TRUE; - timeOfLastDGCheckIn = getMSTimerCount(); + timeOfLastDDCheckIn = getMSTimerCount(); if ( TRUE == isAlarmActive( ALARM_ID_TD_DD_COMM_TIMEOUT ) ) { @@ -122,17 +123,17 @@ /*********************************************************************//** * @brief - * The checkInFromUI function checks in the UI with the HD - indicating that + * The checkInFromUI function checks in the UI with the TD - indicating that * the UI is communicating. - * @details Inputs: none - * @details Outputs: uiIsCommunicating + * @details \b Inputs: none + * @details \b Outputs: uiIsCommunicating, timeOfLastUICheckIn, uiDidCommunicate * @return none *************************************************************************/ void checkInFromUI( void ) { if ( FALSE == uiDidCommunicate ) - { // Start DG check-in timer when UI first communicates - timeOfLastDGCheckIn = getMSTimerCount(); + { // Start DD check-in timer when UI first communicates + timeOfLastDDCheckIn = getMSTimerCount(); } uiIsCommunicating = TRUE; @@ -144,9 +145,9 @@ * @brief * The isDDCommunicating function determines whether the DD is communicating * with the TD. - * @details Inputs: ddIsCommunicating - * @details Outputs: none - * @return TRUE if DG has checked in since last call, FALSE if not + * @details \b Inputs: ddIsCommunicating + * @details \b Outputs: none + * @return TRUE if DD is communicating, FALSE if not *************************************************************************/ BOOL isDDCommunicating( void ) { @@ -156,9 +157,9 @@ /*********************************************************************//** * @brief * The isUICommunicating function determines whether the UI is communicating - * with the HD. - * @details Inputs: uiIsCommunicating - * @details Outputs: none + * with the TD. + * @details \b Inputs: uiIsCommunicating + * @details \b Outputs: uiIsCommunicating * @return TRUE if UI has checked in since last call, FALSE if not *************************************************************************/ BOOL isUICommunicating( void ) @@ -172,27 +173,24 @@ /*********************************************************************//** * @brief - * The uiCommunicated function determines whether the UI has communicated. - * @details Inputs: none - * @details Outputs: none + * The uiCommunicated function determines whether the UI has started communicating + * since power up. + * @details \b Inputs: uiDidCommunicate + * @details \b Outputs: none * @return TRUE if UI has communicated since power up, FALSE if not *************************************************************************/ BOOL uiCommunicated( void ) { -#ifdef SIMULATE_UI - uiDidCommunicate = TRUE; -#endif - return uiDidCommunicate; } /*********************************************************************//** * @brief - * The isOnlyCANNode function determines whether the HD is the only node + * The isOnlyCANNode function determines whether the TD is the only node * currently on the CAN bus. - * @details Inputs: tdIsOnlyCANNode - * @details Outputs: none - * @return TRUE if HD is only node on CAN bus, FALSE if not + * @details \b Inputs: tdIsOnlyCANNode + * @details \b Outputs: none + * @return TRUE if TD is only node on CAN bus, FALSE if not *************************************************************************/ BOOL isOnlyCANNode( void ) { @@ -201,11 +199,12 @@ /*********************************************************************//** * @brief - * The setOnlyCANNode function sets whether the HD is the only node + * The setOnlyCANNode function sets whether the TD is the only node * currently on the CAN bus. - * @details Inputs: none - * @details Outputs: tdIsOnlyCANNode - * @return only TRUE if HD is only node on CAN bus, FALSE if not + * @details \b Inputs: none + * @details \b Outputs: tdIsOnlyCANNode + * @param only Flag indicating whether the TD is the only node on the CAN bus. + * @return none *************************************************************************/ void setOnlyCANNode( BOOL only ) { @@ -215,8 +214,8 @@ /*********************************************************************//** * @brief * The clearCANXmitBuffers function clears all CAN transmit buffers. - * @details Inputs: CAN_OUT_BUFFERS[] - * @details Outputs: CAN transmit buffers cleared. + * @details \b Inputs: CAN_OUT_BUFFERS[] + * @details \b Outputs: CAN transmit buffers cleared. * @return none *************************************************************************/ void clearCANXmitBuffers( void ) @@ -229,38 +228,23 @@ } } - -/************************************************************************* -********************** TRANSMIT SUPPORT FUNCTIONS ************************ -*************************************************************************/ - - - -/************************************************************************* -********************** RECEIVE SUPPORT FUNCTIONS ************************* -*************************************************************************/ - - /*********************************************************************//** * @brief * The checkForCommTimeouts function checks for sub-system communication - * timeout errors. - * @details Inputs: timeOfLastDGCheckIn, timeOfLastUICheckIn - * @details Outputs: possibly a comm t/o alarm + * timeout errors. + * @details \b Alarm: ALARM_ID_TD_UI_COMM_TIMEOUT if UI no longer communicating. + * @details \b Alarm: ALARM_ID_TD_DD_COMM_TIMEOUT if DD no longer communicating. + * @details \b Inputs: timeOfLastDDCheckIn, timeOfLastUICheckIn + * @details \b Outputs: none * @return none *************************************************************************/ void checkForCommTimeouts( void ) { if ( TRUE == uiDidCommunicate ) { TD_OP_MODE_T opMode = getCurrentOperationMode(); - U32 uiTO_MS = UI_COMM_TIMEOUT_IN_MS; + U32 uiTO_MS = ( MODE_SERV == opMode ? UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS : UI_COMM_TIMEOUT_IN_MS ); - // in service mode, allow up to 2 minutes for UI to check-in (for lock-down) - if ( MODE_SERV == opMode ) - { - uiTO_MS = UI_COMM_SERVICE_MODE_TIMEOUT_IN_MS; - } if ( TRUE == didTimeout( timeOfLastUICheckIn, uiTO_MS ) ) { #ifndef _RELEASE_ @@ -271,9 +255,9 @@ } } - if ( TRUE == didTimeout( timeOfLastDGCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) + if ( TRUE == didTimeout( timeOfLastDDCheckIn, DG_COMM_TIMEOUT_IN_MS ) ) { -#ifndef RUN_WITHOUT_DG +#ifndef RUN_WITHOUT_DD // Only alarm on DG comm loss while in the treatment workflow if ( MODE_PRET == opMode || MODE_TREA == opMode || MODE_POST == opMode ) { @@ -294,10 +278,12 @@ /*********************************************************************//** * @brief * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs - * within a set period of time. Assumed function is being called when a new - * bad CRC is detected so a new bad CRC will be added to the list. - * @details Inputs: badCRCTimeStamps[], badCRCListIdx, badCRCListCount - * @details Outputs: possibly a "too many bad CRCs" alarm + * within a set period of time. + * @note Assumed function is being called when a new bad CRC is detected. + * @details \b Alarm: ALARM_ID_TD_COMM_TOO_MANY_BAD_CRCS if too many (5) bad + * CRCs detected in the last 10 minutes. + * @details \b Inputs: none + * @details \b Outputs: none * @return none *************************************************************************/ void checkTooManyBadMsgCRCs( void ) @@ -310,11 +296,13 @@ /*********************************************************************//** * @brief - * The getInBufferID function gets the buffer ID for a given buffer index. - * @details Inputs: CAN_IN_BUFFERS[] - * @details Outputs: none + * The getInBufferID function gets the incoming communication buffer ID for + * a given buffer index. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer index is invalid. + * @details \b Inputs: CAN_IN_BUFFERS[] + * @details \b Outputs: none * @param idx incoming buffer index (e.g. 0 indicates first incoming buffer) - * @return buffer id associated with given incoming buffer index + * @return ID of buffer associated with given incoming buffer index *************************************************************************/ COMM_BUFFER_T getInBufferID( U32 idx ) { @@ -327,19 +315,21 @@ } else { - // TODO - s/w fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX1, idx ) } return result; } /*********************************************************************//** * @brief - * The getOutBufferID function gets the buffer ID for a given buffer index. - * @details Inputs: CAN_OUT_BUFFERS[] - * @details Outputs: none + * The getOutBufferID function gets the outgoing communication buffer ID for + * a given buffer index. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer index is invalid. + * @details \b Inputs: CAN_OUT_BUFFERS[] + * @details \b Outputs: none * @param idx outgoing buffer index (e.g. 0 indicates first outgoing buffer) - * @return buffer id associated with given outgoing buffer index + * @return ID of buffer associated with given outgoing buffer index *************************************************************************/ COMM_BUFFER_T getOutBufferID( U32 idx ) { @@ -352,7 +342,7 @@ } else { - // TODO - s/w fault + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX2, idx ) } return result; @@ -362,9 +352,9 @@ /*********************************************************************//** * @brief * The processReceivedMessage function processes a given message. - * @details Inputs: none - * @details Outputs: message processed - * @param message pointer to message to process + * @details \b Inputs: none + * @details \b Outputs: message processed + * @param message Pointer to the message to process. * @return none *************************************************************************/ void processReceivedMessage( MESSAGE_T *message ) Index: firmware/App/Services/SystemCommTD.h =================================================================== diff -u -r3b3713c0d5445b83f339021972728ff58bd3e6e5 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Services/SystemCommTD.h (.../SystemCommTD.h) (revision 3b3713c0d5445b83f339021972728ff58bd3e6e5) +++ firmware/App/Services/SystemCommTD.h (.../SystemCommTD.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -18,26 +18,26 @@ #ifndef __SYSTEM_COMM_TD_H__ #define __SYSTEM_COMM_TD_H__ -#include "../TDCommon.h" +#include "TDCommon.h" #include "CommBuffers.h" #include "MsgQueues.h" #include "SystemComm.h" /** * @defgroup SystemCommTD SystemCommTD - * @brief System communication module. Manages incoming and outgoing CAN frames. + * @brief System communication unit. Manages incoming and outgoing CAN frames. * * @addtogroup SystemCommTD * @{ */ // ********** public definitions ********** -#define MAX_MSG_SEQ_NO 0x7FFF ///< Maximum sequence number for Denali message (then wraps to 1). -#define MIN_MSG_SEQ_NO 0x0001 ///< Minimum sequence number for Denali message. +#define MAX_MSG_SEQ_NO 0x7FFF ///< Maximum sequence number for Denali message (then wraps to 1). +#define MIN_MSG_SEQ_NO 0x0001 ///< Minimum sequence number for Denali message. -#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit -#define NUM_OF_CAN_IN_BUFFERS 9 ///< Number of CAN buffers for receiving +#define NUM_OF_CAN_OUT_BUFFERS 5 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 9 ///< Number of CAN buffers for receiving // ********** public function prototypes ********** @@ -46,18 +46,19 @@ COMM_BUFFER_T getInBufferID( U32 idx ); COMM_BUFFER_T getOutBufferID( U32 idx ); + void checkForCommTimeouts( void ); void checkTooManyBadMsgCRCs( void ); void checkInFromDG( void ); -void checkInFromUI( void ); +void checkInFromUI( void ); + BOOL isDDCommunicating( void ); BOOL isUICommunicating( void ); BOOL uiCommunicated( void ); BOOL isOnlyCANNode( void ); void setOnlyCANNode( BOOL only ); void clearCANXmitBuffers( void ); - /**@}*/ #endif Index: firmware/App/Tasks/TaskBG.c =================================================================== diff -u -rf688e0f8bded1f0a687437e3136cfba8b14f87b6 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision f688e0f8bded1f0a687437e3136cfba8b14f87b6) +++ firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -42,9 +42,10 @@ /*********************************************************************//** * @brief * The taskBackground function handles the idle Background Task loop. - * Calls the Watchdog Mgmt. and NonVolatile Data services. - * @details Inputs: none - * @details Outputs: Executive for watchdog mgmt. and non-volatile data services called. + * @details \b Alarm: ALARM_ID_TD_UI_COMM_POST_FAILED if UI has not started + * communicating within 2 minutes of power up. + * @details \b Inputs: none + * @details \b Outputs: Background task functions are called. * @return none *************************************************************************/ void taskBackground( void ) Index: firmware/App/Tasks/TaskBG.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskBG.h (.../TaskBG.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Tasks/TaskBG.h (.../TaskBG.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -21,7 +21,10 @@ /** * @defgroup TaskBackground TaskBackground * @brief The background task is an infinite loop running in the background - * called by main() after initialization. + * called by main() after initialization. The background task executes + * functions that may take a long time to complete or are very low priority. + * This includes non-volatile memory operations, battery monitoring and + * watchdog management. * * @addtogroup TaskBackground * @{ Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r3321a6fc6f08b731cfe3dafaa618f93b32acaf45 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 3321a6fc6f08b731cfe3dafaa618f93b32acaf45) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -34,8 +34,8 @@ * The taskGeneral function handles the scheduled General Task interrupt. * Calls the executive functions for most monitors and controllers, the * operation modes, the system communications, and alarms. - * @details Inputs: none - * @details Outputs: Executives running in general task are called. + * @details \b Inputs: none + * @details \b Outputs: Executive functions running in general task are called. * @return none *************************************************************************/ void taskGeneral( void ) Index: firmware/App/Tasks/TaskGeneral.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskGeneral.h (.../TaskGeneral.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Tasks/TaskGeneral.h (.../TaskGeneral.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -23,7 +23,7 @@ /** * @defgroup TaskGeneral TaskGeneral * @brief The general task is called by RTI interrupt every 50 ms and performs - * the bulk of sensor, actuator, mode, alarm & communication operations. + * the bulk of sensor, actuator, mode, alarm, and communication operations. * * @addtogroup TaskGeneral * @{ Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r36d1ef937465bb38a3ec80c329bd933fb3daeda5 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 36d1ef937465bb38a3ec80c329bd933fb3daeda5) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -15,6 +15,7 @@ * ***************************************************************************/ +#include "FluidLeak.h" #include "FPGA.h" #include "SystemCommTD.h" #include "TaskPriority.h" @@ -29,8 +30,8 @@ * @brief * The taskPriority function handles the scheduled Priority Task interrupt. * Calls the executive functions for FPGA, pumps, valves, and buttons. - * @details Inputs: none - * @details Outputs: Executives running in priority task are called. + * @details \b Inputs: none + * @details \b Outputs: Executive functions running in priority task are called. * @return none *************************************************************************/ void taskPriority( void ) @@ -70,7 +71,7 @@ // execBloodFlowMonitor(); // Monitor fluid leak detector -// execFluidLeak(); + execFluidLeak(); // Monitor air bubble detector // execBubble(); Index: firmware/App/Tasks/TaskPriority.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Tasks/TaskPriority.h (.../TaskPriority.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -21,7 +21,7 @@ /** * @defgroup TaskPriority TaskPriority * @brief The priority task is called by RTI interrupt every 10 ms and performs - * high priority and/or more urgent sensor/actuator processing as well as the + * high priority and/or urgent sensor/actuator processing as well as the * interface to the FPGA. * * @addtogroup TaskPriority Index: firmware/App/Tasks/TaskTimer.c =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Tasks/TaskTimer.c (.../TaskTimer.c) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -15,7 +15,9 @@ * ***************************************************************************/ -//#include "CPLD.h" +#ifdef TASK_TIMING_OUTPUT_ENABLED +#include "CpldInterface.h" +#endif #include "TaskTimer.h" #include "WatchdogMgmt.h" #include "Timers.h" @@ -30,8 +32,8 @@ * The taskTimer function handles the scheduled Timer Task interrupt. * Calls the Timers executive to maintain a 1ms timer counter to * support timer and timeout functions. - * @details Inputs: none - * @details Outputs: Executive for Timers called. + * @details \b Inputs: none + * @details \b Outputs: Executive function for Timers is called. * @return none *************************************************************************/ void taskTimer( void ) Index: firmware/App/Tasks/TaskTimer.h =================================================================== diff -u -r73d8423edc56daed591bc0b3f7baee5540aea423 -r3518e8a088c32e75c0c8960d5e629a7401095feb --- firmware/App/Tasks/TaskTimer.h (.../TaskTimer.h) (revision 73d8423edc56daed591bc0b3f7baee5540aea423) +++ firmware/App/Tasks/TaskTimer.h (.../TaskTimer.h) (revision 3518e8a088c32e75c0c8960d5e629a7401095feb) @@ -21,7 +21,7 @@ /** * @defgroup TaskTimer TaskTimer * @brief Timer task is called by RTI interrupt every 1 ms to update the - * ms timer counter. + * millisecond timer counter. * * @addtogroup TaskTimer * @{