Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -rdc0d9b087c609e71cacdb7f0395cccf29d749c00 -r44c977966ab7cfecbfbf5110e6abe4ec45ebab62 --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision dc0d9b087c609e71cacdb7f0395cccf29d749c00) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 44c977966ab7cfecbfbf5110e6abe4ec45ebab62) @@ -27,31 +27,30 @@ // ********** private definitions ********** -#define DEENERGIZED 0 ///< 0 for de-energized valve -#define ENERGIZED 1 ///< 1 for energized valve -#define ALL_VALVES_DEENERGIZED 0x0000 ///< 0 in U16 bit field for all valves +#define DEENERGIZED 0 ///< 0 for de-energized valve. +#define ENERGIZED 1 ///< 1 for energized valve. +#define ALL_VALVES_DEENERGIZED 0x0000 ///< 0 in U16 bit field for all valves. -#define MAX_VALVE_STATE_MISMATCH_COUNT 3 ///< maximum number of times commanded valves state can fail to match read back valve states in a row. +#define MAX_VALVE_STATE_MISMATCH_COUNT 3 ///< Maximum number of times commanded valves state can fail to match read back valve states in a row. -/// Default publication interval for valves states -#define VALVES_STATE_PUB_INTERVAL ( 500 / TASK_PRIORITY_INTERVAL ) ///< interval ( ms / task time) at which valves states are published on CAN bus +#define VALVES_STATE_PUB_INTERVAL ( 500 / TASK_PRIORITY_INTERVAL ) ///< Interval ( ms / task time) at which valves states are published on CAN bus. // ********** private data ********** -static U32 valvesStatesPublicationTimerCounter = 0; ///< used to schedule valve state publication to CAN bus -static U16 commandedValvesStates = ALL_VALVES_DEENERGIZED; ///< initialize commanded valves states bit field. -static U32 valveStateMismatchCounter = 0; ///< initialize valve state mismatch counter +static U32 valvesStatesPublicationTimerCounter = 0; ///< Timer counter used to schedule valve state publication to CAN bus. +static U16 commandedValvesStates = ALL_VALVES_DEENERGIZED; ///< Initialize commanded valves states bit field. +static U32 valveStateMismatchCounter = 0; ///< Initialize valve state mismatch counter. -static OVERRIDE_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states -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_U32_T valveStates[ NUM_OF_VALVES ]; ///< Currently commanded valves states. +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. // ********** private function prototypes ********** -static BOOL checkValveStateName( VALVES_T valve, VALVE_STATE_NAMES_T valveStateName ); ///< check validity of requested valve state name for given valve -static U32 convertValveStateNameToValveState(VALVE_STATE_NAMES_T valveStateName); ///< Convert valve state name to de-/energized valve state -static U16 fromU32ArrayToU16( void ); ///< convert array of U32 to U16 for statesValves preparation +static BOOL checkValveStateName( VALVES_T valve, VALVE_STATE_NAMES_T valveStateName ); +static U32 convertValveStateNameToValveState(VALVE_STATE_NAMES_T valveStateName); +static U16 fromU32ArrayToU16( void ); static void publishValvesStates( void ); -static DATA_GET_PROTOTYPE( U32, getPublishValvesStatesInterval ); +static U32 getPublishValvesStatesInterval( void ); /*********************************************************************//** * @brief @@ -66,7 +65,7 @@ U32 i; // initialize commanded valve states - for (i = 0; i < NUM_OF_VALVES; i++) + for ( i = 0; i < NUM_OF_VALVES; i++ ) { valveStates[ i ].data = DEENERGIZED; valveStates[ i ].ovInitData = DEENERGIZED; @@ -115,7 +114,7 @@ /*********************************************************************//** * @brief - * The checkValveStateName function checks the validity of requested valve \n + * The checkValveStateName function checks the validity of requested valve * state name for given valve. * @details * Inputs : none @@ -224,14 +223,13 @@ /*********************************************************************//** * @brief - * The getPublishValveStateInterval function gets the valves states \n - * publication interval. + * The getPublishValveStateInterval function gets the valves states publication interval. * @details * Inputs : valvesStatesPublishInterval * Outputs : none * @return the current valves states publication interval (in task intervals) *************************************************************************/ -U32 getPublishValvesStatesInterval( void ) +static U32 getPublishValvesStatesInterval( void ) { U32 result = valvesStatesPublishInterval.data; @@ -245,14 +243,14 @@ /*********************************************************************//** * @brief - * The fromU32ArrayToU16 function converts an array of U32 valve states \n + * The fromU32ArrayToU16 function converts an array of U32 valve states * to U16 valvesStates that can be passed to FPGA for setting valves. * @details * Inputs : valveStates[] * Outputs : none * @return converted U16 bit field for currently commanded valve states *************************************************************************/ -U16 fromU32ArrayToU16( void ) +static U16 fromU32ArrayToU16( void ) { U16 result = ALL_VALVES_DEENERGIZED; // start result flag as all valves de-energized U32 i; @@ -276,7 +274,7 @@ * @param valveStateName valve state name enumeration to convert to energized/de-energized * @return converted valve state for given valve state name *************************************************************************/ -U32 convertValveStateNameToValveState( VALVE_STATE_NAMES_T valveStateName ) +static U32 convertValveStateNameToValveState( VALVE_STATE_NAMES_T valveStateName ) { U32 vState = DEENERGIZED; // initialize valve state to de-energized @@ -345,7 +343,7 @@ * Inputs : none * Outputs : none * @param valveID ID of valve to set state for - * @param valveStateName Name of valve state to set given valve to + * @param valveStateName name of valve state to set given valve to * @return TRUE if new valve state is set for given valve ID, FALSE if not. *************************************************************************/ BOOL setValveState( VALVES_T valveID, VALVE_STATE_NAMES_T valveStateName ) @@ -354,7 +352,7 @@ if ( valveID < NUM_OF_VALVES ) { - if ( checkValveStateName ( valveID, valveStateName ) ) + if ( checkValveStateName( valveID, valveStateName ) ) { valveStates[ valveID ].data = convertValveStateNameToValveState( valveStateName ); result = TRUE; @@ -402,8 +400,7 @@ /*********************************************************************//** * @brief - * The publishValvesStates function publishes DG valves states at the \n - * set interval. + * The publishValvesStates function publishes DG valves states at the set interval. * @details * Inputs : valvesStatesPublicationTimerCounter * Outputs : DG valves states are published to CAN bus on interval. @@ -418,15 +415,16 @@ valvesStatesPublicationTimerCounter = 0; } } + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ + - /*********************************************************************//** * @brief - * The testSetValvesStatesPublishIntervalOverride function overrides the \n + * The testSetValvesStatesPublishIntervalOverride function overrides the * valves states publish interval. * @details * Inputs : none @@ -452,7 +450,7 @@ /*********************************************************************//** * @brief - * The testResetValvesStatesPublishIntervalOverride function resets the override \n + * The testResetValvesStatesPublishIntervalOverride function resets the override * of the valves states publish interval. * @details * Inputs : none @@ -475,7 +473,7 @@ /*********************************************************************//** * @brief - * The testSetValveStateOverride function overrides the value of the \n + * The testSetValveStateOverride function overrides the value of the * specified valve with a given value. * Inputs : none * Outputs : valves[] @@ -502,8 +500,7 @@ /*********************************************************************//** * @brief - * The testResetValveStateOverride function resets the override of the \n - * specified valve. + * The testResetValveStateOverride function resets the override of the specified valve. * @details * Inputs : none * Outputs : valves[]