Index: firmware/App/Controllers/Temperatures.c =================================================================== diff -u -r921034ee7092206a50183eacfaa73b436d2dee5f -r46b163d19c65e8c21db7b0247bbb1af0dba1ece5 --- firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 921034ee7092206a50183eacfaa73b436d2dee5f) +++ firmware/App/Controllers/Temperatures.c (.../Temperatures.c) (revision 46b163d19c65e8c21db7b0247bbb1af0dba1ece5) @@ -8,7 +8,7 @@ * @file Temperatures.c * * @author (last) Dara Navaei -* @date (last) 25-May-2022 +* @date (last) 01-Sep-2022 * * @author (original) Dara Navaei * @date (original) 01-Aug-2021 @@ -51,7 +51,7 @@ /// Temperatures exec states typedef enum thermistors_Exec_States { - TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE = 0, ///< Temperatures exec state wait for POST state. + TEMPERATURES_EXEC_STATE_START_STATE = 0, ///< Temperatures exec state start state. TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE, ///< Temperatures exec state get ADC values state. NUM_OF_TEMPERATURES_EXEC_STATES, ///< Number of temperatures exec state. } TEMPERATURES_EXEC_STATES_T; @@ -72,19 +72,17 @@ static U32 dataPublishCounter; ///< Temperatures data publish timer counter. static U32 adcReadCounter; ///< Temperatures ADC read counter. static HD_TEMP_SENSORS_CAL_RECORD_T temperaturesCalRecord; ///< Temperatures calibration record. -static BOOL isPOSTComplete; ///< Temperatures POST complete flag. static const F32 THERMISTOR_VOLTAGE_CONV_COEFF = THERMISTOR_REFERENCE_VOLTAGE / (F32)TWELVE_BIT_RESOLUTION; ///< On board thermistor ADC to voltage conversion coefficient. static const F32 ON_BOARD_THERMISTOR_REF_TEMP_INV = 1.0 / THERMISTOR_REFERENCE_TEMPERATURE; ///< On board thermistor reference inverse. static const F32 FGPA_BOARD_TEMP_CONVERSION_COEFF = 503.975 / (F32)TWELVE_BIT_RESOLUTION; ///< FPGA board temperature conversion coefficient. static const F32 VENOUS_ART_PRES_SENSOR_TEMP_CONV_COEFF = 200.0 / 2047.0; ///< Arterial and venous pressure sensor temperature conversion coefficient. static const F32 VENOUS_ART_PRES_SENSOR_TEMP_CONV_CONSTANT = 50.0; ///< Arterial and venous pressure sensor temperature conversion constant. -static const F32 ADC_BOARD_TEMP_SENSOR_CONVERSION_COEFF = 1.0 / 13584.0; ///< ADC board temperatures sensor conversion coefficient. // ********** private function prototypes ********** -static TEMPERATURES_EXEC_STATES_T handleExecWaitForPOST( void ); +static TEMPERATURES_EXEC_STATES_T handleExecStart( void ); static TEMPERATURES_EXEC_STATES_T handleExecGetADCValues( void ); static void monitorTemperatures( void ); @@ -105,9 +103,8 @@ { U08 i; - temperaturesExecState = TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE; + temperaturesExecState = TEMPERATURES_EXEC_STATE_START_STATE; dataPublishCounter = DATA_PUBLISH_COUNTER_START_COUNT; - isPOSTComplete = FALSE; for ( i = 0; i < NUM_OF_TEMPERATURES; i++ ) { @@ -123,17 +120,15 @@ * The execTemperaturesSelfTest function runs the temperatures POST during * the self-test. * @details Inputs: none - * @details Outputs: none - * @return execTemperaturesSelfTest which is the status of the self test + * @details Outputs: temperaturesCalRecord + * @return TRUE if the self test passed otherwise, FALSE *************************************************************************/ SELF_TEST_STATUS_T execTemperaturesSelfTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; + BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMPERATURE_SESNORS, (U08*)&temperaturesCalRecord, sizeof( HD_TEMP_SENSORS_CAL_RECORD_T ), + NUM_OF_CAL_DATA_HD_TEMP_SENSORS, ALARM_ID_NO_ALARM ); - BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMPERATURE_SESNORS, (U08*)&temperaturesCalRecord, sizeof( HD_TEMP_SENSORS_CAL_RECORD_T ), - NUM_OF_CAL_DATA_HD_TEMP_SENSORS, ALARM_ID_NO_ALARM ); - isPOSTComplete = TRUE; - if ( TRUE == calStatus ) { result = SELF_TEST_STATUS_PASSED; @@ -165,8 +160,8 @@ // Read the sensors all the time switch ( temperaturesExecState ) { - case TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE: - temperaturesExecState = handleExecWaitForPOST(); + case TEMPERATURES_EXEC_STATE_START_STATE: + temperaturesExecState = handleExecStart(); break; case TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE: @@ -194,8 +189,8 @@ /*********************************************************************//** * @brief - * The getThermistorTemperatureValue function returns the temperature of - * a requested thermistor or temperature sensor. + * The getTemperatureValue function returns the temperature of a requested + * thermistor or a temperature sensor. * @details Inputs: thermistorsStatus * @details Outputs: none * @param sensorID index to get its temperature value @@ -220,18 +215,18 @@ /*********************************************************************//** * @brief - * The handleExecWaitForPOST function handles the wait for POST state of the + * The handleExecStart function handles the start state of the * exec state machine. * @details Inputs: adcReadCounter * @details Outputs: adcReadCounter * @return next state of the exec state machine *************************************************************************/ -static TEMPERATURES_EXEC_STATES_T handleExecWaitForPOST( void ) +static TEMPERATURES_EXEC_STATES_T handleExecStart( void ) { - TEMPERATURES_EXEC_STATES_T state = TEMPERATURES_EXEC_STATE_WAIT_FOR_POST_STATE; + TEMPERATURES_EXEC_STATES_T state = TEMPERATURES_EXEC_STATE_START_STATE; // Give a short time for FPGA to boot up and start sending the ADC reads - if ( ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) && ( TRUE == isPOSTComplete ) ) + if ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) { adcReadCounter = 0; state = TEMPERATURES_EXEC_STATE_GET_ADC_VALUES_STATE; @@ -283,23 +278,21 @@ BOOL isTempOutOfRange = FALSE; F32 temperature = 0.0; U32 lastFaultSensor = 0; - F32 faultSensorTemp = 0.0; - for ( sensor = THERMISTOR_ONBOARD_NTC; sensor < NUM_OF_TEMPERATURES; sensor++ ) + if ( getCurrentOperationMode() != MODE_INIT ) { - temperature = getTemperatureValue( sensor ); - - if ( ( temperature > MAX_ALLOWED_TEMPERATURE ) || ( temperature < MIN_ALLOWED_TEMPERATURE ) ) + for ( sensor = THERMISTOR_ONBOARD_NTC; sensor < NUM_OF_TEMPERATURES; sensor++ ) { - isTempOutOfRange = TRUE; - lastFaultSensor = sensor; - faultSensorTemp = temperature; + temperature = getTemperatureValue( sensor ); + + if ( ( temperature > MAX_ALLOWED_TEMPERATURE ) || ( temperature < MIN_ALLOWED_TEMPERATURE ) ) + { + isTempOutOfRange |= TRUE; + lastFaultSensor = sensor; + } } - } - if ( TRUE == isPersistentAlarmTriggered( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, isTempOutOfRange ) ) - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, lastFaultSensor, faultSensorTemp ); + checkPersistentAlarm( ALARM_ID_HD_TEMPERATURES_OUT_OF_RANGE, isTempOutOfRange, lastFaultSensor, MAX_ALLOWED_TEMPERATURE ); } } @@ -352,9 +345,6 @@ #endif } - // TODO remove this code and the if statement. This configuration is until the new arterial sensor is implemented everywhere so the temperature calibration - // structure can be updated permanently. This way the PBA sensor will be replaced with the new arterial sensor. This is to make sure the - // calibration structure does not fail in different devices with different sensors temperaturesStatus[ sensor ].temperatureValue.data = temperature; // Apply the calibration record the temperature values prior to updating the structures temperaturesStatus[ sensor ].temperatureValue.data =