Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -r5c53288436774f0cf6a24132ace29a64a66d619d -r0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 5c53288436774f0cf6a24132ace29a64a66d619d) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 0f4fbb2a56cdbe35dcedd9cad23867fd7248f86e) @@ -176,6 +176,9 @@ static const U32 TWO_TO_POWER_OF_8 = ( 1 << 8 ); ///< 2^8. static const U32 TWO_TO_POWER_OF_23 = ( 1 << 23 ); ///< 2^23. +static U32 temporaryTODORemove[2][ 300 ]; +static U32 temporaryIdx = 0; + // ********** private function prototypes ********** static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ); @@ -325,6 +328,8 @@ // When the FPGA read count does not increment for a period of time, it is considered as an internal error of the temperature sensors // driver. This is internal because FPGA does not error out if the FPGA read count does not increment. initPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ); + + initFPGAPersistentAlarm( TWO_WIRE_ADC_TEMP_SENSORS, ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS); } /*********************************************************************//** @@ -631,15 +636,15 @@ // Shift bits by 31 to right to check the error bit status tempSensors[ sensorIndex ].sensorErrorBitStatus = adc >> SHIFT_BITS_BY_31; - for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) + /*for ( i = 0; i < NUM_OF_TEMPERATURE_SENSORS; i++ ) { // If that bit is a 1, there is either CRC error or Status error that are ored on top of each other // NOTE: only a few sensors have the error bit available but for simplicity, all the sensors are looped. // This variable is zeroed in the init function and the sensors that do not use this bit are never checked ( and set) to // any other values so those sensors will never trigger this fault. // If any of the sensors have this bit to be 1, set the error occurred be 1 isTemperatureNotValid |= ( tempSensors[ i ].sensorErrorBitStatus > 0 ? TRUE : FALSE ); - } + }*/ #ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT // TODO for debugging only remove @@ -728,6 +733,7 @@ // Loop through all the sensors and read their FPGA error status isTemperatureNotValid |= tempSensors[ sensorIndex ].fpgaErrorStatus; } + #ifndef DISABLE_FPGA_ALARMS_UNTIL_THE_NEW_PERSISTENT checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSORS_FPGA_FAULT, isTemperatureNotValid, sensorIndex, TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ); @@ -851,9 +857,6 @@ // A delay to let FPGA to boot up else if ( TRUE == didTimeout( elapsedTime, ADC_FPGA_READ_DELAY ) ) { - // Once FPGA is ready get the barometric sensor's temperature conversion constants - baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); - baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); elapsedTime = 0; state = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; } @@ -875,12 +878,19 @@ U32 errorCount = 0; U32 readCount = 0; + // TODO remove + //temporaryTODORemove[0][temporaryIdx] = (U32)getFPGARTDErrorCount(); + //temporaryTODORemove[1][temporaryIdx] = (U32)getFPGARTDReadCount(); + //temporaryIdx = INC_WRAP(temporaryIdx, 0, 300); + // TODO remove + // Look at the error counter and the specific error flag to make sure the error is a temperature sensor // Add a byte array to have bits for each sensor to find out exactly what sensor failed - if ( ++fpgaRawADCReadInterval >= FPGA_RAW_ADC_READ_INTERVAL_COUNT ) + //if ( ++fpgaRawADCReadInterval >= FPGA_RAW_ADC_READ_INTERVAL_COUNT ) { errorCount = (U32)getFPGARTDErrorCount(); readCount = (U32)getFPGARTDReadCount(); + //checkFPGAPersistentAlarms( TWO_WIRE_ADC_TEMP_SENSORS, errorCount, readCount, TEMPSENSORS_INLET_PRIMARY_HEATER ); processTempSnsrsADCRead( TEMPSENSORS_INLET_PRIMARY_HEATER, getFPGATPiTemp(), errorCount, readCount, TRUE ); processTempSnsrsADCRead( TEMPSENSORS_OUTLET_PRIMARY_HEATER, getFPGATPoTemp(), errorCount, readCount, FALSE ); processTempSnsrsADCRead( TEMPSENSORS_CONDUCTIVITY_SENSOR_1, getFPGACD1Temp(), errorCount, readCount, FALSE ); @@ -895,6 +905,9 @@ processTempSnsrsADCRead( TEMPSENSORS_HEAT_DISINFECT, getFPGATHdTemp(), errorCount, readCount, TRUE ); processTempSnsrsADCRead( TEMPSENSORS_INTERNAL_THD_RTD, getFPGATHdInternalTemp(), errorCount, readCount, FALSE ); + // Once FPGA is ready get the barometric sensor's temperature conversion constants + baroConvConsts.refTemperature = getFPGABaroReferenceTemperature(); + baroConvConsts.temperatureCoeff = getFPGABaroTempCoeffOfTemperature(); errorCount = getFPGABaroErrorCount(); readCount = getFPGABaroReadCount(); processTempSnsrsADCRead( TEMPSENSORS_BAROMETRIC_TEMP_SENSOR, getFPGABaroTemperature(), errorCount, readCount, TRUE );