Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r2205857f59dd884c4af450239381387cfb560c2e -r0d2351b8e47e40fdcd706ed7b7ac1379b69a20ef --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 2205857f59dd884c4af450239381387cfb560c2e) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 0d2351b8e47e40fdcd706ed7b7ac1379b69a20ef) @@ -40,13 +40,18 @@ #define VALVES_STATE_PUB_INTERVAL ( MS_PER_SECOND / TASK_PRIORITY_INTERVAL ) ///< Interval ( ms / task time ) at which valves states are published on CAN bus. #define DATA_PUBLISH_COUNTER_START_COUNT 50 ///< Data publish counter start count. -/// Payload record structure for valve open/close request -typedef struct -{ - U32 valveID; ///< ValveID ( valid range 0 to 28 ) - U32 valveState; ///< Valve state ( Open : 0, closed :1) -} VALVE_CMD_PAYLOAD_T; - +/// Bits associated with RO valves when interfacing with FPGA to command a valve position. 1=energized, 0=de-energized. +static const U08 ValveBits[ NUM_OF_VALVES ] = { + 0x01, + 0x02, + 0x04, + 0x08, + 0x10, + 0x20, + 0x40, + 0x80 +}; + // ********** private data ********** static U32 valvesStatesPublicationTimerCounter; ///< Timer counter used to schedule valve state publication to CAN bus. @@ -161,7 +166,7 @@ * @brief * The readCommandedValveStates function gets the hydraulics, Balancing chamber * and Ultrafiltration valvesStates that can be passed to FPGA for setting valves. - * @details \b Inputs: valveStates[] + * @details \b Inputs: valveStates[], ValveBits[] * @details \b Outputs: commandedValvesStates * @return none *************************************************************************/ @@ -170,12 +175,12 @@ U32 valve; // Initiliaze before updating commanded states - commandedValvesStates = ALL_VALVES_DEENERGIZED; + commandedValvesStates = ALL_VALVES_DEENERGIZED; - // flag hydraulics valves that are currently commanded to be energized + // flag RO valves that are currently commanded to be energized for ( valve = FIRST_VALVE; valve < NUM_OF_VALVES; valve++ ) { - commandedValvesStates |= ( getValveState( valve ) == ENERGIZED ? 0x0001 << valve : 0 ); + commandedValvesStates |= ( getValveState( valve ) == ENERGIZED ? ValveBits[ valve ] : 0 ); } }