Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rc8c60f543b53cd96008914a01145f5b08426903e -r986147effa2865d32f37c8c4c2b8b396eda847e0 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision c8c60f543b53cd96008914a01145f5b08426903e) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 986147effa2865d32f37c8c4c2b8b396eda847e0) @@ -29,25 +29,38 @@ // ********** private definitions ********** -//#define DEENERGIZED 0 -//#define ENERGIZED 1 -//#define INIT_VALVE_STATE 0b0000000000000000 +#define DEENERGIZED 0 +#define ENERGIZED 1 +#define INIT_VALVES_STATES 0b0000000000000000 /// Default publication interval for valve states #define VALVES_STATE_PUB_INTERVAL ( 500 / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the valves state is published on the CAN bus +/// Defined states for the valves self test state machine +typedef enum Valves_Self_Test_States +{ + VALVE_SELF_TEST_STATE_START = 0, ///< Self test start state + VALVE_TEST_STATE_IN_PROGRESS, ///< Self test in progress state + VALVE_TEST_STATE_COMPLETE, ///< Self test completed state + NUM_OF_VALVE_SELF_TEST_STATES ///< Number of valve self test states +} VALVE_SELF_TEST_STATE_T; + // ********** private data ********** -static U32 valveStatePublicationTimerCounter = 0; ///< used to schedule valve state publication to CAN bus +static VALVE_STATES_T valvesStates = INIT_VALVES_STATES; ///< current state of valve driver state machine +static U32 valvesStatesPublicationTimerCounter = 0; ///< used to schedule valve state publication to CAN bus -static OVERRIDE_U32_T valveStatePublishInterval = { VALVES_STATE_PUB_INTERVAL, VALVES_STATE_PUB_INTERVAL, 0, 0 }; ///< interval (in ms/task interval) at which to publish valves state to CAN bus -static OVERRIDE_F32_T valves[ NUM_OF_VALVE_IDS ]; ///< Obtained state from valves +static OVERRIDE_U32_T valvesStatesPublishInterval = { VALVES_STATE_PUB_INTERVAL, VALVES_STATE_PUB_INTERVAL, 0, 0 }; ///< interval (in ms/task interval) at which to publish valves state to CAN bus +static OVERRIDE_F32_T valves[ NUM_OF_VALVES ]; ///< Obtained state from valves +static VALVE_SELF_TEST_STATE_T valvesSelfTestState = VALVE_SELF_TEST_STATE_START; ///< current valve self test state +static U32 valvesSelfTestTimerCount = 0; ///< timer counter for valve self test + // ********** private function prototypes ********** static void checkValves( void ); -static void publishValvesState( void ); -static DATA_GET_PROTOTYPE( U32, getPublishValvesStateInterval ); +static void publishValvesStates( void ); +static DATA_GET_PROTOTYPE( U32, getPublishValvesStatesInterval ); /**@}*/ @@ -61,17 +74,17 @@ *************************************************************************/ void initValves( void ) { - setFPGAValveStates( INIT_VALVES_STATES ) - valvesStatePublicationTimerCounter = 0; + setFPGAValveStates( INIT_VALVES_STATES ); + valvesStatesPublicationTimerCounter = 0; valvesSelfTestTimerCount = 0; } /*********************************************************************//** * @brief * The execValves function executes the valve driver. * @details - * Inputs : valvesState - * Outputs : valvesState + * Inputs : valvesStates + * Outputs : valvesStates * @return none *************************************************************************/ void execValves( void ) @@ -90,21 +103,23 @@ * Outputs : none * @return none *************************************************************************/ -static void checkValveState( void ) +static void checkValves( void ) { /* TODO: compare the requested valve state to the allowable valves \n * states for a given valve; * - if checks, return True * - if not, return false */ + + return; } /*********************************************************************//** * @brief * The getPublishValveStateInterval function gets the valves states \n * publication interval. * @details - * Inputs : valvesStatePublishInterval + * Inputs : valvesStatesPublishInterval * Outputs : none * @return the current valves states publication interval (in task intervals). *************************************************************************/ @@ -122,25 +137,25 @@ /*********************************************************************//** * @brief - * The getValveState function gets the current valve state for given valve ID. + * The getValveState function gets the current valve state for given valve. * @details * Inputs : valveState * Outputs : none - * @return the current valve state for given valve ID. + * @return the current valve state for given valve. *************************************************************************/ -F32 getValveState( U32 valveID ) +F32 getValveState( U32 valve ) { BOOL valveState = DEENERGIZED; - if ( valveID < NUM_OF_VALVE_IDS ) + if ( valve < NUM_OF_VALVES ) { - if ( OVERRIDE_KEY == valves[ valveID ].override ) + if ( OVERRIDE_KEY == valves[ valve ].override ) { - valveState = valves[ valveID ].ovData; + valveState = valves[ valve ].ovData; } else { - valveState = valves[ valveID ].data; + valveState = valves[ valve ].data; } } else @@ -154,10 +169,10 @@ /*********************************************************************//** * * @brief - * The publishValvesState function publishes DG valves state at the \n + * The publishValvesStates function publishes DG valves states at the \n * set interval. * @details - * Inputs : valvesStatePublicationTimerCounter + * Inputs : valvesStatesPublicationTimerCounter * Outputs : DG valves states are published to CAN bus * @return none *************************************************************************/ @@ -166,21 +181,21 @@ // publish valve state on interval if ( ++valvesStatesPublicationTimerCounter >= getPublishValvesStatesInterval() ) { - broadcastValvesState( getFPGAValveStates() ); + broadcastValvesStates( getFPGAValveStates() ); valvesStatesPublicationTimerCounter = 0; } } /*********************************************************************//** * @brief - * The execPressuresTest function executes the state machine for the \n - * Pressures self test. + * The execValvesTest function executes the state machine for the \n + * valves self test. * @details * Inputs : none * Outputs : none - * @return the current state of the Pressures self test. + * @return the current state of the valves self test. *************************************************************************/ -SELF_TEST_STATUS_T execPressuresTest( void ) +SELF_TEST_STATUS_T execValvesTest( void ) { SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED; @@ -191,23 +206,22 @@ /**@}*/ - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ /*********************************************************************//** * @brief - * The testSetPressuresDataPublishIntervalOverride function overrides the \n - * pressure and occlusion data publish interval. + * The testSetValvesStatesPublishIntervalOverride function overrides the \n + * valves states publish interval. * @details * Inputs : none - * Outputs : pressuresDataPublishInterval - * @param value : override pressure and occlusion data publish interval with (in ms) + * Outputs : valvesStatesPublishInterval + * @param value : override valves states publish interval with (in ms) * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetPressuresDataPublishIntervalOverride( U32 value ) +BOOL testSetValvesStatesPublishIntervalOverride( U32 value ) { BOOL result = FALSE; @@ -216,57 +230,57 @@ U32 intvl = value / TASK_PRIORITY_INTERVAL; result = TRUE; - pressuresDataPublishInterval.ovData = intvl; - pressuresDataPublishInterval.override = OVERRIDE_KEY; + valvesStatesPublishInterval.ovData = intvl; + valvesStatesPublishInterval.override = OVERRIDE_KEY; } return result; } /*********************************************************************//** * @brief - * The testResetPressuresDataPublishIntervalOverride function resets the override \n - * of the pressure and occlusion data publish interval. + * The testResetValvesStatesPublishIntervalOverride function resets the override \n + * of the valves states publish interval. * @details * Inputs : none - * Outputs : pressuresDataPublishInterval + * Outputs : valvesStatesPublishInterval * @return TRUE if override reset successful, FALSE if not *************************************************************************/ -BOOL testResetPressuresDataPublishIntervalOverride( void ) +BOOL testResetValvesStatesPublishIntervalOverride( void ) { BOOL result = FALSE; if ( TRUE == isTestingActivated() ) { result = TRUE; - pressuresDataPublishInterval.override = OVERRIDE_RESET; - pressuresDataPublishInterval.ovData = pressuresDataPublishInterval.ovInitData; + valvesStatesPublishInterval.override = OVERRIDE_RESET; + valvesStatesPublishInterval.ovData = valvesStatesPublishInterval.ovInitData; } return result; } /*********************************************************************//** * @brief - * The testSetDGPressureSensorOverride function overrides the value of the \n - * specified pressure sensor with a given value. + * The testSetValveStateOverride function overrides the value of the \n + * specified valve with a given value. * Inputs : none - * Outputs : pressures[] - * @param sensor : ID of pressure sensor to override for - * @param value : override value for the given pressure sensor ID + * Outputs : valves[] + * @param valve : ID of valve to override for + * @param value : override value for the given valve ID * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testSetDGPressureSensorOverride( U32 sensor, F32 value ) +BOOL testSetValveStateOverride( U32 valve, F32 value ) { BOOL result = FALSE; - if ( sensor < NUM_OF_PRESSURE_SENSORS ) + if ( valve < NUM_OF_VALVES ) { if ( TRUE == isTestingActivated() ) { result = TRUE; - pressures[ sensor ].ovData = value; - pressures[ sensor ].override = OVERRIDE_KEY; + valves[ valve ].ovData = value; + valves[ valve ].override = OVERRIDE_KEY; } } @@ -275,25 +289,25 @@ /*********************************************************************//** * @brief - * The testResetDGPressureSensorOverride function resets the override of the \n - * specified DG pressure sensor. + * The testResetValveStateOverride function resets the override of the \n + * specified valve. * @details * Inputs : none - * Outputs : pressures[] - * @param value : ID of sensor to reset override pressure for + * Outputs : valves[] + * @param value : ID of valve to reset override state for * @return TRUE if override successful, FALSE if not *************************************************************************/ -BOOL testResetDGPressureSensorOverride( U32 sensor ) +BOOL testResetValveStateOverride( U32 valve ) { BOOL result = FALSE; - if ( sensor < NUM_OF_PRESSURE_SENSORS ) + if ( valve < NUM_OF_VALVES ) { if ( TRUE == isTestingActivated() ) { result = TRUE; - pressures[ sensor ].override = OVERRIDE_RESET; - pressures[ sensor ].ovData = pressures[ sensor ].ovInitData; + valves[ valve ].override = OVERRIDE_RESET; + valves[ valve ].ovData = valves[ valve ].ovInitData; } }