Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r6d85a90d2325163e936055a620a8b6aa1a6db65a --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 6d85a90d2325163e936055a620a8b6aa1a6db65a) @@ -15,11 +15,12 @@ * ***************************************************************************/ +#include "Conductivity.h" +#include "Flow.h" #include "Messaging.h" #include "MessageSupport.h" -#include "OperationModes.h" +#include "Pressure.h" #include "Temperature.h" -#include "Timers.h" #include "TaskPriority.h" #include "Utilities.h" @@ -29,32 +30,16 @@ */ // ********** private definitions ********** -#define ADC_FPGA_READ_DELAY 30U ///< Delay in ms before reading the ADC values from FPGA. -#define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. -#define TEMP_SENSORS_FPGA_ERROR_TIMEOUT_MS ( 2 * MS_PER_SECOND ) ///< Temperature sensors FPGA error timeout in milliseconds. +#define TEMP_SENSORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Temperature sensors publish data time interval. +#define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. -#define DATA_PUBLISH_COUNTER_START_COUNT 30 ///< Data publish counter start count. - -/// Temperature sensor exec states. -typedef enum tempSensors_Exec_States -{ - TEMPSENSORS_EXEC_STATE_START = 0, ///< Temperature sensors exec start - TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES, ///< Temperature sensors exec get ADC values - NUM_OF_TEMPSENSORS_EXEC_STATES, ///< Total number of exec states -} TEMPSENSORS_EXEC_STATES_T; - // ********** private data ********** -static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState; ///< TemperatureSensor exec state. -static U32 startTime; ///< star time to read FPGA values. -static U32 dataPublicationTimerCounter; ///< Temperature sensors data publish timer counter. -static OVERRIDE_U32_T tempSensorsPublishInterval; ///< Temperature sensors publish time interval override. - +static OVERRIDE_U32_T tempSensorsPublishInterval; ///< Temperature sensor data publication counter. +static U32 dataPublicationTimerCounter; ///< Timer counter used to schedule temp sensor data publication to CAN bus. // ********** private function prototypes ********** -static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ); -static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ); static void publishTemperatureSensorsData( void ); /*********************************************************************//** @@ -66,140 +51,33 @@ *************************************************************************/ void initTemperature( void ) { - startTime = 0; - tempSensorsExecState = TEMPSENSORS_EXEC_STATE_START; - dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; - - tempSensorsPublishInterval.data = TEMP_SENSORS_DATA_PUBLISH_INTERVAL; - tempSensorsPublishInterval.ovData = TEMP_SENSORS_DATA_PUBLISH_INTERVAL; - tempSensorsPublishInterval.ovInitData = 0; - tempSensorsPublishInterval.override = OVERRIDE_RESET; - - // Initialize the temperature sensors - initTemperatureSensors(); + dataPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + tempSensorsPublishInterval.data = TEMP_SENSORS_DATA_PUBLISH_INTERVAL; + tempSensorsPublishInterval.ovData = TEMP_SENSORS_DATA_PUBLISH_INTERVAL; + tempSensorsPublishInterval.ovInitData = 0; + tempSensorsPublishInterval.override = OVERRIDE_RESET; } /*********************************************************************//** * @brief - * The execTemperatureSensorsSelfTest function runs the TemperatureSensors - * POST during the self-test. - * @details \b Inputs: none - * @details \b Outputs: none - * @return tempSensorsSelfTestState which is the status of the self test - *************************************************************************/ -//SELF_TEST_STATUS_T execTemperatureSensorsSelfTest( void ) -//{ -// SELF_TEST_STATUS_T result = SELF_TEST_STATUS_IN_PROGRESS; -// -// //BOOL calStatus = getNVRecord2Driver( GET_CAL_TEMP_SENSORS, (U08*)&tempSensorCalRecord, sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), -// // NUM_OF_CAL_DATA_TEMP_SENSORS, ALARM_ID_DD_TEMPERATURE_SENSORS_INVALID_CAL_RECORD ); -// BOOL calStatus = TRUE; -// -// if ( TRUE == calStatus ) -// { -// result = SELF_TEST_STATUS_PASSED; -// } -// else -// { -// result = SELF_TEST_STATUS_FAILED; -// } -// -// return result; -//} - -/*********************************************************************//** - * @brief * The execTemperatureSensors function executes the temperature sensors' * state machine. - * @details \b Inputs: tempSensorsExecState - * @details \b Outputs: tempSensorsExecState - * @details \b Alarms: ALARM_ID_DD_SOFTWARE_FAULT when invalid temperature - * sensor state is seen. + * @details \b Inputs: none + * @details \b Outputs: none * @return none *************************************************************************/ void execTemperatureSensors( void ) { - // Check if a new calibration is available -// if ( TRUE == isNewCalibrationRecordAvailable() ) -// { -// getNVRecord2Driver( GET_CAL_TEMP_SENSORS, (U08*)&tempSensorCalRecord, sizeof( DD_TEMP_SENSORS_CAL_RECORD_T ), -// NUM_OF_CAL_DATA_TEMP_SENSORS, ALARM_ID_DD_TEMPERATURE_SENSORS_INVALID_CAL_RECORD ); -// } - - // Read the sensors all the time - switch ( tempSensorsExecState ) - { - case TEMPSENSORS_EXEC_STATE_START: - tempSensorsExecState = handleExecStart(); - break; - - case TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES: - tempSensorsExecState = handleExecGetADCValues(); - break; - - default: -// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_SOFTWARE_FAULT, SW_FAULT_ID_TEMPERATURE_SENSORS_EXEC_INVALID_STATE, tempSensorsExecState ); -// tempSensorsExecState = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; - break; - } - - // Monitor the temperature values - monitorTemperatureSenors(); - - // Publish the data publishTemperatureSensorsData(); } /*********************************************************************//** * @brief - * The handleExecStart function waits for a period of time and switches to - * the state that reads the ADC values from FPGA. - * @details \b Inputs: startTime - * @details \b Outputs: startTime, baroCoeffsWaitToRcvStartTime - * @return the next state of the state machine - *************************************************************************/ -static TEMPSENSORS_EXEC_STATES_T handleExecStart( void ) -{ - TEMPSENSORS_EXEC_STATES_T state = TEMPSENSORS_EXEC_STATE_START; - - if ( 0 == startTime ) - { - startTime = getMSTimerCount(); - } - // A delay to let FPGA to boot up - else if ( TRUE == didTimeout( startTime, ADC_FPGA_READ_DELAY ) ) - { - startTime = 0; - state = TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; - } - - return state; -} - -/*********************************************************************//** - * @brief - * The handleExecGetADCValues function reads the ADC values from FPGA and - * at the specified time intervals and calls required functions to calculate - * the actual tempetature from the raw ADC values. - * @details \b Inputs: FPGA - * @details \b Outputs: temperature value. - * @return the next state of the state machine - *************************************************************************/ -static TEMPSENSORS_EXEC_STATES_T handleExecGetADCValues( void ) -{ - // Read temperature sensors - readTemperatureSensors(); - - return TEMPSENSORS_EXEC_STATE_GET_ADC_VALUES; -} - -/*********************************************************************//** - * @brief * The publishTemperatureSensorsData function broadcasts the temperature * sensors data at the publication interval. - * @details \b Inputs: dataPublicationTimerCounter and publish interval time. + * @details \b Inputs: dataPublicationTimerCounter, tempSensorsPublishInterval * @details \b Outputs: dataPublicationTimerCounter - * @details \b Message \b Sent: MSG_ID_DD_TEMPERATURE_DATA publishes the temperature + * @details \b Message \b Sent: MSG_ID_FP_TEMPERATURE_DATA publishes the temperature * data in a periodic interval. * @return none *************************************************************************/ @@ -209,13 +87,21 @@ { TEMPERATURE_SENSORS_DATA_T data; - data.p23Temp = getTemperatureValue( P23_TEMP ); - data.p23Temp = getTemperatureValue( P22_TEMP ); - data.p10Temp = getTemperatureValue( P10_TEMP ); - data.p19Temp = getTemperatureValue( P19_TEMP ); - data.boardTemp = 0.0F; // TODO + data.p10Temp = getFilteredConductivitySensorTemperature( P9_COND ); + data.p19Temp = getFilteredConductivitySensorTemperature( P18_COND ); + data.m1Temp = getFilteredPressureSensorTemperature( M1_PRES ); + data.m3Temp = getFilteredPressureSensorTemperature( M3_PRES ); + data.p8Temp = getFilteredPressureSensorTemperature( P8_PRES ); + data.p13Temp = getFilteredPressureSensorTemperature( P13_PRES ); + data.p17Temp = getFilteredPressureSensorTemperature( P17_PRES ); + data.x1Temp = getFilteredPressureSensorTemperature( X1_PRES ); + data.x2Temp = getFilteredPressureSensorTemperature( X2_PRES ); + data.x3Temp = getFilteredPressureSensorTemperature( X3_PRES ); + data.x4Temp = getFilteredPressureSensorTemperature( X4_PRES ); + data.p7Temp = getFilteredFlowSensorTemperature( P7_FLOW ); + data.p16Temp = getFilteredFlowSensorTemperature( P16_FLOW ); - broadcastData( MSG_ID_FP_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + broadcastData( MSG_ID_FP_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); dataPublicationTimerCounter = 0; } }