Index: firmware/.launches/DG.launch =================================================================== diff -u -ra504d6899e709d7432af9c055db1bd1fe340d032 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/.launches/DG.launch (.../DG.launch) (revision a504d6899e709d7432af9c055db1bd1fe340d032) +++ firmware/.launches/DG.launch (.../DG.launch) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -1,40 +1,10 @@ - - -<<<<<<< HEAD - - - - - - - - - - - - - - - - - - - + - - - - - - - - - Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -rbe027f8c9bee75f07267f7a9ab5635bbb02df86e -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision be027f8c9bee75f07267f7a9ab5635bbb02df86e) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -231,7 +231,9 @@ if ( primaryHeaterTargetTemperature >= MINIMUM_TARGET_TEMPERATURE && primaryHeaterTargetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) { +#ifndef DISABLE_HEATERS_AND_TEMPS hasStartPrimaryHeaterRequested = TRUE; +#endif status = TRUE; } @@ -256,7 +258,9 @@ if ( trimmerHeaterTargetTemperature >= MINIMUM_TARGET_TEMPERATURE && trimmerHeaterTargetTemperature <= MAXIMUM_TARGET_TEMPERATURE ) { +#ifndef DISABLE_HEATERS_AND_TEMPS hasStartTrimmerHeaterRequested = TRUE; +#endif status = TRUE; } @@ -836,6 +840,7 @@ (U32)(trimmerHeaterDutyCycle*100) ); //NOTE: This section will be removed #ifdef DEBUG_ENABLED +#ifdef HEATERS_DEBUG { char debugTempStr[ 256 ]; // TODO: clean up. @@ -884,6 +889,7 @@ sendDebugData ( (U08*)debugTempStr, strlen(debugTempStr) ); } #endif +#endif dataPublicationTimerCounter = 0; } } Index: firmware/App/Controllers/LoadCell.c =================================================================== diff -u -rc081112c61e0d85854e8f1e604ac7f1f37c2ec02 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision c081112c61e0d85854e8f1e604ac7f1f37c2ec02) +++ firmware/App/Controllers/LoadCell.c (.../LoadCell.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -30,8 +30,8 @@ #define LOAD_CELL_SAMPLES_TO_AVERAGE LOAD_CELL_REPORT_PERIOD ///< Averaging load cell data over the reporting interval. #define LOAD_CELL_AVERAGE_MULTIPLIER (1.0 / (F32)LOAD_CELL_SAMPLES_TO_AVERAGE) ///< Optimization - multiplying is faster than dividing. // TODO - gain and offset for load cells should be read from NV Data calibration record. -#define ADC2GRAM (0.0894 * 1.1338) // Conversion factor from ADC counts to grams. Division for averaging is folded into this value. -#define LOAD_CELL_ZERO_OFFSET -1018.02 // Zero offset (in grams). TODO - right now, this is empty reservoir weight. +#define ADC2GRAM (0.0894 * 1.1338) ///< Conversion factor from ADC counts to grams. Division for averaging is folded into this value. +#define LOAD_CELL_ZERO_OFFSET -1215.0 ///< Zero offset (in grams). TODO - right now, this is empty reservoir weight. // ********** private data ********** Index: firmware/App/Controllers/Pressures.c =================================================================== diff -u -rebd11d01f826a08806d2f4984bd57e829371b687 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision ebd11d01f826a08806d2f4984bd57e829371b687) +++ firmware/App/Controllers/Pressures.c (.../Pressures.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -300,6 +300,7 @@ broadcastPressureSensorsData( roIn, roOut, drainIn, drainOut ); pressuresDataPublicationTimerCounter = 0; #ifdef DEBUG_ENABLED +#ifdef PRESSURES_DEBUG { // TODO - temporary debug code - remove later F32 lc1 = getLoadCellFilteredWeight(LOAD_CELL_A1); @@ -310,6 +311,7 @@ sendDebugData( (U08*)debugPresStr, strlen(debugPresStr) ); } #endif +#endif } } Index: firmware/App/DGCommon.h =================================================================== diff -u -r3cc737c39b4440e18abab95ef2f8b6aef13acba9 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/DGCommon.h (.../DGCommon.h) (revision 3cc737c39b4440e18abab95ef2f8b6aef13acba9) +++ firmware/App/DGCommon.h (.../DGCommon.h) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -33,7 +33,11 @@ // #define RM46_EVAL_BOARD_TARGET 1 // #define SIMULATE_UI 1 // #define CAN_TEST 1 +// #define DISABLE_HEATERS_AND_TEMPS 1 // #define ENABLE_DIP_SWITCHES 1 + #define ALARMS_DEBUG 1 +// #define HEATERS_DEBUG 1 +// #define PRESSURES_DEBUG 1 #include #include #endif Index: firmware/App/Drivers/InternalADC.c =================================================================== diff -u -rebd11d01f826a08806d2f4984bd57e829371b687 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision ebd11d01f826a08806d2f4984bd57e829371b687) +++ firmware/App/Drivers/InternalADC.c (.../InternalADC.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -105,7 +105,7 @@ } /*********************************************************************//** - * @brief adcNotification + * @brief * The adcNotification function handles an ADC conversion complete interrupt. \n * All channel readings in the FIFO are retrieved. * @details Index: firmware/App/Services/AlarmMgmt.c =================================================================== diff -u -r68fc03b5a22f14190146fc9069f022c109682b63 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 68fc03b5a22f14190146fc9069f022c109682b63) +++ firmware/App/Services/AlarmMgmt.c (.../AlarmMgmt.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -99,14 +99,6 @@ { // activate alarm alarmIsActive[ alarm ].data = TRUE; -#ifdef DEBUG_ENABLED - { - // TODO - temporary debug code - remove later - char debugStr[ 256 ]; - sprintf( debugStr, "ALARM triggered:%5d \n", alarm ); - sendDebugData( (U08*)debugStr, strlen(debugStr) ); - } -#endif } } else @@ -135,6 +127,16 @@ broadcastAlarmTriggered( (U16)alarm, blankAlarmData, blankAlarmData ); } activateAlarm( alarm ); +#ifdef DEBUG_ENABLED +#ifdef ALARMS_DEBUG + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM triggered:%5d \n", alarm ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + } +#endif +#endif } /************************************************************************* @@ -157,6 +159,16 @@ broadcastAlarmTriggered( (U16)alarm, alarmData, blankAlarmData ); } activateAlarm( alarm ); +#ifdef DEBUG_ENABLED +#ifdef ALARMS_DEBUG + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM triggered:%5d %8X \n", alarm, alarmData.data.uInt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + } +#endif +#endif } /************************************************************************* @@ -180,6 +192,16 @@ broadcastAlarmTriggered( (U16)alarm, alarmData1, alarmData2 ); } activateAlarm( alarm ); +#ifdef DEBUG_ENABLED +#ifdef ALARMS_DEBUG + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM triggered:%5d %8X %8X \n", alarm, alarmData1.data.uInt, alarmData2.data.uInt ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + } +#endif +#endif } /************************************************************************* @@ -202,6 +224,16 @@ { broadcastAlarmCleared( alarm ); alarmIsActive[ alarm ].data = FALSE; +#ifdef DEBUG_ENABLED +#ifdef ALARMS_DEBUG + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "ALARM cleared:%5d \n", alarm ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + } +#endif +#endif } } else Index: firmware/App/Services/CommBuffers.c =================================================================== diff -u -rc4434389fe6c3314c2bba98dc2f4cf737551f637 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision c4434389fe6c3314c2bba98dc2f4cf737551f637) +++ firmware/App/Services/CommBuffers.c (.../CommBuffers.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -23,26 +23,31 @@ #include // for memcpy() #include "CommBuffers.h" +#include "SystemCommMessages.h" +#include "Timers.h" // ********** private definitions ********** #define COMM_BUFFER_LENGTH 512 // max bytes in each comm buffer (double if you count double buffers) #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 volatile BOOL bufferGetLock[ NUM_OF_COMM_BUFFERS ]; // prevent getter from accessing active buffer while add in progress +static U32 firstBufferOverflowTimeStamp = 0; // time stamp of a prior overflow event - allows for an overflow persistence check // ********** private function prototypes ********** +static void clearBuffer( COMM_BUFFER_T buffer ); static U32 switchDoubleBuffer( COMM_BUFFER_T buffer ); static void getDataFromInactiveBuffer( COMM_BUFFER_T buffer, U08 *data, U32 len ); /************************************************************************* - * @brief initCommBuffers + * @brief * The initCommBuffers function initializes the CommBuffers module. * @details * Inputs : none @@ -52,25 +57,46 @@ *************************************************************************/ void initCommBuffers( void ) { - S32 b,d,i; + S32 b; // reset and zero out all buffers for ( b = 0; b < NUM_OF_COMM_BUFFERS; b++ ) { - activeDoubleBuffer[ b ] = 0; + clearBuffer( (COMM_BUFFER_T)b ); + } +} + +/************************************************************************* + * @brief + * The clearBuffer function clears (empties) a given buffer. \n + * Caller should ensure buffer won't be used while this function is clearing \n + * the buffer. + * @details + * Inputs : none + * Outputs : given buffer is cleared. + * @param buffer : the buffer to clear + * @return none + *************************************************************************/ +static void clearBuffer( COMM_BUFFER_T buffer ) +{ + if ( buffer < NUM_OF_COMM_BUFFERS ) + { + S32 d,i; + + activeDoubleBuffer[ buffer ] = 0; for ( d = 0; d < DOUBLE_BUFFERS; d++ ) { - commBufferByteCount[ b ][ d ] = 0; + commBufferByteCount[ buffer ][ d ] = 0; for ( i = 0; i < COMM_BUFFER_LENGTH; i++ ) { - commBuffers[ b ][ d ][ i ] = 0; + commBuffers[ buffer ][ d ][ i ] = 0; } } } } /************************************************************************* - * @brief addToCommBuffer + * @brief * The addToCommBuffer function adds data of specified length to a specified \n * communication buffer. S/W fault if buffer too full to add data. \n * This function will always add to the active double buffer. \n @@ -119,15 +145,43 @@ else // buffer too full to add this much data { bufferFull = TRUE; + clearBuffer( buffer ); } // release thread protection bufferGetLock[ buffer ] = FALSE; _enable_IRQ(); - // if buffer was full, trigger s/w fault + // if buffer was full, check persistence - trigger s/w fault if persists if ( TRUE == bufferFull ) { - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_ADD_TOO_MUCH_DATA, len ) + // not first overflow? + if ( firstBufferOverflowTimeStamp != 0 ) + { + // if buffer overflows persists, fault + if ( calcTimeSince( firstBufferOverflowTimeStamp ) > BUFFER_OVERFLOW_PERSISTENCE_MS ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_SOFTWARE_FAULT, SW_FAULT_ID_COMM_BUFFERS_ADD_TOO_MUCH_DATA, len ) + } + } + else // first overflow - set time stamp for persistence check + { + firstBufferOverflowTimeStamp = getMSTimerCount(); + } +#ifdef DEBUG_ENABLED + { + // TODO - temporary debug code - remove later + char debugStr[ 256 ]; + sprintf( debugStr, "Comm Buffer Overflow:%5d \n", (U32)buffer ); + sendDebugData( (U08*)debugStr, strlen(debugStr) ); + } +#endif } + else + { // if good for persistence time period, reset persistence check + if ( ( firstBufferOverflowTimeStamp != 0 ) && ( calcTimeSince( firstBufferOverflowTimeStamp ) > BUFFER_OVERFLOW_PERSISTENCE_MS ) ) + { + firstBufferOverflowTimeStamp = 0; + } + } } else // invalid buffer given { @@ -138,7 +192,7 @@ } /************************************************************************* - * @brief getFromCommBuffer + * @brief * The getFromCommBuffer function fills a given byte array with a given \n * number of bytes from a given buffer and returns the number of bytes \n * retrieved from the buffer. This function will draw from the inactive \n @@ -199,7 +253,7 @@ } /************************************************************************* - * @brief peekFromCommBuffer + * @brief * The peekFromCommBuffer function fills a given byte array with a given \n * number of bytes from a given buffer. This function does NOT consume \n * the bytes - it only peeks at them. A call to numberOfBytesInCommBuffer() \n @@ -257,7 +311,7 @@ } /************************************************************************* - * @brief numberOfBytesInCommBuffer + * @brief * The numberOfBytesInCommBuffer function determines how many bytes \n * are currently contained in a given comm buffer. Both double buffers \n * are considered for this. @@ -295,7 +349,7 @@ } /************************************************************************* - * @brief switchDoubleBuffer + * @brief * The switchDoubleBuffer function switches the active and inactive buffers \n * for the given buffer. \n * This function should only be called when the current inactive buffer has \n @@ -321,7 +375,7 @@ } /************************************************************************* - * @brief getDataFromInactiveBuffer + * @brief * The getDataFromInactiveBuffer function retrieves a given number of bytes \n * from the inactive buffer of a given buffer. This function should only be \n * called by getFromCommBuffer(). Params will be pre-validated there. Index: firmware/App/Services/SystemCommMessages.c =================================================================== diff -u -r9e114bbc273088bff2739e8ea54d3af66b6cd141 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 9e114bbc273088bff2739e8ea54d3af66b6cd141) +++ firmware/App/Services/SystemCommMessages.c (.../SystemCommMessages.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -30,17 +30,12 @@ #include "ROPump.h" #include "RTC.h" #include "SystemComm.h" +#include "SafetyShutdown.h" +#include "SystemCommMessages.h" +#include "TemperatureSensors.h" #include "Utilities.h" #include "Valves.h" #include "WatchdogMgmt.h" -#include "SystemCommMessages.h" -#include "SafetyShutdown.h" -#include "Utilities.h" -#include "SystemComm.h" -#include "RTC.h" -#include "LoadCell.h" -#include "TemperatureSensors.h" -#include "Heaters.h" // ********** private definitions ********** Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r3cc737c39b4440e18abab95ef2f8b6aef13acba9 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 3cc737c39b4440e18abab95ef2f8b6aef13acba9) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -56,12 +56,14 @@ // manage time-based reservoir tasks execReservoirs(); +#ifndef DISABLE_HEATERS_AND_TEMPS // Primary heaters state machine execPrimaryHeaters(); // Trimmer heater state machine execTrimmerHeater(); #endif +#endif // run operation mode state machine execOperationModes(); Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r3cc737c39b4440e18abab95ef2f8b6aef13acba9 -r1d44cf33cf4461b81b19a8ab0e402c609649786b --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 3cc737c39b4440e18abab95ef2f8b6aef13acba9) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 1d44cf33cf4461b81b19a8ab0e402c609649786b) @@ -52,8 +52,10 @@ // monitor load cells execLoadCell(); +#ifndef DISABLE_HEATERS_AND_TEMPS // Temperature sensors read execTemperatureSensors(); +#endif // control valves execValves();