Index: firmware/App/Controllers/Thermistors.c =================================================================== diff -u -rc8fa40dde08a25bf61fae9f4fe770606a234db57 -rc0160362dc799802ec589d5b6cf4c2bd1face77e --- firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision c8fa40dde08a25bf61fae9f4fe770606a234db57) +++ firmware/App/Controllers/Thermistors.c (.../Thermistors.c) (revision c0160362dc799802ec589d5b6cf4c2bd1face77e) @@ -15,19 +15,19 @@ // ********** private definitions ********** -#define THERMISTORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Thermistors publish data time interval. -#define THERMISTORS_ADC_READ_INTERVAL ( MS_PER_SECOND / ( 2 * TASK_GENERAL_INTERVAL ) ) ///< Thermistors ADC read time interval. -#define ADC_FPGA_READ_DELAY_COUNT 1.0 ///< FGPA read delay upon startup. -#define TWELVE_BIT_RESOLUTION 4096U ///< 12 bit resolution conversion. -#define THERMISTOR_REFERENCE_VOLTAGE 3.0 ///< Thermistors source voltage. -#define THERMISTOR_REFERENCE_RESISTOR_AT_25 10000.0 ///< Thermistors reference resistor in ohms. -#define THERMISTOR_REFERENCE_TEMPERATURE 298.0 ///< Thermistors reference temperature in kelvin. -#define ONBOARD_THERMISTOR_BETA_VALUE 3380.0 ///< Onboard thermistor beta value. -#define POWER_SUPPLY_THERMISTOR_BETA_VALUE 3345.0 ///< Power supply beta value. -#define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. -#define MIN_ALLOWED_TEMPERATURE 5.0 ///< Thermistors/sensors minimum allowed temperature reading. -#define MAX_ALLOWED_TEMPERATURE 70.0 ///< Thermistors/sensors maximum allowed temperature reading. -#define MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD ( 5 * MS_PER_SECOND ) ///< Thermistors/sensors maximum allowed temperature out of range period. +#define THERMISTORS_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Thermistors publish data time interval. +#define THERMISTORS_ADC_READ_INTERVAL ( MS_PER_SECOND / ( 2 * TASK_GENERAL_INTERVAL ) ) ///< Thermistors ADC read time interval. +#define ADC_FPGA_READ_DELAY_COUNT 1.0 ///< FGPA read delay upon startup. +#define TWELVE_BIT_RESOLUTION 4096U ///< 12 bit resolution conversion. +#define THERMISTOR_REFERENCE_VOLTAGE 3.0 ///< Thermistors source voltage. +#define THERMISTOR_REFERENCE_RESISTOR_AT_25 10000.0 ///< Thermistors reference resistor in ohms. +#define THERMISTOR_REFERENCE_TEMPERATURE 298.0 ///< Thermistors reference temperature in kelvin. +#define ONBOARD_THERMISTOR_BETA_VALUE 3380.0 ///< Onboard thermistor beta value. +#define POWER_SUPPLY_THERMISTOR_BETA_VALUE 3345.0 ///< Power supply beta value. +#define CELSIUS_TO_KELVIN_CONVERSION 273.15 ///< Celsius to Kelvin temperature conversion. +#define MIN_ALLOWED_TEMPERATURE 0.0 ///< Thermistors/sensors minimum allowed temperature reading. +#define MAX_ALLOWED_TEMPERATURE 80.0 ///< Thermistors/sensors maximum allowed temperature reading. +#define MAX_ALLOWED_TEMP_OUT_OF_RANGE_PERIOD ( 5 * MS_PER_SECOND ) ///< Thermistors/sensors maximum allowed temperature out of range period. /// Thermistors self test states typedef enum thermistors_Self_Test_States @@ -53,8 +53,6 @@ F32 betaValue; ///< Thermistor beta value used to calculate temperature } THERMISTOR_T; -static SELF_TEST_STATUS_T thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; ///< Thermistors self test result. -static THERMISTORS_SELF_TEST_STATES_T thermistorsSelfTestState = THERMISTROS_SELF_TEST_CHECK_RANGE_STATE; ///< Thermistors self test state. static THERMISTORS_EXEC_STATES_T thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; ///< Thermistors exec state. static THERMISTOR_T thermistorsStatus[ NUM_OF_THERMISTORS ]; ///< Thermistors array. static OVERRIDE_U32_T thermistorsPublishInterval = { THERMISTORS_DATA_PUBLISH_INTERVAL, @@ -68,8 +66,6 @@ // ********** private function prototypes ********** -static THERMISTORS_SELF_TEST_STATES_T handleSelfTestCheckRange( void ); - static THERMISTORS_EXEC_STATES_T handleExecStart( void ); static THERMISTORS_EXEC_STATES_T handleExecGetADCValues( void ); @@ -82,18 +78,14 @@ /*********************************************************************//** * @brief * The initThermistors function initializes the thermistors module. - * @details Inputs: thermistorsSelfTestReslt, thermistorsExecState, - * thermistorsExecState, dataPublishCounter - * @details Outputs: thermistorsSelfTestReslt, thermistorsExecState, - * thermistorsExecState, dataPublishCounter + * @details Inputs: none + * @details Outputs: thermistorsExecState, dataPublishCounter * @return none *************************************************************************/ void initThermistors( void ) { // Reset the thermistors values for a run - thermistorsSelfTestReslt = SELF_TEST_STATUS_IN_PROGRESS; thermistorsExecState = THERMISTORS_EXEC_STATE_START_STATE; - thermistorsSelfTestState = THERMISTROS_SELF_TEST_CHECK_RANGE_STATE; dataPublishCounter = 0; // Initialize the beta values of each thermistor @@ -108,30 +100,19 @@ /*********************************************************************//** * @brief * The execThermistorsSelfTest function executes the thermistors self test. - * @details Inputs: thermistorsSelfTestState - * @details Outputs: thermistorsSelfTestState + * @details Inputs: none + * @details Outputs: none * @return Status of self test *************************************************************************/ SELF_TEST_STATUS_T execThermistorsSelfTest( void ) { - switch ( thermistorsSelfTestState ) - { - case THERMISTROS_SELF_TEST_CHECK_RANGE_STATE: - thermistorsSelfTestState = handleSelfTestCheckRange(); - break; + SELF_TEST_STATUS_T status = SELF_TEST_STATUS_IN_PROGRESS; - case THERMISTORS_SELF_TEST_COMPLETE_STATE: - // Done with POST. Do nothing. - break; + // TODO implement the calibration processing function. + // It returns a pass for now + status = SELF_TEST_STATUS_PASSED; - default: - // Wrong state was called, raise an alarm - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DG_SOFTWARE_FAULT, SW_FAULT_ID_THERMISTORS_INVALID_SELF_TEST_STATE, thermistorsSelfTestState ); - thermistorsSelfTestState = THERMISTORS_SELF_TEST_COMPLETE_STATE; - break; - } - - return thermistorsSelfTestReslt; + return status; } /*********************************************************************//** @@ -199,55 +180,6 @@ /*********************************************************************//** * @brief - * The handleSelfTestRangeCheck function checks whether the thermistors - * are in range upon staring the device. - * @details Inputs: thermistorsStatus, adcReadCounter - * @details Outputs: thermistorsStatus, adcReadCounter - * @return next state of self test - *************************************************************************/ -static THERMISTORS_SELF_TEST_STATES_T handleSelfTestCheckRange( void ) -{ - THERMISTORS_SELF_TEST_STATES_T state = THERMISTROS_SELF_TEST_CHECK_RANGE_STATE; - - // Give a short time for FPGA to boot up and start sending the ADC reads - if ( ++adcReadCounter > ADC_FPGA_READ_DELAY_COUNT ) - { - THERMISTORS_TEMP_SENSORS_T thermistor; - F32 temperature; - - // Assuming self test passed - thermistorsSelfTestReslt = SELF_TEST_STATUS_PASSED; - - // Get all the raw readings in ADC - thermistorsStatus[ THERMISTOR_ONBOARD_NTC ].rawADCRead = getIntADCReading( INT_ADC_BOARD_THERMISTOR ); - thermistorsStatus[ THERMISTOR_POWER_SUPPLY_1 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_1_THERMISTOR ); - thermistorsStatus[ THERMISTOR_POWER_SUPPLY_2 ].rawADCRead = getIntADCReading( INT_ADC_POWER_SUPPLY_2_THERMISTOR ); - - // Convert the ADC values to temperature - convertADC2Temperature(); - - for ( thermistor = THERMISTOR_ONBOARD_NTC; thermistor < NUM_OF_THERMISTORS; thermistor++ ) - { - // Get the actual temperature value and not the override value - temperature = thermistorsStatus[ thermistor ].temperatureValue.data; - // If the values are out of range, raise an alarm - if ( temperature < MIN_ALLOWED_TEMPERATURE || temperature >= MAX_ALLOWED_TEMPERATURE ) - { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_DG_THERMISTORS_TEMPERATURE_OUT_OF_RANGE, thermistor, temperature ); - // If any thermistor/sensor is not in range, POST has failed - thermistorsSelfTestReslt = SELF_TEST_STATUS_FAILED; - } - } - // Done with POST - state = THERMISTORS_SELF_TEST_COMPLETE_STATE; - adcReadCounter = 0; - } - - return state; -} - -/*********************************************************************//** - * @brief * The handleExecStart function handles the start state of the exec state * machine. * @details Inputs: adcReadCounter