/**********************************************************************//** * * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file TemperatureSensors.c * * @date 7-Apr-2020 * @author Dara Navaei * * @brief DG temperature sensors controller * **************************************************************************/ #include "TemperatureSensors.h" #include "FPGA.h" // Private variables //TODO sensor ADC ranges as #define //TODO sensor ADC to conversion as #define typedef enum tempSensors_Self_Test_States { TEMPSENSORS_SELF_TEST_START = 0, TEMPSENSORS_SELF_TEST_ADC_CHECK, TEMPSENSORS_SELF_TEST_CONSISTENCY_CHECK, TEMPSENSORS_SELF_TEST_COMPLETE, NUM_OF_TEMPSENSORS_SELF_TEST_STATES } TEMPSENSORS_SELF_TEST_STATES_T; typedef enum tempSensors_Exec_States { TEMPSENSORS_EXEC_STATE_WAIT_FOR_POST = 0, TEMPSENSROS_EXEC_STATE_READ_SENSORS, NUM_OF_TEMPSENSORS_EXEC_STATES, } TEMPSENSORS_EXEC_STATES_T; static SELF_TEST_STATUS_T tempSensorsSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; ///< Self test result of the TemperatureSensors module static TEMPSENSORS_SELF_TEST_STATES_T tempSensorsSelfTestState = TEMPSENSORS_SELF_TEST_START; ///< TemperatureSensor self test state static TEMPSENSORS_EXEC_STATES_T tempSensorsExecState = TEMPSENSORS_EXEC_STATE_WAIT_FOR_POST; ///< TemperatureSensor exec state // Private functions prototypes static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestStart ( void ); static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestADCCheck ( void ); static TEMPSENSORS_SELF_TEST_STATES_T handleSelfTestConsistencyCheck ( void ); static TEMPSENSORS_EXEC_STATES_T handleExecWaitForPost ( void ); static TEMPSENSORS_EXEC_STATES_T handleExecReadSensors ( void ); // Public functions /************************************************************************* * @brief initTemperatureSensors * The initTemperatureSensors initializes the module * @details * Inputs : none * Outputs : none * @param none * @return none *************************************************************************/ void initTemperatureSensors ( void ) { tempSensorsSelfTestResult = SELF_TEST_STATUS_IN_PROGRESS; tempSensorsSelfTestState = TEMPSENSORS_SELF_TEST_START; tempSensorsExecState = TEMPSENSORS_EXEC_STATE_WAIT_FOR_POST; } /************************************************************************* * @brief execTemperatureSensorsSelfTest * The execTemperatureSensorsSelfTest runs the TemperatureSensors POST * during the self test * @details * Inputs : none * Outputs : SELF_TEST_STATUS_T * @param none * @return SELF_TEST_STATUS_T *************************************************************************/ SELF_TEST_STATUS_T execTemperatureSensorsSelfTest ( void ) { switch ( tempSensorsSelfTestState ) { case TEMPSENSORS_SELF_TEST_START: tempSensorsSelfTestState = handleSelfTestStart(); break; case TEMPSENSORS_SELF_TEST_ADC_CHECK: tempSensorsSelfTestState = handleSelfTestADCCheck(); break; case TEMPSENSORS_SELF_TEST_CONSISTENCY_CHECK: tempSensorsSelfTestState = handleSelfTestConsistencyCheck(); break; case TEMPSENSORS_SELF_TEST_COMPLETE: // Done with self test, do nothing break; default: //TODO add software fault tempSensorsSelfTestState = TEMPSENSORS_SELF_TEST_COMPLETE; } return tempSensorsSelfTestResult; } /************************************************************************* * @brief execTemperatureSensors * The execTemperatureSensors runs the TemperatureSensors main tasks * @details * Inputs : none * Outputs : none * @param none * @return none *************************************************************************/ void execTemperatureSensors ( void ) { switch ( tempSensorsExecState ) { case TEMPSENSORS_EXEC_STATE_WAIT_FOR_POST: break; case TEMPSENSROS_EXEC_STATE_READ_SENSORS: // task priority // overwrite structure for the sensors break; default: // TODO add software fault tempSensorsExecState = TEMPSENSROS_EXEC_STATE_READ_SENSORS; } }