Index: firmware/App/Controllers/TemperatureSensors.c =================================================================== diff -u -re0eeafdfe3efec528a5ba8bb0f2f7c0f682b32da -r969ec174d1d6254ef5b7f90723d5b5313cfa3932 --- firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision e0eeafdfe3efec528a5ba8bb0f2f7c0f682b32da) +++ firmware/App/Controllers/TemperatureSensors.c (.../TemperatureSensors.c) (revision 969ec174d1d6254ef5b7f90723d5b5313cfa3932) @@ -86,6 +86,7 @@ #define TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 120.0 ///< Temperature sensors maximum allowed temperature in C. #define NON_FLUID_PATH_TEMP_SENSORS_MAX_ALLOWED_DEGREE_C 80.0 ///< Non fluid temperature sensors path maximum allowed temperature in C. #define TEMP_SENSORS_OUT_OF_RANGE_PERSISTENT_PEROID_MS ( 5 * MS_PER_SECOND ) ///< Temperature sensor out of range persistent period in milliseconds. +#define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. // The count cannot be within 0.1V of the rail on both sides therefore: // ADC count = ((2^12) - 1 / ref voltage) * voltage @@ -130,6 +131,7 @@ static U32 dataPublicationTimerCounter; ///< Temperature sensors data publish timer counter. static OVERRIDE_U32_T tempSensorsPublishInterval = { TEMP_SENSORS_DATA_PUBLISH_INTERVAL, TEMP_SENSORS_DATA_PUBLISH_INTERVAL, 0, 0 }; ///< Temperature sensors publish time interval override. +static DG_TEMP_SENSORS_CAL_RECORD_T tempSensorCalRecord; ///< Temperature sensors calibration record. static const F32 POSITIVE_TC_EXP_A0 = 0.118597600000E0; ///< K TC positive temperature exponent coefficient A0. static const F32 POSITIVE_TC_EXP_A1 = -0.118343200000E-3; ///< K TC positive temperature exponent coefficient A1. @@ -167,7 +169,7 @@ static BOOL isADCReadValid( U32 sensorIndex, U32 fpgaError, U32 fpgaCount ); static void processADCRead( U32 sensorIndex, S32 adc ); static void publishTemperatureSensorsData( void ); -static void monitorTemperatureSnsrs( U32 sensorIndex ); +static void monitorTemperatureSnsrs( U32 sensorIndex, F32 temperature ); /*********************************************************************//** * @brief @@ -186,7 +188,7 @@ tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; elapsedTime = 0; internalHeatersConversionTimer = 0; - dataPublicationTimerCounter = 0; + dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; fpgaRawADCReadInterval = 0; /* NOTE: The temperature sensors do not have conversion coefficient. @@ -303,14 +305,21 @@ *************************************************************************/ SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ) { - SELF_TEST_STATUS_T status = SELF_TEST_STATUS_IN_PROGRESS; + SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; - // TODO implement the calibration processing function. - // It returns a pass for now + BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMP_SENSORS, (U08*)&tempSensorCalRecord, sizeof( DG_TEMP_SENSORS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_TEMP_SENSORS, ALARM_ID_NO_ALARM ); - status = SELF_TEST_STATUS_PASSED; + if ( TRUE == calStatus ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + } - return status; + return result; } /*********************************************************************//** @@ -396,7 +405,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( OVERRIDE_KEY == tempSensors[ sensorIndex ].temperatureValues.override ) + if ( tempSensors[ sensorIndex ].temperatureValues.override == OVERRIDE_KEY ) { temperature = tempSensors[ sensorIndex ].temperatureValues.ovData; } @@ -736,7 +745,7 @@ tempSensors[ sensorIndex ].temperatureValues.data = temperature; // Monitor the temperature value - monitorTemperatureSnsrs( sensorIndex ); + monitorTemperatureSnsrs( sensorIndex, temperature ); } /*********************************************************************//** @@ -903,14 +912,17 @@ * @details Inputs: tempSensors * @details Outputs: tempSensors * @param sensorIndex the index of the temperature sensor + * @param temperature the temperature value to be checked * @return none *************************************************************************/ -static void monitorTemperatureSnsrs( U32 sensorIndex ) +static void monitorTemperatureSnsrs( U32 sensorIndex, F32 temperature ) { - F32 temperature = getTemperatureValue( sensorIndex ); + // The maximum allowed temperature is different for the sensors that are in the fluid path + // with the ones that are not in the fluid path + F32 maxLimit = tempSensors[ sensorIndex ].maxAllowedTemperature; // Check both temperature and to be in range - if ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > tempSensors[ sensorIndex ].maxAllowedTemperature ) ) + if ( ( temperature < TEMP_SENSORS_MIN_ALLOWED_DEGREE_C ) || ( temperature > maxLimit ) ) { // TODO investigate //checkPersistentAlarm( ALARM_ID_DG_TEMPERATURE_SENSOR_OUT_OF_RANGE, TRUE, sensorIndex, temperature ); @@ -939,7 +951,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensors[ sensorIndex ].temperatureValues.ovData = temperature; @@ -965,7 +977,7 @@ if ( sensorIndex < NUM_OF_TEMPERATURE_SENSORS ) { - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensors[ sensorIndex ].temperatureValues.override = OVERRIDE_RESET; @@ -989,7 +1001,7 @@ { BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { U32 interval = value / TASK_PRIORITY_INTERVAL; @@ -1013,7 +1025,7 @@ { BOOL result = FALSE; - if ( TRUE == isTestingActivated() ) + if ( isTestingActivated() ) { result = TRUE; tempSensorsPublishInterval.override = OVERRIDE_RESET;