Index: firmware/App/Controllers/BoostPump.c =================================================================== diff -u -r051cd0430ef8342bd606115c98871e26dc24acf1 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 051cd0430ef8342bd606115c98871e26dc24acf1) +++ firmware/App/Controllers/BoostPump.c (.../BoostPump.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -171,7 +171,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_INVALID_PUMP_DUTY_CYCLE_SELECTED, boostPumpState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED, boostPumpState ) boostPumpState = BOOST_PUMP_OFF_STATE; break; } @@ -193,34 +193,38 @@ BOOST_PUMP_STATE_T state = BOOST_PUMP_OFF_STATE; isBoostPumpOn = FALSE; - // If there is a target pressure set, transition to the PI controller and control to pressure. - if ( ( getTargetBoostPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + // Do not control unless boost is installed + if ( TRUE == isBoostPumpInstalled ) { - // Set pump to on - isBoostPumpOn = TRUE; - boostPumpDutyCyclePctSet = boostPumpPresToPWM( getTargetBoostPumpPressure() ); - setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); - state = BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; - } + // If there is a target pressure set, transition to the PI controller and control to pressure. + if ( ( getTargetBoostPumpPressure() > 0.0F ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + { + // Set pump to on + isBoostPumpOn = TRUE; + boostPumpDutyCyclePctSet = boostPumpPresToPWM( getTargetBoostPumpPressure() ); + setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); + state = BOOST_PUMP_CONTROL_TO_TARGET_PRESSURE_STATE; + } - // If there is a target flow set, transition to the PI controller and control to flow - else if ( ( getTargetBoostPumpFlowRateMLPM() > 0 ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) - { - // Set pump to on - isBoostPumpOn = TRUE; - boostPumpDutyCyclePctSet = boostPumpFlowToPWM( getTargetBoostPumpFlowRateMLPM() ); - setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); - state = BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE; + // If there is a target flow set, transition to the PI controller and control to flow + else if ( ( getTargetBoostPumpFlowRateMLPM() > 0 ) && ( PUMP_CONTROL_MODE_CLOSED_LOOP == boostPumpControlMode ) ) + { + // Set pump to on + isBoostPumpOn = TRUE; + boostPumpDutyCyclePctSet = boostPumpFlowToPWM( getTargetBoostPumpFlowRateMLPM() ); + setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpDutyCyclePctSet ); + state = BOOST_PUMP_CONTROL_TO_TARGET_FLOW_STATE; + } + // If the target duty cycle is greater than zero (minimum is 10%) and the mode has been set to open + // loop, set the duty cycle + else if ( ( boostPumpOpenLoopTargetDutyCycle > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == boostPumpControlMode ) ) + { + setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpOpenLoopTargetDutyCycle ); + boostPumpDutyCyclePctSet = boostPumpOpenLoopTargetDutyCycle; + isBoostPumpOn = TRUE; + state = BOOST_PUMP_OPEN_LOOP_STATE; + } } - // If the target duty cycle is greater than zero (minimum is 10%) and the mode has been set to open - // loop, set the duty cycle - else if ( ( boostPumpOpenLoopTargetDutyCycle > 0.0F ) && ( PUMP_CONTROL_MODE_OPEN_LOOP == boostPumpControlMode ) ) - { - setFluidPumpPctToPWMDutyCycle( P40_PUMP, boostPumpOpenLoopTargetDutyCycle ); - boostPumpDutyCyclePctSet = boostPumpOpenLoopTargetDutyCycle; - isBoostPumpOn = TRUE; - state = BOOST_PUMP_OPEN_LOOP_STATE; - } return state; } @@ -370,7 +374,7 @@ // Requested flow rate is out of range else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_FLOW_RATE_SET, boostFlowRate ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_PUMP_INVALID_FLOW_RATE_SET, boostFlowRate ) } return result; @@ -413,7 +417,7 @@ // Requested flow rate is out of range else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_PRESSURE_SELECTED, boostPressure ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_PUMP_INVALID_PRESSURE_SELECTED, boostPressure ) } return result; @@ -454,7 +458,7 @@ } else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_INVALID_PUMP_DUTY_CYCLE_SELECTED, dutyCycle ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED, dutyCycle ) } return status; @@ -603,7 +607,7 @@ pumpData.p40TargetFlow = getTargetBoostPumpFlowRateMLPM(); pumpData.p40TargetDutyCycle = boostPumpOpenLoopTargetDutyCycle; - broadcastData( MSG_ID_FP_BOOST_PUMP_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&pumpData, sizeof( BOOST_PUMP_DATA_T ) ); + broadcastData( MSG_ID_FP_BOOST_PUMP_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&pumpData, sizeof( BOOST_PUMP_DATA_T ) ); boostPumpDataPublicationTimerCounter = 0; } } Index: firmware/App/Controllers/BoostPump.h =================================================================== diff -u -r863f8f88c73ee5dd285242f6e131a14862b4f5c4 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Controllers/BoostPump.h (.../BoostPump.h) (revision 863f8f88c73ee5dd285242f6e131a14862b4f5c4) +++ firmware/App/Controllers/BoostPump.h (.../BoostPump.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -55,7 +55,7 @@ void execBoostPumpController( void ); void execBoostPumpMonitor( void ); -void signalBoostPumpStop( void ); +void signalBoostPumpHardStop( void ); BOOL isBoostPumpRunning( void ); BOOL setBoostPumpTargetFlowRateLPM( U32 roFlowRate ); Index: firmware/App/Controllers/Heaters.c =================================================================== diff -u -r94695022c89578c365bbe6e8b247b2ecdbd2b33e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 94695022c89578c365bbe6e8b247b2ecdbd2b33e) +++ firmware/App/Controllers/Heaters.c (.../Heaters.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -17,7 +17,7 @@ #include // Used for mathematical operations -#include "FpgaRO.h" +#include "FpgaFP.h" #include "Heaters.h" #include "Level.h" #include "MessageSupport.h" @@ -369,7 +369,7 @@ static HEATER_STATE_T handleHeaterStateRampToTarget( void ) { HEATER_STATE_T state = HEATER_EXEC_STATE_RAMP_TO_TARGET; - RO_OP_MODE_T opMode = getCurrentOperationMode(); + FP_OP_MODE_T opMode = getCurrentOperationMode(); F32 targetTemperature = getHeaterTargetTemperature(); // if ( RO_MODE_HEAT != opMode ) @@ -538,7 +538,7 @@ dataPublicationTimerCounter = 0; - broadcastData( MSG_ID_FP_HEATER_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( HEATERS_DATA_T ) ); + broadcastData( MSG_ID_FP_HEATER_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( HEATERS_DATA_T ) ); } } Index: firmware/App/Controllers/ROPump.c =================================================================== diff -u -r863f8f88c73ee5dd285242f6e131a14862b4f5c4 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 863f8f88c73ee5dd285242f6e131a14862b4f5c4) +++ firmware/App/Controllers/ROPump.c (.../ROPump.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -17,7 +17,7 @@ //#include -#include "FlowSensor.h" +#include "Flow.h" //#include "NVDataMgmt.h" #include "Messaging.h" #include "MessageSupport.h" @@ -171,7 +171,7 @@ break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_INVALID_PUMP_DUTY_CYCLE_SELECTED, roPumpState ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED, roPumpState ) roPumpState = RO_PUMP_OFF_STATE; break; } @@ -371,7 +371,7 @@ // Requested flow rate is out of range else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_FLOW_RATE_SET, roFlowRate ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_PUMP_INVALID_FLOW_RATE_SET, roFlowRate ) } return result; @@ -414,7 +414,7 @@ // Requested flow rate is out of range else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_PUMP_INVALID_PRESSURE_SELECTED, roPressure ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_PUMP_INVALID_PRESSURE_SELECTED, roPressure ) } return result; @@ -455,7 +455,7 @@ } else { - SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_INVALID_PUMP_DUTY_CYCLE_SELECTED, dutyCycle ) + SET_ALARM_WITH_2_F32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED, dutyCycle ) } return status; @@ -602,7 +602,7 @@ pumpData.p12TargetFlow = getTargetROPumpFlowRateMLPM(); pumpData.p12TargetDutyCycle = roPumpOpenLoopTargetDutyCycle; - broadcastData( MSG_ID_FP_RO_PUMP_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&pumpData, sizeof( RO_PUMP_DATA_T ) ); + broadcastData( MSG_ID_FP_RO_PUMP_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&pumpData, sizeof( RO_PUMP_DATA_T ) ); roPumpDataPublicationTimerCounter = 0; } } Index: firmware/App/Controllers/Valves.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Controllers/Valves.c (.../Valves.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Controllers/Valves.c (.../Valves.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -17,7 +17,7 @@ #include // For memcpy -#include "FpgaRO.h" +#include "FpgaFP.h" #include "MessageSupport.h" #include "Messaging.h" #include "TaskPriority.h" @@ -375,7 +375,7 @@ data.valvesSensedState[ valve ] = (U08)getValveStateName( (VALVES_T)valve ); } - broadcastData( MSG_ID_FP_VALVES_STATES_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( RO_VALVES_DATA_T ) ); + broadcastData( MSG_ID_FP_VALVES_STATES_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( RO_VALVES_DATA_T ) ); valvesStatesPublicationTimerCounter = 0; } Index: firmware/App/Drivers/ConductivitySensor.c =================================================================== diff -u -r863f8f88c73ee5dd285242f6e131a14862b4f5c4 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Drivers/ConductivitySensor.c (.../ConductivitySensor.c) (revision 863f8f88c73ee5dd285242f6e131a14862b4f5c4) +++ firmware/App/Drivers/ConductivitySensor.c (.../ConductivitySensor.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -19,7 +19,7 @@ #include // For memcpy #include "ConductivitySensor.h" -#include "FpgaRO.h" +#include "FpgaFP.h" #include "MessageSupport.h" #include "Messaging.h" #include "OperationModes.h" Index: firmware/App/Drivers/FlowSensor.c =================================================================== diff -u -r863f8f88c73ee5dd285242f6e131a14862b4f5c4 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Drivers/FlowSensor.c (.../FlowSensor.c) (revision 863f8f88c73ee5dd285242f6e131a14862b4f5c4) +++ firmware/App/Drivers/FlowSensor.c (.../FlowSensor.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,9 +15,9 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" +#include "FpgaFP.h" #include "FlowSensor.h" -#include "FpgaRO.h" #include "Messaging.h" #include "PersistentAlarm.h" Index: firmware/App/Drivers/FluidPump.c =================================================================== diff -u -r051cd0430ef8342bd606115c98871e26dc24acf1 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Drivers/FluidPump.c (.../FluidPump.c) (revision 051cd0430ef8342bd606115c98871e26dc24acf1) +++ firmware/App/Drivers/FluidPump.c (.../FluidPump.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -16,7 +16,7 @@ ***************************************************************************/ #include "FluidPump.h" -#include "FpgaRO.h" +#include "FpgaFP.h" #include "Messaging.h" #include "MessageSupport.h" #include "PersistentAlarm.h" Index: firmware/App/Drivers/PressureSensor.c =================================================================== diff -u -r051cd0430ef8342bd606115c98871e26dc24acf1 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision 051cd0430ef8342bd606115c98871e26dc24acf1) +++ firmware/App/Drivers/PressureSensor.c (.../PressureSensor.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,8 +15,8 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" -#include "FpgaRO.h" +#include "AlarmMgmtFP.h" +#include "FpgaFP.h" #include "Messaging.h" #include "PersistentAlarm.h" #include "PressureSensor.h" Index: firmware/App/Drivers/TemperatureSensor.c =================================================================== diff -u -rb3768ad7d1f1282c7cd4199d0b993bbcc2ef492d -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Drivers/TemperatureSensor.c (.../TemperatureSensor.c) (revision b3768ad7d1f1282c7cd4199d0b993bbcc2ef492d) +++ firmware/App/Drivers/TemperatureSensor.c (.../TemperatureSensor.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -19,7 +19,7 @@ #include // For memset() #include "Conductivity.h" -#include "FpgaRO.h" +#include "FpgaFP.h" #include "MessageSupport.h" #include "Messaging.h" //#include "NVDataMgmt.h" Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/FilterFlush.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/FilterFlush.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Modes/FlushConcentrate.c =================================================================== diff -u --- firmware/App/Modes/FlushConcentrate.c (revision 0) +++ firmware/App/Modes/FlushConcentrate.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1 @@ \ No newline at end of file Index: firmware/App/Modes/FlushConcentrate.h =================================================================== diff -u --- firmware/App/Modes/FlushConcentrate.h (revision 0) +++ firmware/App/Modes/FlushConcentrate.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,15 @@ +/* + * FlushConcentrate.h + * + * Created on: Jul 2, 2025 + * Author: fw + */ + +#ifndef APP_MODES_FLUSHCONCENTRATE_H_ +#define APP_MODES_FLUSHCONCENTRATE_H_ + + + + + +#endif /* APP_MODES_FLUSHCONCENTRATE_H_ */ Index: firmware/App/Modes/FlushFilter.c =================================================================== diff -u --- firmware/App/Modes/FlushFilter.c (revision 0) +++ firmware/App/Modes/FlushFilter.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,365 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 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 FlushFilter.c +* +* @author (last) Michael Garthwaite +* @date (last) 28-Feb-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 28-Feb-2025 +* +***************************************************************************/ + +#include + +#include "FlushFilter.h" +#include "MessageSupport.h" +#include "Messaging.h" +#include "OperationModes.h" +#include "Pressure.h" +#include "TaskGeneral.h" +#include "Timers.h" +#include "Valves.h" + +/** + * @addtogroup FPFilterFlush + * @{ + */ + +// ********** private definitions ********** + +#define FILTER_FLUSH_MAX_TIMEOUT ( 600 * MS_PER_SECOND ) ///< Max override timeout for 10 minutes +#define FILTER_FLUSH_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen water mode data published. +#define FILTER_FLUSH_TIMEOUT ( 30 * MS_PER_SECOND ) ///< filter flush timer (in ms) +#define FILTER_HEALTH_PRESSURE_DIFF 10 + +// ********** private data ********** + +static FP_FILTER_FLUSH_STATE_T filterFlushState; ///< Currently active filter flush state. +static U32 filterFlushDataPublicationTimerCounter; ///< Used to schedule filter flush data publication to CAN bus. +static OVERRIDE_U32_T filterFlushDataPublishInterval; ///< Filter Flush mode data publish interval. +static OVERRIDE_U32_T filterFlushTimeout; ///< Filter Flush timeout value +static U32 filterFlushTimer; ///< Filter Flush timeout timer +static BOOL pendingStartFilterFlushRequest; ///< signal to start flushing. +static BOOL isFlushComplete; ///< Filter Flush complete BOOL + +// ********** private function prototypes ********** + +static void publishFilterFlushData( void ); +static FP_FILTER_FLUSH_STATE_T handleFilterFlushProgressState( void ); +static FP_FILTER_FLUSH_STATE_T handleFilterFlushPausedState( void ); +static void setFilterFlushTransition( FP_FILTER_FLUSH_STATE_T state ); +static U32 getFilterFlushTimeout( void ); +static U32 getFilterFlushPublishInterval( void ); + +/*********************************************************************//** + * @brief + * The initFilterFlush function initializes the filter flush unit. + * @details \b Inputs: none + * @details \b Outputs: filter flush unit initialized + * @return none + *************************************************************************/ +void initFilterFlush( void ) +{ + filterFlushState = FILTER_FLUSH_PAUSED; + filterFlushDataPublishInterval.data = FILTER_FLUSH_DATA_PUBLISH_INTERVAL; + filterFlushDataPublishInterval.ovData = FILTER_FLUSH_DATA_PUBLISH_INTERVAL; + filterFlushDataPublishInterval.ovInitData = 0; + filterFlushDataPublishInterval.override = OVERRIDE_RESET; + filterFlushTimeout.data = FILTER_FLUSH_TIMEOUT; + filterFlushTimeout.ovData = FILTER_FLUSH_TIMEOUT; + filterFlushTimeout.ovInitData = 0; + filterFlushTimeout.override = OVERRIDE_RESET; + filterFlushDataPublicationTimerCounter = 0; + filterFlushTimer = 0; + isFlushComplete = FALSE; + pendingStartFilterFlushRequest = FALSE; +} + +/*********************************************************************//** + * @brief + * The execFilterFlush function executes the filter flush state machine + * and publishes filter flush data. + * @details \b Inputs: filterFlushState + * @details \b Outputs: filterFlushState + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if in invalid flush state + * @return none + *************************************************************************/ +void execFilterFlush( void ) +{ + switch ( filterFlushState ) + { + case FILTER_FLUSH_IN_PROGRESS: + filterFlushState = handleFilterFlushProgressState(); + break; + + case FILTER_FLUSH_PAUSED: + filterFlushState = handleFilterFlushPausedState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_FILTER_FLUSH_STATE, (U32)filterFlushState ) + filterFlushState = FILTER_FLUSH_PAUSED; + break; + } + + // publish filter flush data on interval + publishFilterFlushData(); +} + +/*********************************************************************//** + * @brief + * The handleFilterFlushProgressState handles the in progress state of filter flush + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of filter flush state + *************************************************************************/ +static FP_FILTER_FLUSH_STATE_T handleFilterFlushProgressState( void ) +{ + FP_FILTER_FLUSH_STATE_T state = FILTER_FLUSH_IN_PROGRESS; + BOOL isPressureOutOfRange = FALSE; + F32 pressureDif = 0.0; + + if( TRUE == didTimeout( filterFlushTimer, getFilterFlushTimeout() ) ) + { + pressureDif = fabs( getFilteredPressure(M3_PRES) - getFilteredPressure(P8_PRES) ); + isPressureOutOfRange = ( pressureDif > FILTER_HEALTH_PRESSURE_DIFF ? TRUE : FALSE ); + + if( TRUE == isPressureOutOfRange ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_FILTER_HEALTH_PRESSURE_OUT_OF_RANGE, pressureDif, FILTER_HEALTH_PRESSURE_DIFF ) + setFilterFlushTransition( FILTER_FLUSH_PAUSED ); + state = FILTER_FLUSH_PAUSED; + } + else + { + isFlushComplete = TRUE; + setFilterFlushTransition( FILTER_FLUSH_PAUSED ); + state = FILTER_FLUSH_PAUSED; + + } + } + return state; +} + +/*********************************************************************//** + * @brief + * The handleFilterFlushProgressState handles the in progress state of filter flush + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of filter flush state + *************************************************************************/ +static FP_FILTER_FLUSH_STATE_T handleFilterFlushPausedState( void ) +{ + FP_FILTER_FLUSH_STATE_T state = FILTER_FLUSH_PAUSED; + + if ( TRUE == pendingStartFilterFlushRequest ) + { + isFlushComplete = FALSE; + pendingStartFilterFlushRequest = FALSE; + filterFlushTimer = getMSTimerCount(); + setFilterFlushTransition( FILTER_FLUSH_IN_PROGRESS ); + state = FILTER_FLUSH_IN_PROGRESS; + } + return state; +} + +/*********************************************************************//** + * @brief + * The setFilterFlushTransition function sets the actuators and variables + * for the state transition in filter flush mode. + * @details Inputs: Valve states, Pump speed + * @details Outputs: Actuate valves, pumps as desired. + * @param state filter flush state enum + * @return none + *************************************************************************/ +static void setFilterFlushTransition( FP_FILTER_FLUSH_STATE_T state ) +{ + // Execute on running state + switch( state ) + { + case FILTER_FLUSH_IN_PROGRESS: + setValveState( M4_VALV, VALVE_STATE_OPEN ); + setValveState( P6_VALV, VALVE_STATE_OPEN ); + setValveState( P11_VALV, VALVE_STATE_CLOSED ); + setValveState( P33_VALV, VALVE_STATE_CLOSED ); + setValveState( P34_VALV, VALVE_STATE_CLOSED ); + setValveState( P37_VALV, VALVE_STATE_CLOSED ); + setValveState( P39_VALV, VALVE_STATE_OPEN ); + filterFlushTimer = getMSTimerCount(); + break; + + case FILTER_FLUSH_PAUSED: + // close only if we actually pause during flush + if ( FALSE == isFilterFlushComplete() ) + { + setValveState( M4_VALV, VALVE_STATE_CLOSED ); + setValveState( P6_VALV, VALVE_STATE_CLOSED ); + setValveState( P11_VALV, VALVE_STATE_CLOSED ); + setValveState( P33_VALV, VALVE_STATE_CLOSED ); + setValveState( P34_VALV, VALVE_STATE_CLOSED ); + setValveState( P37_VALV, VALVE_STATE_CLOSED ); + setValveState( P39_VALV, VALVE_STATE_CLOSED ); + } + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_FILTER_FLUSH_STATE, state ) + break; + } +} + +/*********************************************************************//** + * @brief + * The signalStartFilterFlush function signals the FP to start filter flush. + * @details \b Inputs: none + * @details \b Outputs: pendingStartFilterFlushRequest + * @return none + *************************************************************************/ +void signalStartFilterFlush( void ) +{ + if ( FILTER_FLUSH_PAUSED == getCurrentFilterFlushState() ) + { + pendingStartFilterFlushRequest = TRUE; + } +} + +/*********************************************************************//** + * @brief + * The resetFilterFlushSignals function resets the signal values for + * FP filter flush. + * @details \b Inputs: none + * @details \b Outputs: pendingStartFilterFlushRequest, isFlushComplete + * @return none + *************************************************************************/ +void resetFilterFlushSignals( void ) +{ + pendingStartFilterFlushRequest = FALSE; + isFlushComplete = FALSE; +} + +/*********************************************************************//** + * @brief + * The getCurrentFilterFlushState function returns the current state of + * filter flush. + * @details \b Inputs: filterFlushState + * @details \b Outputs: filterFlushState + * @return the current state of filter flush + *************************************************************************/ +FP_FILTER_FLUSH_STATE_T getCurrentFilterFlushState( void ) +{ + return filterFlushState; +} + +/*********************************************************************//** + * @brief + * The isFilterFlushComplete function returns isFilterFlushComplete. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the complete boolean for filter flush. + *************************************************************************/ +BOOL isFilterFlushComplete( void ) +{ + return isFlushComplete; +} + + +/*********************************************************************//** + * @brief + * The getFilterFlushTimeout function gets the generate water + * mode data publish interval. + * @details \b Inputs: filterFlushTimeOut + * @details \b Outputs: none + * @return the timeout timer for filter flush. + *************************************************************************/ +static U32 getFilterFlushTimeout( void ) +{ + U32 result = getU32OverrideValue( &filterFlushTimeout ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getFilterFlushPublishInterval function gets the filter flush + * mode data publish interval. + * @details \b Inputs: filterFlushDataPublishInterval + * @details \b Outputs: none + * @return the interval at filter flush mode data being published. + *************************************************************************/ +static U32 getFilterFlushPublishInterval( void ) +{ + U32 result = getU32OverrideValue( &filterFlushDataPublishInterval ); + + return result; +} + +/*********************************************************************//** + * @brief + * The publishFilterFlushData function broadcasts the filter flush + * mode data at defined interval. + * @details \b Inputs: filterFlushDataPublicationTimerCounter + * @details \b Outputs: fp filter flush data broadcast message sent + * @details \b Message \Sent: MSG_ID_FP_GEN_WATER_MODE_DATA to publish the + * filter flush mode data. + * @return none + *************************************************************************/ +static void publishFilterFlushData( void ) +{ + if ( ++filterFlushDataPublicationTimerCounter >= getFilterFlushPublishInterval() ) + { + FILTER_FLUSH_DATA_T data; + + data.filterFlushExecState = (U32)getCurrentFilterFlushState(); + broadcastData( MSG_ID_FP_FILTER_FLUSH_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( FILTER_FLUSH_DATA_T ) ); + + filterFlushDataPublicationTimerCounter = 0; + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testFilterFlushDataPublishIntervalOverride function overrides the + * FP filter flush mode data publish interval. + * @details \b Inputs: filterFlushDataPublishInterval + * @details \b Outputs: filterFlushDataPublishInterval + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP filter flush data publish interval to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testFilterFlushDataPublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &filterFlushDataPublishInterval, TASK_GENERAL_INTERVAL ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testFilterFlushTimerOverride function overrides the + * FP filter flush timeout value. + * @details \b Inputs: filterFlushTimeout + * @details \b Outputs: filterFlushTimeout + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP filter flush timeout to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testFilterFlushTimerOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &filterFlushTimeout, 0, FILTER_FLUSH_MAX_TIMEOUT ); + + return result; +} + +/**@}*/ Index: firmware/App/Modes/FlushFilter.h =================================================================== diff -u --- firmware/App/Modes/FlushFilter.h (revision 0) +++ firmware/App/Modes/FlushFilter.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,56 @@ +/************************************************************************** +* +* Copyright (c) 2024-2025 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 FlushFilter.h +* +* @author (last) Michael Garthwaite +* @date (last) 03-Mar-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 03-Mar-2025 +* +***************************************************************************/ + +#ifndef __FLUSH_FILTER_H__ +#define __FLUSH_FILTER_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + +/** + * @defgroup FPFilterFlush FPFilterFlush + * @brief Filter Flush unit. Manages filter flush functions via a state machine. + * + * @addtogroup FPFilterFlush + * @{ + */ + +// ********** public definitions ********** + +/// Filter Flush data structure +typedef struct +{ + U32 filterFlushExecState; ///< Filter Flush execution state +} FILTER_FLUSH_DATA_T; + +// ********** public function prototypes ********** + +void initFilterFlush( void ); // Initialize this Filter Flush unit +U32 transitionToFilterFlush( void ); // Transition to Filter Flush +void execFilterFlush( void ); // Execute the Filter Flush state machine +BOOL isFilterFlushComplete( void ); // returns if flush is complete +void signalStartFilterFlush( void ); // signal to start flush +void resetFilterFlushSignals( void ); // reset signals for flush + +FP_FILTER_FLUSH_STATE_T getCurrentFilterFlushState( void ); // Get the current state of the Filter Flush + +BOOL testFilterFlushDataPublishIntervalOverride( MESSAGE_T *message ); +BOOL testFilterFlushTimerOverride( MESSAGE_T *message ); +/**@}*/ + + +#endif Index: firmware/App/Modes/FlushPermeate.c =================================================================== diff -u --- firmware/App/Modes/FlushPermeate.c (revision 0) +++ firmware/App/Modes/FlushPermeate.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,418 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 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 FlushPermeate.c +* +* @author (last) Michael Garthwaite +* @date (last) 28-Feb-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 28-Feb-2025 +* +***************************************************************************/ + +#include + +#include "Conductivity.h" +#include "BoostPump.h" +#include "FlushPermeate.h" +#include "MessageSupport.h" +#include "Messaging.h" +#include "OperationModes.h" +#include "Pressure.h" +#include "ROPump.h" +#include "TaskGeneral.h" +#include "Timers.h" +#include "Valves.h" + +/** + * @addtogroup FPPermeateFlush + * @{ + */ + +// ********** private definitions ********** + +#define PERMEATE_FLUSH_MAX_TIMEOUT ( 600 * MS_PER_SECOND ) ///< Max override timeout for 10 minutes +#define PERMEATE_FLUSH_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen water mode data published. +#define PERMEATE_FLUSH_TIMEOUT ( 30 * MS_PER_SECOND ) ///< Permeate flush timer (in ms) +#define PERMEATE_FLUSH_ALARM_TIMEOUT ( 120 * MS_PER_SECOND ) ///< Permeate flush timer (in ms) +#define PERMEATE_FLUSH_RO_PUMP_TGT_PSI 15 ///< Pressure target in PSI for the RO pump during permeate flush. +#define PERMEATE_FLUSH_BOOST_PUMP_TGT_PSI 25 ///< Pressure target in PSI for the boost pump during permeate flush. +#define PERMEATE_FLUSH_CONDUCTIVITY_THRESHOLD 200.0F ///< Conductivity alarm threshold for permeate flush. + +// ********** private data ********** + +static FP_PERM_FLUSH_STATE_T permeateFlushState; ///< Currently active Permeate flush state. +static U32 permeateFlushDataPublicationTimerCounter; ///< Used to schedule Permeate flush data publication to CAN bus. +static OVERRIDE_U32_T permeateFlushDataPublishInterval; ///< Permeate Flush mode data publish interval. +static OVERRIDE_U32_T permeateFlushTimeout; ///< Permeate Flush timeout value +static OVERRIDE_U32_T permeateFlushAlarmTimeout; +static U32 permeateFlushTimer; ///< Permeate Flush timeout timer +static U32 permeateFlushAlarmTimer; +static BOOL pendingStartPermeateFlushRequest; ///< signal to start flushing. +static BOOL isFlushComplete; ///< Permeate Flush complete BOOL + +// ********** private function prototypes ********** + +static void publishPermeateFlushData( void ); +static FP_PERM_FLUSH_STATE_T handlePermeateFlushProgressState( void ); +static FP_PERM_FLUSH_STATE_T handlePermeateFlushPausedState( void ); +static void setPermeateFlushTransition( FP_PERM_FLUSH_STATE_T state ); +static U32 getPermeateFlushTimeout( void ); +static U32 getPermeateFlushAlarmTimeout( void ); +static U32 getPermeateFlushPublishInterval( void ); + +/*********************************************************************//** + * @brief + * The initPermeateFlush function initializes the Permeate flush unit. + * @details \b Inputs: none + * @details \b Outputs: Permeate flush unit initialized + * @return none + *************************************************************************/ +void initPermeateFlush( void ) +{ + permeateFlushState = PERM_FLUSH_PAUSED; + permeateFlushDataPublishInterval.data = PERMEATE_FLUSH_DATA_PUBLISH_INTERVAL; + permeateFlushDataPublishInterval.ovData = PERMEATE_FLUSH_DATA_PUBLISH_INTERVAL; + permeateFlushDataPublishInterval.ovInitData = 0; + permeateFlushDataPublishInterval.override = OVERRIDE_RESET; + permeateFlushTimeout.data = PERMEATE_FLUSH_TIMEOUT; + permeateFlushTimeout.ovData = PERMEATE_FLUSH_TIMEOUT; + permeateFlushTimeout.ovInitData = 0; + permeateFlushTimeout.override = OVERRIDE_RESET; + permeateFlushAlarmTimeout.data = PERMEATE_FLUSH_ALARM_TIMEOUT; + permeateFlushAlarmTimeout.ovData = PERMEATE_FLUSH_ALARM_TIMEOUT; + permeateFlushAlarmTimeout.ovInitData = 0; + permeateFlushAlarmTimeout.override = OVERRIDE_RESET; + permeateFlushDataPublicationTimerCounter = 0; + permeateFlushTimer = 0; + permeateFlushAlarmTimer = 0; + isFlushComplete = FALSE; + pendingStartPermeateFlushRequest = FALSE; +} + +/*********************************************************************//** + * @brief + * The execPermeateFlush function executes the Permeate flush state machine + * and publishes Permeate flush data. + * @details \b Inputs: permeateFlushState + * @details \b Outputs: permeateFlushState + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if in invalid flush state + * @return none + *************************************************************************/ +void execPermeateFlush( void ) +{ + switch ( permeateFlushState ) + { + case PERM_FLUSH_IN_PROGRESS: + permeateFlushState = handlePermeateFlushProgressState(); + break; + + case PERM_FLUSH_PAUSED: + permeateFlushState = handlePermeateFlushPausedState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PERMEATE_FLUSH_STATE, (U32)permeateFlushState ) + permeateFlushState = PERM_FLUSH_PAUSED; + break; + } + + // publish Permeate flush data on interval + publishPermeateFlushData(); +} + +/*********************************************************************//** + * @brief + * The handlePermeateFlushProgressState handles the in progress state of Permeate flush + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of Permeate flush state + *************************************************************************/ +static FP_PERM_FLUSH_STATE_T handlePermeateFlushProgressState( void ) +{ + FP_PERM_FLUSH_STATE_T state = PERM_FLUSH_IN_PROGRESS; + + if( TRUE == didTimeout( permeateFlushTimer, getPermeateFlushTimeout() ) ) + { + F32 p18conductivity = getFilteredConductivity( P18_COND ); + if( PERMEATE_FLUSH_CONDUCTIVITY_THRESHOLD > p18conductivity ) + { + isFlushComplete = TRUE; + setPermeateFlushTransition( PERM_FLUSH_PAUSED ); + state = PERM_FLUSH_PAUSED; + } + + // If conductivity is not in range, continue to monitor until timeout + else + { + if( TRUE == didTimeout( permeateFlushAlarmTimer, getPermeateFlushAlarmTimeout() ) ) + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_PERMEATE_FLUSH_CONDUCTIVITY_TIMEOUT, PERMEATE_FLUSH_CONDUCTIVITY_THRESHOLD, p18conductivity) + setPermeateFlushTransition( PERM_FLUSH_PAUSED ); + state = PERM_FLUSH_PAUSED; + } + } + + } + return state; +} + +/*********************************************************************//** + * @brief + * The handlePermeateFlushProgressState handles the in progress state of Permeate flush + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of Permeate flush state + *************************************************************************/ +static FP_PERM_FLUSH_STATE_T handlePermeateFlushPausedState( void ) +{ + FP_PERM_FLUSH_STATE_T state = PERM_FLUSH_PAUSED; + + if ( TRUE == pendingStartPermeateFlushRequest ) + { + isFlushComplete = FALSE; + pendingStartPermeateFlushRequest = FALSE; + permeateFlushTimer = getMSTimerCount(); + permeateFlushAlarmTimer = getMSTimerCount(); + setPermeateFlushTransition( PERM_FLUSH_IN_PROGRESS ); + state = PERM_FLUSH_IN_PROGRESS; + } + return state; +} + +/*********************************************************************//** + * @brief + * The setPermeateFlushTransition function sets the actuators and variables + * for the state transition in Permeate flush mode. + * @details Inputs: Valve states, Pump speed + * @details Outputs: Actuate valves, pumps as desired. + * @param state Permeate flush state enum + * @return none + *************************************************************************/ +static void setPermeateFlushTransition( FP_PERM_FLUSH_STATE_T state ) +{ + // Execute on running state + switch( state ) + { + case PERM_FLUSH_IN_PROGRESS: + setValveState( M4_VALV, VALVE_STATE_OPEN ); + setValveState( P6_VALV, VALVE_STATE_CLOSED ); + setValveState( P11_VALV, VALVE_STATE_OPEN ); + setValveState( P33_VALV, VALVE_STATE_CLOSED ); + setValveState( P34_VALV, VALVE_STATE_CLOSED ); + setValveState( P37_VALV, VALVE_STATE_CLOSED ); + setValveState( P39_VALV, VALVE_STATE_OPEN ); + setROPumpTargetPressure( PERMEATE_FLUSH_RO_PUMP_TGT_PSI ); + setBoostPumpTargetPressure( PERMEATE_FLUSH_BOOST_PUMP_TGT_PSI ); + permeateFlushTimer = getMSTimerCount(); + permeateFlushAlarmTimer = getMSTimerCount(); + break; + + case PERM_FLUSH_PAUSED: + + // Stop pumps and close only if we alarm ( pause ) during flush. + if ( FALSE == isPermeateFlushComplete() ) + { + setValveState( M4_VALV, VALVE_STATE_CLOSED ); + setValveState( P6_VALV, VALVE_STATE_CLOSED ); + setValveState( P11_VALV, VALVE_STATE_CLOSED ); + setValveState( P33_VALV, VALVE_STATE_CLOSED ); + setValveState( P34_VALV, VALVE_STATE_CLOSED ); + setValveState( P37_VALV, VALVE_STATE_CLOSED ); + setValveState( P39_VALV, VALVE_STATE_CLOSED ); + signalBoostPumpHardStop(); + signalROPumpHardStop(); + } + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PERMEATE_FLUSH_STATE, state ) + break; + } +} + +/*********************************************************************//** + * @brief + * The signalStartPermeateFlush function signals the FP to start Permeate flush. + * @details \b Inputs: none + * @details \b Outputs: pendingStartPermeateFlushRequest + * @return the current state of Permeate flush + *************************************************************************/ +void signalStartPermeateFlush( void ) +{ + if ( PERM_FLUSH_PAUSED == getCurrentPermeateFlushState() ) + { + pendingStartPermeateFlushRequest = TRUE; + } +} + +/*********************************************************************//** + * @brief + * The resetFilterFlushSignals function resets the signal values for + * FP filter flush. + * @details \b Inputs: none + * @details \b Outputs: pendingStartFilterFlushRequest, isFlushComplete + * @return none + *************************************************************************/ +void resetPermeateFlushSignals( void ) +{ + pendingStartPermeateFlushRequest = FALSE; + isFlushComplete = FALSE; +} + +/*********************************************************************//** + * @brief + * The getCurrentPermeateFlushState function returns the current state of + * Permeate flush. + * @details \b Inputs: permeateFlushState + * @details \b Outputs: permeateFlushState + * @return the current state of Permeate flush + *************************************************************************/ +FP_PERM_FLUSH_STATE_T getCurrentPermeateFlushState( void ) +{ + return permeateFlushState; +} + +/*********************************************************************//** + * @brief + * The isPermeateFlushComplete function returns isPermeateFlushComplete. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the complete boolean for Permeate flush. + *************************************************************************/ +BOOL isPermeateFlushComplete( void ) +{ + return isFlushComplete; +} + +/*********************************************************************//** + * @brief + * The getPermeateFlushTimeout function gets the generate water + * mode data publish interval. + * @details \b Inputs: PermeateFlushTimeOut + * @details \b Outputs: none + * @return the timeout timer for Permeate flush. + *************************************************************************/ +static U32 getPermeateFlushTimeout( void ) +{ + U32 result = getU32OverrideValue( &permeateFlushTimeout ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getPermeateFlushTimeout function gets the generate water + * mode data publish interval. + * @details \b Inputs: PermeateFlushTimeOut + * @details \b Outputs: none + * @return the timeout timer for Permeate flush. + *************************************************************************/ +static U32 getPermeateFlushAlarmTimeout( void ) +{ + U32 result = getU32OverrideValue( &permeateFlushAlarmTimeout ); + + return result; +} + +/*********************************************************************//** + * @brief + * The getPermeateFlushPublishInterval function gets the Permeate flush + * mode data publish interval. + * @details \b Inputs: permeateFlushDataPublishInterval + * @details \b Outputs: none + * @return the interval at Permeate flush mode data being published. + *************************************************************************/ +static U32 getPermeateFlushPublishInterval( void ) +{ + U32 result = getU32OverrideValue( &permeateFlushDataPublishInterval ); + + return result; +} + +/*********************************************************************//** + * @brief + * The publishPermeateFlushData function broadcasts the Permeate flush + * mode data at defined interval. + * @details \b Inputs: permeateFlushDataPublicationTimerCounter + * @details \b Outputs: fp Permeate flush data broadcast message sent + * @details \b Message \Sent: MSG_ID_FP_PERMEATE_FLUSH_DATA to publish the + * Permeate flush mode data. + * @return none + *************************************************************************/ +static void publishPermeateFlushData( void ) +{ + if ( ++permeateFlushDataPublicationTimerCounter >= getPermeateFlushPublishInterval() ) + { + PERM_FLUSH_DATA_T data; + + data.permeateFlushExecState = (U32)getCurrentPermeateFlushState(); + broadcastData( MSG_ID_FP_PERMEATE_FLUSH_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( PERM_FLUSH_DATA_T ) ); + + permeateFlushDataPublicationTimerCounter = 0; + } +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testPermeateFlushDataPublishIntervalOverride function overrides the + * FP Permeate flush mode data publish interval. + * @details \b Inputs: permeateFlushDataPublishInterval + * @details \b Outputs: permeateFlushDataPublishInterval + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP Permeate flush data publish interval to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testPermeateFlushDataPublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &permeateFlushDataPublishInterval, TASK_GENERAL_INTERVAL ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testPermeateFlushTimerOverride function overrides the + * FP Permeate flush timeout value. + * @details \b Inputs: permeateFlushTimeout + * @details \b Outputs: permeateFlushTimeout + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP Permeate flush timeout to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testPermeateFlushTimerOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &permeateFlushTimeout, 0, PERMEATE_FLUSH_MAX_TIMEOUT ); + + return result; +} + +/*********************************************************************//** + * @brief + * The testPermeateFlushAlarmTimerOverride function overrides the + * FP Permeate flush timeout value. + * @details \b Inputs: permeateFlushAlarmTimeout + * @details \b Outputs: permeateFlushAlarmTimeout + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP Permeate flush timeout to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testPermeateFlushAlarmTimerOverride( MESSAGE_T *message ) +{ + BOOL result = u32Override( message, &permeateFlushAlarmTimeout, 0, PERMEATE_FLUSH_MAX_TIMEOUT ); + + return result; +} + +/**@}*/ Index: firmware/App/Modes/FlushPermeate.h =================================================================== diff -u --- firmware/App/Modes/FlushPermeate.h (revision 0) +++ firmware/App/Modes/FlushPermeate.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,56 @@ +/************************************************************************** +* +* Copyright (c) 2024-2025 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 FlushPermeate.h +* +* @author (last) Michael Garthwaite +* @date (last) 03-Mar-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 03-Mar-2025 +* +***************************************************************************/ + +#ifndef __FLUSH_PERMEATE_H__ +#define __FLUSH_PERMEATE_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + +/** + * @defgroup FPPermeateFlush FPPermeateFlush + * @brief Permeate Flush unit. Manages Permeate flush functions via a state machine. + * + * @addtogroup FPPermeateFlush + * @{ + */ + +// ********** public definitions ********** + +/// Permeate Flush data structure +typedef struct +{ + U32 permeateFlushExecState; ///< Permeate Flush execution state +} PERM_FLUSH_DATA_T; + +// ********** public function prototypes ********** + +void initPermeateFlush( void ); // Initialize this Permeate Flush unit +U32 transitionToPermeateFlush( void ); // Transition to Permeate Flush +void execPermeateFlush( void ); // Execute the Permeate Flush state machine +BOOL isPermeateFlushComplete( void ); // returns if flush is complete +void signalStartPermeateFlush( void ); // signal to start flush +void resetPermeateFlushSignals( void ); // reset signals for flush + +FP_PERM_FLUSH_STATE_T getCurrentPermeateFlushState( void ); // Get the current state of the Permeate Flush + +BOOL testPermeateFlushDataPublishIntervalOverride( MESSAGE_T *message ); +BOOL testPermeateFlushTimerOverride( MESSAGE_T *message ); +/**@}*/ + + +#endif Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/MembraneFlush.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/MembraneFlush.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Modes/ModeFault.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Modes/ModeFault.h (.../ModeFault.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -3,13 +3,13 @@ #define __MODE_FAULT_H__ #include "FPCommon.h" -#include "RODefs.h" +#include "FPDefs.h" /** - * @defgroup ROFaultMode ROFaultMode + * @defgroup FPFaultMode FPFaultMode * @brief FaultMode unit. * - * @addtogroup ROFaultMode + * @addtogroup FPFaultMode * @{ */ Index: firmware/App/Modes/ModeGenPermeate.c =================================================================== diff -u --- firmware/App/Modes/ModeGenPermeate.c (revision 0) +++ firmware/App/Modes/ModeGenPermeate.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,332 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 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 ModeGenPermeate.c +* +* @author (last) Michael Garthwaite +* @date (last) 28-Feb-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 28-Feb-2025 +* +***************************************************************************/ + +#include +#include "DDInterface.h" +#include "Level.h" +#include "MessageSupport.h" +#include "Messaging.h" +#include "ModeGenPermeate.h" +#include "ModeStandby.h" +#include "OperationModes.h" +#include "TaskGeneral.h" +#include "Timers.h" +#include "Valves.h" + +/** + * @addtogroup FPGenPermeateMode + * @{ + */ + +// ********** private definitions ********** + +#define GEN_PERMEATE_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the gen permeate mode data published. +#define GEN_PERMEATE_TIMEOUT_MS ( 6 * MS_PER_SECOND ) ///< state switch timeout (in ms) + +// ********** private data ********** + +static FP_GENP_MODE_STATE_T genPermeateState; ///< Currently active generate Permeate state. +static U32 genPermeateDataPublicationTimerCounter; ///< Used to schedule generate Permeate data publication to CAN bus. +static OVERRIDE_U32_T genPermeateDataPublishInterval; ///< Generate permeate mode data publish interval. +static U32 stateDelayTime; ///< Time stamp to track delay before valve switch. +static U32 pendingStartGenRequest; ///< Flag indicating DD has requested FP start the generate permeate. + +// ********** private function prototypes ********** + +static void publishGenPModeData( void ); +static FP_GENP_MODE_STATE_T handleGenPTankFullState( void ); +static FP_GENP_MODE_STATE_T handleGenPTankFillState( void ); +static void setModeGenPTransition( FP_GENP_MODE_STATE_T state ); +static U32 getGenPermeateDataPublishInterval( void ); + +/*********************************************************************//** + * @brief + * The initGenPermeateMode function initializes the water generation mode unit. + * @details \b Inputs: none + * @details \b Outputs: Gen water mode unit initialized + * @return none + *************************************************************************/ +void initGenPermeateMode( void ) +{ + genPermeateState = FP_GENP_TANK_FILL_STATE; + genPermeateDataPublishInterval.data = GEN_PERMEATE_DATA_PUBLISH_INTERVAL; + genPermeateDataPublishInterval.ovData = GEN_PERMEATE_DATA_PUBLISH_INTERVAL; + genPermeateDataPublishInterval.ovInitData = 0; + genPermeateDataPublishInterval.override = OVERRIDE_RESET; + genPermeateDataPublicationTimerCounter = 0; + stateDelayTime = 0; + pendingStartGenRequest = 0; +} + +/*********************************************************************//** + * @brief + * The transitionToGenPermeateMode function prepares for transition to gen + * permeate mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @return initial state + *************************************************************************/ +U32 transitionToGenPermeateMode( void ) +{ + initGenPermeateMode(); + setCurrentSubState( genPermeateState ); + + return genPermeateState; +} + +/*********************************************************************//** + * @brief + * The execGenPermeateMode function executes the Gen Permeate mode state machine. + * @details \b Inputs: none + * @details \b Outputs: Gen Permeate mode state machine executed + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT when wrong gen Permeate state invoked. + * @return current state. + *************************************************************************/ +U32 execGenPermeateMode( void ) +{ + LEVEL_STATE_T level = getLevelStatus(); + + if ( LEVEL_STATE_ILLEGAL == level ) + { + // TODO: Raise illegal level alarm + } + + // execute current gen Permeate state + switch ( genPermeateState ) + { + case FP_GENP_TANK_FILL_STATE: + genPermeateState = handleGenPTankFullState(); + break; + + case FP_GENP_TANK_FULL_STATE: + genPermeateState = handleGenPTankFillState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_GENP_STATE, genPermeateState ) + break; + + } + //Publish Gen Permeate mode data + publishGenPModeData(); + + return genPermeateState; +} + +/*********************************************************************//** + * @brief + * The setModeGenPTransition function sets the actuators and variables + * for the state transition in generate permeate mode. + * @details Inputs: Valve states, Pump speed + * @details Outputs: Actuate valves, pumps as desired. + * @param state gen permeate state enum + * @return none + *************************************************************************/ +static void setModeGenPTransition( FP_GENP_MODE_STATE_T state ) +{ + // Execute on running state + switch( state ) + { + case FP_GENP_TANK_FILL_STATE: + setValveState( M4_VALV,VALVE_STATE_OPEN ); + setValveState( M7_VALV,VALVE_STATE_CLOSED ); + setValveState( P6_VALV,VALVE_STATE_CLOSED ); + setValveState( P39_VALV,VALVE_STATE_OPEN ); + setValveState( P11_VALV, VALVE_STATE_OPEN ); + break; + + case FP_GENP_TANK_FULL_STATE: + setValveState( M4_VALV,VALVE_STATE_CLOSED ); + setValveState( M7_VALV,VALVE_STATE_CLOSED ); + setValveState( P6_VALV,VALVE_STATE_CLOSED ); + setValveState( P39_VALV,VALVE_STATE_OPEN ); + setValveState( P11_VALV, VALVE_STATE_CLOSED ); + stateDelayTime = getMSTimerCount(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_GENP_STATE, state ) + break; + } +} + +/*********************************************************************//** + * @brief + * The handleGenPTankFillState handles the fill state of gen water. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of gen water mode + *************************************************************************/ +static FP_GENP_MODE_STATE_T handleGenPTankFillState( void ) +{ + FP_GENP_MODE_STATE_T state = FP_GENP_TANK_FILL_STATE; + LEVEL_STATE_T level = getLevelStatus(); + + if ( LEVEL_STATE_HIGH == level ) + { + setModeGenPTransition( FP_GENP_TANK_FULL_STATE ); + state = FP_GENP_TANK_FULL_STATE; + } + + else if ( level <= LEVEL_STATE_MEDIUM ) + { + // expected state. No action required. + // If level is low we still want to fill. + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handleGenPTankFullState handles the full state of gen permeate. + * @details \b Inputs: stateDelayTime + * @details \b Outputs: none + * @return the next state of gen permeate mode + *************************************************************************/ +static FP_GENP_MODE_STATE_T handleGenPTankFullState( void ) +{ + FP_GENP_MODE_STATE_T state = FP_GENP_TANK_FULL_STATE; + LEVEL_STATE_T level = getLevelStatus(); + + if ( LEVEL_STATE_LOW == level ) + { + // TODO: Turn off heater. + } + + else if ( ( level >= LEVEL_STATE_MEDIUM ) && ( TRUE == didTimeout( stateDelayTime, GEN_PERMEATE_TIMEOUT_MS ) ) ) + { + setModeGenPTransition( FP_GENP_TANK_FILL_STATE ); + state = FP_GENP_TANK_FILL_STATE; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The getCurrentGenPermeateState function returns the current state of the + * gen permeate mode. + * @details \b Inputs: genPermeateState + * @details \b Outputs: genPermeateState + * @return the current state of gen permeate mode + *************************************************************************/ +FP_GENP_MODE_STATE_T getCurrentGenPermeateState( void ) +{ + return genPermeateState; +} + +/*********************************************************************//** + * @brief + * The getGenPermeateDataPublishInterval function gets the generate water + * mode data publish interval. + * @details \b Inputs: genPermeateDataPublishInterval + * @details \b Outputs: none + * @return the interval at generate permeate mode data being published. + *************************************************************************/ +static U32 getGenPermeateDataPublishInterval( void ) +{ + U32 result = getU32OverrideValue( &genPermeateDataPublishInterval ); + + return result; +} + +/*********************************************************************//** + * @brief + * The publishGenPModeData function broadcasts the generate water + * mode data at defined interval. + * @details \b Inputs: genPermeateDataPublicationTimerCounter + * @details \b Outputs: FP generate permeate data broadcast message sent + * @details \b Message \Sent: MSG_ID_FP_GEN_WATER_MODE_DATA to publish the + * generate water mode data. + * @return none + *************************************************************************/ +static void publishGenPModeData( void ) +{ + if ( ++genPermeateDataPublicationTimerCounter >= getGenPermeateDataPublishInterval() ) + { + GEN_PERMEATE_MODE_DATA_T data; + + data.genPermeateExecState = (U32)getCurrentGenPermeateState(); + data.setFlowRate = (F32)getDDPermeateFlowRate(); + + broadcastData( MSG_ID_FP_GEN_WATER_MODE_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( GEN_PERMEATE_MODE_DATA_T ) ); + + genPermeateDataPublicationTimerCounter = 0; + } +} + +/*********************************************************************//** + * @brief + * The requestGenWaterStart function handles an DD request to start (go to gen permeate mode). + * @details \b Inputs: preGenWState + * @details \b Outputs: pendingStartGenRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestGenWaterStart( void ) +{ + BOOL result = FALSE; + + if ( FP_PRE_GENP_VERIFY_WATER == getCurrentPreGenPState() ) + { + result = TRUE; + pendingStartGenRequest = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The requestGenWaterStop function handles an DD request to stop (go to standby mode). + * @details \b Inputs: none + * @details \b Outputs: pendingStartGenRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestGenWaterStop( void ) +{ + BOOL result = TRUE; + pendingStartGenRequest = FALSE; + requestNewOperationMode( FP_MODE_STAN ); + + return result; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testGenPermeateDataPublishIntervalOverride function overrides the + * DD generate water mode data publish interval. + * @details \b Inputs: genPermeateDataPublishInterval + * @details \b Outputs: genPermeateDataPublishInterval + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP generate permeate data publish interval to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testGenPermeateDataPublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &genPermeateDataPublishInterval, TASK_GENERAL_INTERVAL ); + + return result; +} + +/**@}*/ Index: firmware/App/Modes/ModeGenPermeate.h =================================================================== diff -u --- firmware/App/Modes/ModeGenPermeate.h (revision 0) +++ firmware/App/Modes/ModeGenPermeate.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,56 @@ +/************************************************************************** +* +* Copyright (c) 2024-2025 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 ModeGenPermeate.h +* +* @author (last) Michael Garthwaite +* @date (last) 03-Mar-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 03-Mar-2025 +* +***************************************************************************/ + +#ifndef __MODE_GEN_PERM_H__ +#define __MODE_GEN_PERM_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + +/** + * @defgroup FPGenPermeateMode FPGenPermeateMode + * @brief Generate Permeate unit. Manages water generation functions via a state machine. + * + * @addtogroup FPGenPermeateMode + * @{ + */ + +// ********** public definitions ********** + +/// Generate Permeate mode data structure +typedef struct +{ + U32 genPermeateExecState; ///< Generate Permeate execution state + F32 setFlowRate; ///< Permeate flow rate requested by the DD. +} GEN_PERMEATE_MODE_DATA_T; + +// ********** public function prototypes ********** + +void initGenPermeateMode( void ); // Initialize this gen permeate mode unit +U32 transitionToGenPermeateMode( void ); // Transition to gen permeate mode +U32 execGenPermeateMode( void ); // Execute the gen permeate mode state machine (call from OperationModes) +BOOL requestGenWaterStart( void ); +BOOL requestGenWaterStop( void ); + +FP_GENP_MODE_STATE_T getCurrentGenPermeateState( void ); // Get the current state of the gen water mode + +BOOL testGenPermeateDataPublishIntervalOverride( MESSAGE_T *message ); // override broadcast interval for gen permeate + +/**@}*/ + + +#endif Index: firmware/App/Modes/ModeGenPermeateDefeatured.c =================================================================== diff -u --- firmware/App/Modes/ModeGenPermeateDefeatured.c (revision 0) +++ firmware/App/Modes/ModeGenPermeateDefeatured.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,28 @@ + +#include "ModeGenPermeateDefeatured.h" + +/** + * @addtogroup FPGenPermeateDefeatured + * @{ + */ + +// ********** private data ********** + + +void initGenPermeateDefeaturedMode( void ) +{ + +} + +U32 transitionToGenPermeateDefeaturedMode( void ) +{ + return 0; +} + +U32 execGenPermeateDefeaturedMode( void ) +{ + return 0; +} + +/**@}*/ + Index: firmware/App/Modes/ModeGenPermeateDefeatured.h =================================================================== diff -u --- firmware/App/Modes/ModeGenPermeateDefeatured.h (revision 0) +++ firmware/App/Modes/ModeGenPermeateDefeatured.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,11 @@ + + +#ifndef __MODE_GENP_DEF_H__ +#define __MODE_GENP_DEF_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + + + +#endif Index: firmware/App/Modes/ModeInitPOST.c =================================================================== diff -u -rbf3ba65cafc8cbfb34e03d9fb2fc248069a8addb -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision bf3ba65cafc8cbfb34e03d9fb2fc248069a8addb) +++ firmware/App/Modes/ModeInitPOST.c (.../ModeInitPOST.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -22,6 +22,6 @@ U32 execInitAndPOSTMode( void ) { - requestNewOperationMode( RO_MODE_STAN ); + requestNewOperationMode( FP_MODE_STAN ); return 0; } Index: firmware/App/Modes/ModeInitPOST.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Modes/ModeInitPOST.h (.../ModeInitPOST.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -3,14 +3,14 @@ #define __MODE_INIT_POST_H__ #include "FPCommon.h" -#include "RODefs.h" +#include "FPDefs.h" /** - * @defgroup ROInitAndPOSTMode ROInitAndPOSTMode + * @defgroup FPInitAndPOSTMode FPInitAndPOSTMode * @brief Initialization and POST mode unit. Manages initialization and POST * mode functions via a state machine. * - * @addtogroup ROInitAndPOSTMode + * @addtogroup FPInitAndPOSTMode * @{ */ Index: firmware/App/Modes/ModePreGenPermeate.c =================================================================== diff -u --- firmware/App/Modes/ModePreGenPermeate.c (revision 0) +++ firmware/App/Modes/ModePreGenPermeate.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,422 @@ +/************************************************************************** +* +* Copyright (c) 2020-2025 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 ModePreGenPermeate.c +* +* @author (last) Michael Garthwaite +* @date (last) 28-Feb-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 28-Feb-2025 +* +***************************************************************************/ + +#include "DDInterface.h" +#include "FlushFilter.h" +#include "FlushPermeate.h" +#include "MessageSupport.h" +#include "Messaging.h" +#include "ModeGenPermeate.h" +#include "ModePreGenPermeate.h" +#include "ModeStandby.h" +#include "OperationModes.h" +#include "TaskGeneral.h" +#include "Timers.h" + +/** + * @addtogroup FPPreGenPermeateMode + * @{ + */ + +// ********** private definitions ********** + +#define PRE_GENP_DATA_PUBLISH_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) ///< Interval (ms/task time) at which the pre gen Permeate mode data published. + +// ********** private data ********** + +static FP_PRE_GENP_MODE_STATE_T preGenPState; ///< Currently active pre generate Permeate state. +static U32 preGenPDataPublicationTimerCounter; ///< Used to schedule pre generate Permeate data publication to CAN bus. +static OVERRIDE_U32_T preGenPDataPublishInterval; ///< Pre Generate Permeate mode data publish interval. +static U32 pendingStartPreGenRequest; ///< Flag indicating DD has requested FP start the generate permeate. + +// ********** private function prototypes ********** + +static void publishPreGenPModeData( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPInletPressureCheckState( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPFilterFlushState( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPPermeateFlushState( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPConcentrateFlushState( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPVerifyWaterState( void ); +static FP_PRE_GENP_MODE_STATE_T handlePreGenPPausedState( void ); +static void setModePreGenPTransition( FP_PRE_GENP_MODE_STATE_T state ); + +/*********************************************************************//** + * @brief + * The initPreGenPMode function initializes the pre generate Permeate mode unit. + * @details \b Inputs: none + * @details \b Outputs: pre gen Permeate mode unit initialized + * @return none + *************************************************************************/ +void initPreGenPMode( void ) +{ + preGenPState = FP_PRE_GENP_PAUSED; + preGenPDataPublishInterval.data = PRE_GENP_DATA_PUBLISH_INTERVAL; + preGenPDataPublishInterval.ovData = PRE_GENP_DATA_PUBLISH_INTERVAL; + preGenPDataPublishInterval.ovInitData = 0; + preGenPDataPublishInterval.override = OVERRIDE_RESET; + preGenPDataPublicationTimerCounter = 0; + pendingStartPreGenRequest = FALSE; +} + +/*********************************************************************//** + * @brief + * The transitionToPreGenPMode function prepares for transition to pre gen + * Permeate mode. + * @details \b Inputs: none + * @details \b Outputs: none + * @return initial state + *************************************************************************/ +U32 transitionToPreGenPMode( void ) +{ + initPreGenPMode(); + setCurrentSubState( preGenPState ); + + return preGenPState; +} + +/*********************************************************************//** + * @brief + * The execPreGenPMode function executes the pre gen Permeate mode state machine. + * @details \b Inputs: preGenWState + * @details \b Outputs: Pre Gen Permeate mode state machine executed + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT when wrong pre gen Permeate state invoked. + * @return current state. + *************************************************************************/ +U32 execPreGenPMode( void ) +{ + // execute current pre gen Permeate state + switch ( preGenPState ) + { + case FP_PRE_GENP_INLET_PRESSURE_CHECK: + preGenPState = handlePreGenPInletPressureCheckState(); + break; + + case FP_PRE_GENP_FILTER_FLUSH: + preGenPState = handlePreGenPFilterFlushState(); + break; + + case FP_PRE_GENP_PERMEATE_FLUSH: + preGenPState = handlePreGenPConcentrateFlushState(); + break; + + case FP_PRE_GENP_CONCENTRATE_FLUSH: + preGenPState = handlePreGenPPermeateFlushState(); + break; + + case FP_PRE_GENP_VERIFY_WATER: + preGenPState = handlePreGenPVerifyWaterState(); + break; + + case FP_PRE_GENP_PAUSED: + preGenPState = handlePreGenPPausedState(); + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PGEN_STATE, preGenPState ) + break; + } + //Publish pre Gen Permeate mode data + publishPreGenPModeData(); + + return preGenPState; +} + +/*********************************************************************//** + * @brief + * The setModePreGenPTransition function sets the actuators and variables + * for the state transition in pre generate Permeate mode. + * @details Inputs: none + * @details Outputs: Actuate valves, pumps as desired. + * @param state pre gen Permeate state enum + * @return none + *************************************************************************/ +static void setModePreGenPTransition( FP_PRE_GENP_MODE_STATE_T state ) +{ + // Execute on running state + switch( state ) + { + case FP_PRE_GENP_INLET_PRESSURE_CHECK: + break; + + case FP_PRE_GENP_FILTER_FLUSH: + // Actuator transitions happen within Filter Flush exec + break; + + case FP_PRE_GENP_PERMEATE_FLUSH: + // Actuator transitions happen within Permeate Flush exec + break; + + case FP_PRE_GENP_CONCENTRATE_FLUSH: + // Actuator transitions happen within Concentrate Flush exec + break; + + case FP_PRE_GENP_VERIFY_WATER: + // Actuator transitions happen within Verify Water exec + break; + + case FP_PRE_GENP_PAUSED: + break; + + default: + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_PGEN_STATE, state ) + break; + } +} + +/*********************************************************************//** + * @brief + * The handlePreGenPInletPressureCheckState handles the inlet pressure check state of pre gen Permeate. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen Permeate mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPInletPressureCheckState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_INLET_PRESSURE_CHECK; + + if ( FALSE == isBoostPumpInstalled() ) + { + signalStartFilterFlush(); + } + else + { + // TODO - boost pump check + } + return state; +} + +/*********************************************************************//** + * @brief + * The handlePreGenPFilterFlushState handles the filter flush state of pre gen Permeate. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen Permeate mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPFilterFlushState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_FILTER_FLUSH; + + execFilterFlush(); + + if( TRUE == isFilterFlushComplete() ) + { + state = FP_PRE_GENP_PERMEATE_FLUSH; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handlePreGenPPermeateFlushState handles the permeate flush + * state of pre gen permeate. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen permeate mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPPermeateFlushState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_PERMEATE_FLUSH; + + execPermeateFlush(); + + if( TRUE == isPermeateFlushComplete() ) + { + state = FP_PRE_GENP_CONCENTRATE_FLUSH; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handlePreGenPConcentrateFlushState handles the concentrate flush + * state of pre gen water. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen water mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPConcentrateFlushState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_CONCENTRATE_FLUSH; + + execFilterFlush(); + + if( TRUE == isFilterFlushComplete() ) + { + state = FP_PRE_GENP_VERIFY_WATER; + } + + return state; +} + +/*********************************************************************//** + * @brief + * The handlePreGenPVerifyWaterState handles the verify water state of + * pre gen water. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen water mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPVerifyWaterState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_VERIFY_WATER; + + return state; +} + +/*********************************************************************//** + * @brief + * The handlePreGenPPausedState handles the paused state of + * pre gen water. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the next state of pre gen water mode + *************************************************************************/ +static FP_PRE_GENP_MODE_STATE_T handlePreGenPPausedState( void ) +{ + FP_PRE_GENP_MODE_STATE_T state = FP_PRE_GENP_PAUSED; + + return state; +} + +/** + * *******************************************************************//** + * @brief + * The getCurrentPreGenWState function returns the current state of the + * pre gen water mode. + * @details \b Inputs: preGenWState + * @details \b Outputs: none + * @return the current state of pre gen water mode + *************************************************************************/ +FP_PRE_GENP_MODE_STATE_T getCurrentPreGenPState( void ) +{ + return preGenPState; +} + +/*********************************************************************//** + * @brief + * The getPreGenRequest function returns the current state of the + * pre gen water mode. + * @details \b Inputs: pendingStartPreGenRequest + * @details \b Outputs: none + * @return the current state of pre gen request + *************************************************************************/ +BOOL getPreGenRequest( void ) +{ + return pendingStartPreGenRequest; +} + +/*********************************************************************//** + * @brief + * The getPreGenWDataPublishInterval function gets the pre generate water + * mode data publish interval. + * @details \b Inputs: genWaterDataPublishInterval + * @details \b Outputs: none + * @return the interval at generate water mode data being published. + *************************************************************************/ +static U32 getPreGenPDataPublishInterval( void ) +{ + U32 result = getU32OverrideValue( &preGenPDataPublishInterval ); + + return result; +} + +/*********************************************************************//** + * @brief + * The publishPreGenWModeData function broadcasts the pre generate water + * mode data at defined interval. + * @details \b Inputs: genDialysateDataPublicationTimerCounter + * @details \b Outputs: preGenWState, preGenWDataPublicationTimerCounter + * @details \b Message \b Sent: MSG_ID_FP_GEN_WATER_MODE_DATA to publish the + * generate water mode data. + * @return none + *************************************************************************/ +static void publishPreGenPModeData( void ) +{ + if ( ++preGenPDataPublicationTimerCounter >= getPreGenPDataPublishInterval() ) + { + PRE_GENP_MODE_DATA_T data; + + data.preGenPExecState = (U32)getCurrentPreGenPState(); + + broadcastData( MSG_ID_FP_PRE_GEN_WATER_MODE_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( PRE_GENP_MODE_DATA_T ) ); + + preGenPDataPublicationTimerCounter = 0; + } +} + +/*********************************************************************//** + * @brief + * The requestPreGenStart function handles an DD request to start (go to pre gen permeate mode). + * @details \b Inputs: standbyState + * @details \b Outputs: pendingStartRORequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestPreGenStart( void ) +{ + BOOL result = FALSE; + + if ( ( FP_MODE_STAN == getCurrentOperationMode() ) && ( FP_STANDBY_MODE_STATE_IDLE == getCurrentStandbyState() ) ) + { + result = TRUE; + pendingStartPreGenRequest = TRUE; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The requestPreGenStop function handles an DD request to stop (go to standby mode). + * @details \b Inputs: none + * @details \b Outputs: pendingStartPreGenRequest + * @return TRUE if request accepted, FALSE if not. + *************************************************************************/ +BOOL requestPreGenStop( void ) +{ + BOOL result = TRUE; + pendingStartPreGenRequest = FALSE; + requestNewOperationMode( FP_MODE_STAN ); + + return result; +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/*********************************************************************//** + * @brief + * The testPreGenDataPublishIntervalOverride function overrides the + * DD generate water mode data publish interval. + * @details \b Inputs: preGenPDataPublishInterval + * @details \b Outputs: preGenPDataPublishInterval + * @param Override message from Dialin which includes the interval + * (in ms) to override the FP generate water data publish interval to. + * @return TRUE if override successful, FALSE if not + *************************************************************************/ +BOOL testPreGenDataPublishIntervalOverride( MESSAGE_T *message ) +{ + BOOL result = u32BroadcastIntervalOverride( message, &preGenPDataPublishInterval, TASK_GENERAL_INTERVAL ); + + return result; +} + +/**@}*/ Index: firmware/App/Modes/ModePreGenPermeate.h =================================================================== diff -u --- firmware/App/Modes/ModePreGenPermeate.h (revision 0) +++ firmware/App/Modes/ModePreGenPermeate.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,54 @@ +/************************************************************************** +* +* Copyright (c) 2024-2025 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 ModePreGenPermeate.h +* +* @author (last) Michael Garthwaite +* @date (last) 03-Mar-2025 +* +* @author (original) Michael Garthwaite +* @date (original) 03-Mar-2025 +* +***************************************************************************/ + +#ifndef __MODE_PRE_GENP_H__ +#define __MODE_PRE_GENP_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + +/** + * @defgroup FPPreGenPermeateMode FPPreGenPermeateMode + * @brief Pre Generate Permeate unit. Manages pre checks for permeate generation functions via a state machine. + * + * @addtogroup FPPreGenPermeateMode + * @{ + */ + +// ********** public definitions ********** + +/// Pre Generate water mode data structure +typedef struct +{ + U32 preGenPExecState; ///< Pre Generate Permeate execution state +} PRE_GENP_MODE_DATA_T; + +// ********** public function prototypes ********** + +void initPreGenPMode( void ); // Initialize this pre gen Permeate mode unit +U32 transitionToPreGenPMode( void ); // Transition to pre gen Permeate mode +U32 execPreGenPMode( void ); // Execute the pre gen Permeate mode state machine (call from OperationModes) +BOOL requestPreGenStart( void ); +BOOL requestPreGenStop( void ); +BOOL getPreGenRequest( void ); +FP_PRE_GENP_MODE_STATE_T getCurrentPreGenPState( void ); // Get the current state of the pre gen Permeate mode + +BOOL testPreGenDataPublishIntervalOverride( MESSAGE_T *message ); + +/**@}*/ + +#endif Index: firmware/App/Modes/ModePreGenPermeateDefeatured.c =================================================================== diff -u --- firmware/App/Modes/ModePreGenPermeateDefeatured.c (revision 0) +++ firmware/App/Modes/ModePreGenPermeateDefeatured.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,28 @@ + +#include "ModePreGenPermeateDefeatured.h" + +/** + * @addtogroup FPreGenPermeateDefeatured + * @{ + */ + +// ********** private data ********** + + +void initPreGenPDefMode( void ) +{ + +} + +U32 transitionToPreGenPDefMode( void ) +{ + return 0; +} + +U32 execPreGenPDefMode( void ) +{ + return 0; +} + +/**@}*/ + Index: firmware/App/Modes/ModePreGenPermeateDefeatured.h =================================================================== diff -u --- firmware/App/Modes/ModePreGenPermeateDefeatured.h (revision 0) +++ firmware/App/Modes/ModePreGenPermeateDefeatured.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,11 @@ + + +#ifndef __MODE_PRE_GENP_DEF_H__ +#define __MODE_PRE_GENP_DEF_H__ + +#include "FPCommon.h" +#include "FPDefs.h" + + + +#endif Index: firmware/App/Modes/ModeStandby.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Modes/ModeStandby.c (.../ModeStandby.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,27 +15,29 @@ * ***************************************************************************/ +#include "ModePreGenPermeateDefeatured.h" +#include "ModePreGenPermeate.h" #include "ModeStandby.h" -#include "ModeWaterPreGen.h" #include "OperationModes.h" #include "PersistentAlarm.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "TaskGeneral.h" /** - * @addtogroup ROStandbyMode + * @addtogroup FPStandbyMode * @{ */ // ********** private definitions ********** // ********** private data ********** -static RO_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. +static FP_STANDBY_MODE_STATE_T standbyState; ///< Currently active standby state. + // ********** private function prototypes ********** -static RO_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); +static FP_STANDBY_MODE_STATE_T handleStandbyIdleState( void ); /*********************************************************************//** * @brief @@ -46,7 +48,7 @@ *************************************************************************/ void initStandbyMode( void ) { - standbyState = RO_STANDBY_MODE_STATE_IDLE; + standbyState = FP_STANDBY_MODE_STATE_IDLE; } /*********************************************************************//** @@ -69,21 +71,21 @@ * The execStandbyMode function executes the standby mode state machine. * @details \b Inputs: none * @details \b Outputs: Standby mode state machine executed - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if standbyState is invalid. + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if standbyState is invalid. * @return current state *************************************************************************/ U32 execStandbyMode( void ) { // execute current Standby state switch ( standbyState ) { - case RO_STANDBY_MODE_STATE_IDLE: + case FP_STANDBY_MODE_STATE_IDLE: standbyState = handleStandbyIdleState(); break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_MODE_STANDBY_INVALID_STATE, standbyState ) - standbyState = RO_STANDBY_MODE_STATE_IDLE; + standbyState = FP_STANDBY_MODE_STATE_IDLE; break; } @@ -99,13 +101,21 @@ * @details \b Message \Sent: * @return the next state *************************************************************************/ -static RO_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) +static FP_STANDBY_MODE_STATE_T handleStandbyIdleState( void ) { - RO_STANDBY_MODE_STATE_T state = RO_STANDBY_MODE_STATE_IDLE; + FP_STANDBY_MODE_STATE_T state = FP_STANDBY_MODE_STATE_IDLE; if ( TRUE == getPreGenRequest() ) { - requestNewOperationMode( RO_MODE_PGEN ); + if ( FALSE == isDefeatured() ) + { + requestNewOperationMode( FP_MODE_PGEN ); + } + else + { + requestNewOperationMode( FP_MODE_DPGW ); + } + } return state; @@ -118,12 +128,11 @@ * @details \b Outputs: none * @return the current state of standby mode. *************************************************************************/ -RO_STANDBY_MODE_STATE_T getCurrentStandbyState( void ) +FP_STANDBY_MODE_STATE_T getCurrentStandbyState( void ) { return standbyState; } - /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ Index: firmware/App/Modes/ModeStandby.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Modes/ModeStandby.h (.../ModeStandby.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -18,14 +18,14 @@ #define __MODE_STANDBY_H__ #include "FPCommon.h" -#include "RODefs.h" +#include "FPDefs.h" /** - * @defgroup ROStandbyMode ROStandbyMode + * @defgroup FPStandbyMode FPStandbyMode * @brief Standby mode unit. Manages the Standby mode functions via a state * machine. * - * @addtogroup ROStandbyMode + * @addtogroup FPStandbyMode * @{ */ @@ -37,9 +37,9 @@ U32 transitionToStandbyMode( void ); // Prepares for transition to standby mode U32 execStandbyMode( void ); // Execute the standby mode state machine (call from OperationModes) -RO_STANDBY_MODE_STATE_T getCurrentStandbyState( void ); // get the current state of the standby mode. +FP_STANDBY_MODE_STATE_T getCurrentStandbyState( void ); // get the current state of the standby mode. -BOOL testROstartGenPermeateOverride( MESSAGE_T *message ); // Overide start gen permeate mode +BOOL testFPstartGenPermeateOverride( MESSAGE_T *message ); // Overide start gen permeate mode /**@}*/ Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/ModeWaterGen.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/ModeWaterGen.h'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/ModeWaterPreGen.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Modes/ModeWaterPreGen.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Modes/OperationModes.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Modes/OperationModes.c (.../OperationModes.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,52 +15,59 @@ * ***************************************************************************/ + #include "Messaging.h" #include "ModeInitPOST.h" #include "ModeFault.h" +#include "ModeGenPermeateDefeatured.h" +#include "ModePreGenPermeateDefeatured.h" +#include "ModeGenPermeate.h" +#include "ModePreGenPermeate.h" #include "ModeStandby.h" -#include "ModeWaterGen.h" -#include "ModeWaterPreGen.h" #include "OperationModes.h" #include "TaskGeneral.h" /** - * @addtogroup ROOperationModes + * @addtogroup FPOperationModes * @{ */ // ********** private definitions ********** -#define BROADCAST_TD_OP_MODE_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< RO operation mode broadcast interval (in task interval/sec). +#define BROADCAST_TD_OP_MODE_INTERVAL ( 250 / TASK_GENERAL_INTERVAL ) ///< FP operation mode broadcast interval (in task interval/sec). #define DATA_PUBLISH_COUNTER_START_COUNT 11 ///< Data publish counter start count. // ********** private data ********** -static volatile BOOL modeRequest[ NUM_OF_RO_MODES - 1 ]; ///< Pending operation mode change requests. -static RO_OP_MODE_T lastMode; ///< Last operation mode prior to current mode. -static RO_OP_MODE_T currentMode; ///< Current operation mode. +static volatile BOOL modeRequest[ NUM_OF_FP_MODES - 1 ]; ///< Pending operation mode change requests. +static FP_OP_MODE_T lastMode; ///< Last operation mode prior to current mode. +static FP_OP_MODE_T currentMode; ///< Current operation mode. static U32 currentSubMode; ///< The currently active state of the active mode. static U32 broadcastModeIntervalCtr; ///< Interval counter used to determine when to broadcast operation mode. Initialize to 11 to stagger broadcast. static U32 currentSubState; ///< current sub state. static U32 current4thLevelState; ///< current 4th level state. +static BOOL isDeviceDefeatured; ///< bool to determine defeatured status +static BOOL isBoostInstalled; ///< bool to determine boost pump status /// Interval (in task intervals) at which to publish operation mode data to CAN bus. static OVERRIDE_U32_T opModePublishInterval = { BROADCAST_TD_OP_MODE_INTERVAL, BROADCAST_TD_OP_MODE_INTERVAL, BROADCAST_TD_OP_MODE_INTERVAL, 0 }; /// This matrix determines legal transitions from one mode to another -static const RO_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_RO_MODES - 1 ][ NUM_OF_RO_MODES - 1 ] = { -// From to-> FAULT SERVICE INIT STANBY PGEN GENW -/* FAUL */{ RO_MODE_FAUL, RO_MODE_SERV, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_NLEG }, -/* SERV */{ RO_MODE_FAUL, RO_MODE_SERV, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_NLEG }, -/* INIT */{ RO_MODE_FAUL, RO_MODE_NLEG, RO_MODE_INIT, RO_MODE_STAN, RO_MODE_NLEG, RO_MODE_NLEG }, -/* STAN */{ RO_MODE_FAUL, RO_MODE_SERV, RO_MODE_NLEG, RO_MODE_STAN, RO_MODE_NLEG, RO_MODE_GENW }, -/* PGEN */{ RO_MODE_FAUL, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_STAN, RO_MODE_PGEN, RO_MODE_GENW }, -/* GENW */{ RO_MODE_FAUL, RO_MODE_NLEG, RO_MODE_NLEG, RO_MODE_STAN, RO_MODE_NLEG, RO_MODE_GENW } }; +static const FP_OP_MODE_T MODE_TRANSITION_TABLE[ NUM_OF_FP_MODES - 1 ][ NUM_OF_FP_MODES - 1 ] = { +// From to-> FAULT SERVICE INIT STANBY PGEN GENW DPGW DEGW +/* FAUL */{ FP_MODE_FAUL, FP_MODE_SERV, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG }, +/* SERV */{ FP_MODE_FAUL, FP_MODE_SERV, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG }, +/* INIT */{ FP_MODE_FAUL, FP_MODE_NLEG, FP_MODE_INIT, FP_MODE_STAN, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG }, +/* STAN */{ FP_MODE_FAUL, FP_MODE_SERV, FP_MODE_NLEG, FP_MODE_STAN, FP_MODE_NLEG, FP_MODE_GENP, FP_MODE_NLEG, FP_MODE_DEGW }, +/* PGEN */{ FP_MODE_FAUL, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_STAN, FP_MODE_PGEN, FP_MODE_GENP, FP_MODE_NLEG, FP_MODE_NLEG }, +/* GENW */{ FP_MODE_FAUL, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_STAN, FP_MODE_NLEG, FP_MODE_GENP, FP_MODE_NLEG, FP_MODE_NLEG }, +/* DPGW */{ FP_MODE_FAUL, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_STAN, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_DPGW, FP_MODE_DEGW }, +/* DEGW */{ FP_MODE_FAUL, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_STAN, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_NLEG, FP_MODE_DEGW } }; // ********** private function prototypes ********** -static RO_OP_MODE_T arbitrateModeRequest( void ); -static void transitionToNewOperationMode( RO_OP_MODE_T newMode ); +static FP_OP_MODE_T arbitrateModeRequest( void ); +static void transitionToNewOperationMode( FP_OP_MODE_T newMode ); static void broadcastOperationMode( void ); /*********************************************************************//** @@ -75,41 +82,43 @@ U32 i; // Initialize mode requests to none pending - for ( i = 0; i < ( NUM_OF_RO_MODES - 1 ); i++ ) + for ( i = 0; i < ( NUM_OF_FP_MODES - 1 ); i++ ) { modeRequest[ i ] = FALSE; } // Start in init mode - lastMode = RO_MODE_INIT; - currentMode = RO_MODE_INIT; + lastMode = FP_MODE_INIT; + currentMode = FP_MODE_INIT; currentSubMode = 0; currentSubState = NO_SUB_STATE; current4thLevelState = NO_SUB_STATE; broadcastModeIntervalCtr = DATA_PUBLISH_COUNTER_START_COUNT; + isDeviceDefeatured = FALSE; + isBoostInstalled = FALSE; - transitionToNewOperationMode( RO_MODE_INIT ); + transitionToNewOperationMode( FP_MODE_INIT ); // Call initializers for the individual modes initFaultMode(); // initServiceMode(); initInitAndPOSTMode(); initStandbyMode(); - initPreGenWMode(); - initGenWaterMode(); + initPreGenPMode(); + initGenPermeateMode(); } /*********************************************************************//** * @brief * The execOperationModes function executes the Operation Modes state machine. - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if current mode is invalid. + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if current mode is invalid. * @details \b Inputs: none * @details \b Outputs: currentMode is set by state machine. * @return none *************************************************************************/ void execOperationModes( void ) { - RO_OP_MODE_T newMode; + FP_OP_MODE_T newMode; U32 priorSubMode = currentSubMode; U32 priorSubState = currentSubState; U32 prior4thLevelState = current4thLevelState; @@ -119,7 +128,7 @@ newMode = MODE_TRANSITION_TABLE[ currentMode ][ newMode ]; // Is requested new mode valid and legal at this time? - if ( ( newMode >= RO_MODE_NLEG ) && ( isTestingActivated() != TRUE ) ) + if ( ( newMode >= FP_MODE_NLEG ) && ( isTestingActivated() != TRUE ) ) { SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_ILLEGAL_MODE_TRANSITION_REQUESTED, newMode ) newMode = currentMode; @@ -138,33 +147,33 @@ // Mode specific processing to be done continuously switch ( currentMode ) { - case RO_MODE_FAUL: + case FP_MODE_FAUL: currentSubMode = execFaultMode(); break; - case RO_MODE_SERV: + case FP_MODE_SERV: // currentSubMode = execServiceMode(); break; - case RO_MODE_INIT: + case FP_MODE_INIT: currentSubMode = execInitAndPOSTMode(); break; - case RO_MODE_STAN: + case FP_MODE_STAN: currentSubMode = execStandbyMode(); break; - case RO_MODE_PGEN: - currentSubMode = execPreGenWMode(); + case FP_MODE_PGEN: + currentSubMode = execPreGenPMode(); break; - case RO_MODE_GENW: - currentSubMode = execGenWaterMode(); + case FP_MODE_GENP: + currentSubMode = execGenPermeateMode(); break; default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_STATE, currentMode ) - currentMode = RO_MODE_FAUL; + currentMode = FP_MODE_FAUL; currentSubMode = 0; break; } // End switch @@ -175,7 +184,7 @@ #endif { // sendOperationStatusEvent(); - SEND_EVENT_WITH_2_U32_DATA( RO_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) + SEND_EVENT_WITH_2_U32_DATA( FP_EVENT_SUB_MODE_CHANGE, priorSubMode, currentSubMode ) } // Broadcast current operation mode on interval @@ -187,15 +196,15 @@ * The requestNewOperationMode function requests transition to a new * operation mode. The request will be arbitrated when the state machine * is next executed. - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if given new mode is invalid. + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if given new mode is invalid. * @details \b Inputs: none * @details \b Outputs: modeRequest[] * @return none *************************************************************************/ -void requestNewOperationMode( RO_OP_MODE_T newMode ) +void requestNewOperationMode( FP_OP_MODE_T newMode ) { // Validate requested mode - if ( newMode < RO_MODE_NLEG ) + if ( newMode < FP_MODE_NLEG ) { // Make request modeRequest[ newMode ] = TRUE; @@ -213,7 +222,7 @@ * @details \b Outputs: none * @return the current operation mode *************************************************************************/ -RO_OP_MODE_T getCurrentOperationMode( void ) +FP_OP_MODE_T getCurrentOperationMode( void ) { return currentMode; } @@ -225,7 +234,7 @@ * @details \b Outputs: none * @return the previous operation mode *************************************************************************/ -RO_OP_MODE_T getPreviousOperationMode( void ) +FP_OP_MODE_T getPreviousOperationMode( void ) { return lastMode; } @@ -252,26 +261,26 @@ * @details \b Outputs: modeRequest[] is reset * @return the next operation mode (current mode if no requests pending) *************************************************************************/ -static RO_OP_MODE_T arbitrateModeRequest( void ) +static FP_OP_MODE_T arbitrateModeRequest( void ) { - RO_OP_MODE_T reqMode = currentMode; + FP_OP_MODE_T reqMode = currentMode; U32 i; // Block additional requests until after mode arbitration _disable_IRQ(); // Select highest priority mode request -or- current mode if no requests pending - for ( i = 0; i < RO_MODE_NLEG; i++ ) + for ( i = 0; i < FP_MODE_NLEG; i++ ) { if ( modeRequest[ i ] != FALSE ) { - reqMode = (RO_OP_MODE_T)i; + reqMode = (FP_OP_MODE_T)i; break; } } // Clear all requests now that an arbitration winner is selected - for ( i = 0; i < RO_MODE_NLEG; i++ ) + for ( i = 0; i < FP_MODE_NLEG; i++ ) { modeRequest[ i ] = FALSE; } @@ -286,40 +295,49 @@ * @brief * The transitionToNewOperationMode function calls the transition to function * for a new operation mode that we are transitioning to. - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if given new mode is invalid. + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if given new mode is invalid. * @details \b Inputs: none * @details \b Outputs: transition function called for new mode * @return none *************************************************************************/ -static void transitionToNewOperationMode( RO_OP_MODE_T newMode ) +static void transitionToNewOperationMode( FP_OP_MODE_T newMode ) { // Setup for new operating mode switch ( newMode ) { - case RO_MODE_FAUL: + case FP_MODE_FAUL: currentSubMode = transitionToFaultMode(); break; - case RO_MODE_SERV: + case FP_MODE_SERV: // currentSubMode = transitionToServiceMode(); break; - case RO_MODE_INIT: + case FP_MODE_INIT: currentSubMode = transitionToInitAndPOSTMode(); break; - case RO_MODE_STAN: + case FP_MODE_STAN: currentSubMode = transitionToStandbyMode(); break; - case RO_MODE_PGEN: - currentSubMode = transitionToPreGenWMode(); + case FP_MODE_PGEN: + currentSubMode = transitionToPreGenPMode(); break; - case RO_MODE_GENW: - currentSubMode = transitionToGenWaterMode(); + case FP_MODE_GENP: + currentSubMode = transitionToGenPermeateMode(); break; + case FP_MODE_DPGW: + //currentSubMode = transitionToPreGenWMode(); + break; + + case FP_MODE_DEGW: + //currentSubMode = transitionToGenWaterMode(); + break; + + default: SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_OP_MODES_INVALID_MODE_TO_TRANSITION_TO, newMode ) break; @@ -331,7 +349,7 @@ * The broadcastOperationMode function sends the current operation mode at * the prescribed interval. * @details \b Inputs: broadcastModeIntervalCtr - * @details \b Outputs: RO operation mode broadcast message sent. + * @details \b Outputs: FP operation mode broadcast message sent. * @return none *************************************************************************/ static void broadcastOperationMode( void ) @@ -343,7 +361,7 @@ broadcastModeIntervalCtr = 0; data.opMode = (U32)currentMode; data.subMode = currentSubMode; - broadcastData( MSG_ID_FP_OP_MODE_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( OP_MODE_PAYLOAD_T ) ); + broadcastData( MSG_ID_FP_OP_MODE_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( OP_MODE_PAYLOAD_T ) ); } } @@ -373,7 +391,33 @@ current4thLevelState = state; } +/*********************************************************************//** + * @brief + * The getDefeatured function returns if the Leahi device is defeatured. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the current state of standby mode. + *************************************************************************/ +BOOL isDefeatured( void ) +{ + // TODO - pull status from NV mem. + return isDeviceDefeatured; +} +/*********************************************************************//** + * @brief + * The isBoostPumpInstalled function returns if the Leahi device + * has a boost pump installed. + * @details \b Inputs: none + * @details \b Outputs: none + * @return the current state of standby mode. + *************************************************************************/ +BOOL isBoostPumpInstalled( void ) +{ + // TODO - pull status from NV mem. + return isBoostInstalled; +} + /************************************************************************* * TEST SUPPORT FUNCTIONS *************************************************************************/ @@ -399,9 +443,9 @@ U32 newMode; memcpy( &newMode, message->payload, sizeof( U32 ) ); - if ( (RO_OP_MODE_T)newMode < NUM_OF_RO_MODES ) + if ( (FP_OP_MODE_T)newMode < NUM_OF_FP_MODES ) { - RO_OP_MODE_T reqMode = (RO_OP_MODE_T)newMode; + FP_OP_MODE_T reqMode = (FP_OP_MODE_T)newMode; requestNewOperationMode( reqMode ); result = TRUE; Index: firmware/App/Modes/OperationModes.h =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Modes/OperationModes.h (.../OperationModes.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -19,13 +19,13 @@ #define __OP_MODES_H__ #include "FPCommon.h" -#include "RODefs.h" +#include "FPDefs.h" /** - * @defgroup ROOperationModes ROOperationModes + * @defgroup FPOperationModes FPOperationModes * @brief Operation Modes unit. * - * @addtogroup ROOperationModes + * @addtogroup FPOperationModes * @{ */ @@ -45,10 +45,12 @@ void initOperationModes( void ); // Initialize this unit void execOperationModes( void ); -void requestNewOperationMode( RO_OP_MODE_T newMode ); // Request a transition to a new operation mode -RO_OP_MODE_T getCurrentOperationMode( void ); // Get the current operation mode -RO_OP_MODE_T getPreviousOperationMode( void ); // Get the previous operation mode +void requestNewOperationMode( FP_OP_MODE_T newMode ); // Request a transition to a new operation mode +FP_OP_MODE_T getCurrentOperationMode( void ); // Get the current operation mode +FP_OP_MODE_T getPreviousOperationMode( void ); // Get the previous operation mode U32 getCurrentSubMode( void ); // Get the current sub-mode +BOOL isDefeatured( void ); // is the Leahi device is defeatured ( TBD pulled from NV mem ) +BOOL isBoostPumpInstalled( void ); // is this leahi device installed with a boost pump ( TBD pulled from NV mem ) void setCurrentSubState( U32 subState ); // Set the current substate. void setCurrent4thLevelState( U32 state ); // Set the current 4th level state. Index: firmware/App/Modes/PressureCheck.c =================================================================== diff -u --- firmware/App/Modes/PressureCheck.c (revision 0) +++ firmware/App/Modes/PressureCheck.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1 @@ \ No newline at end of file Index: firmware/App/Modes/PressureCheck.h =================================================================== diff -u --- firmware/App/Modes/PressureCheck.h (revision 0) +++ firmware/App/Modes/PressureCheck.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,15 @@ +/* + * PressureCheck.h + * + * Created on: Jul 1, 2025 + * Author: fw + */ + +#ifndef APP_MODES_PRESSURECHECK_H_ +#define APP_MODES_PRESSURECHECK_H_ + + + + + +#endif /* APP_MODES_PRESSURECHECK_H_ */ Index: firmware/App/Modes/VerifyWater.c =================================================================== diff -u --- firmware/App/Modes/VerifyWater.c (revision 0) +++ firmware/App/Modes/VerifyWater.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1 @@ \ No newline at end of file Index: firmware/App/Modes/VerifyWater.h =================================================================== diff -u --- firmware/App/Modes/VerifyWater.h (revision 0) +++ firmware/App/Modes/VerifyWater.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,15 @@ +/* + * VerifyWater.h + * + * Created on: Jul 1, 2025 + * Author: fw + */ + +#ifndef APP_MODES_VERIFYWATER_H_ +#define APP_MODES_VERIFYWATER_H_ + + + + + +#endif /* APP_MODES_VERIFYWATER_H_ */ Index: firmware/App/Monitors/Conductivity.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Monitors/Conductivity.c (.../Conductivity.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -19,6 +19,7 @@ #include // For memcpy #include "Conductivity.h" +#include "ConductivitySensor.h" #include "MessageSupport.h" #include "Messaging.h" #include "OperationModes.h" @@ -88,6 +89,20 @@ // publish conductivity sensors publishConductivitySensorsData(); } +/*********************************************************************//** + * @brief + * The getFilteredConductivity function gets the filtered current flow (in mL/min) + * for a given flow sensor. + * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if given sensor is invalid. + * @details \b Inputs: filteredcurrentFlowReadings[] + * @details \b Outputs: none + * @param sensor ID of flow sensor to get filtered flow reading for. + * @return The filtered current flow (in mL/min) of the given flow sensor. + *************************************************************************/ +F32 getFilteredConductivity( CONDUCTIVITY_SENSORS_T sensor ) +{ + return 0.0F; +} /*********************************************************************//** * @brief @@ -109,7 +124,7 @@ data.p18Conductivity = getConductivityValue( P18_COND ); conductivityPublishTimerCounter = 0; - broadcastData( MSG_ID_FP_CONDUCTIVITY_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( CONDUCTIVITY_DATA_T ) ); + broadcastData( MSG_ID_FP_CONDUCTIVITY_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( CONDUCTIVITY_DATA_T ) ); } } Index: firmware/App/Monitors/Conductivity.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Monitors/Conductivity.h (.../Conductivity.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -42,6 +42,7 @@ void initConductivity( void ); void execConductivity( void ); +F32 getFilteredConductivity( CONDUCTIVITY_SENSORS_T sensor ); BOOL testConductivitySensorDataPublishIntervalOverride( MESSAGE_T *message ); Index: firmware/App/Monitors/Flow.c =================================================================== diff -u -r863f8f88c73ee5dd285242f6e131a14862b4f5c4 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Flow.c (.../Flow.c) (revision 863f8f88c73ee5dd285242f6e131a14862b4f5c4) +++ firmware/App/Monitors/Flow.c (.../Flow.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" #include "Flow.h" #include "Messaging.h" #include "PersistentAlarm.h" @@ -179,7 +179,7 @@ * @brief * The getFilteredFlowSensorTemperature function gets the filtered current * flow sensor temperature (in deg C) for a given flow sensor. - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if given sensor is invalid. + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if given sensor is invalid. * @details \b Inputs: currentFlowTempReadings * @details \b Outputs: none * @param sensor ID of flow sensor to get temperature reading for. @@ -213,7 +213,7 @@ * of the flow sensors. * @details \b Inputs: flowsState * @details \b Outputs: flowsState - * @details \b Alarm: ALARM_ID_RO_SOFTWARE_FAULT if in invalid flow state + * @details \b Alarm: ALARM_ID_FP_SOFTWARE_FAULT if in invalid flow state * @return none *************************************************************************/ void execFlowMonitor( void ) @@ -355,10 +355,10 @@ /*********************************************************************//** * @brief - * The publishFlowsData function publishes RO flow data at a set interval. + * The publishFlowsData function publishes FP flow data at a set interval. * @details \b Inputs: flowsDataPublicationTimerCounter * @details \b Outputs: flowsDataPublicationTimerCounter - * @details \b Message \b Sent: MSG_ID_RO_FLOW_DATA to publish flow data. + * @details \b Message \b Sent: MSG_ID_FP_FLOW_DATA to publish flow data. * @return none *************************************************************************/ static void publishFlowsData( void ) @@ -373,7 +373,7 @@ data.p7Temp = getFilteredFlowSensorTemperature( P7_FLOW ); data.p16Temp = getFilteredFlowSensorTemperature( P16_FLOW ); - broadcastData( MSG_ID_FP_FLOW_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( FLOW_TEMP_DATA_T ) ); + broadcastData( MSG_ID_FP_FLOW_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( FLOW_TEMP_DATA_T ) ); flowsDataPublicationTimerCounter = 0; } } Index: firmware/App/Monitors/Level.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Level.c (.../Level.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Monitors/Level.c (.../Level.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include "FpgaRO.h" +#include "FpgaFP.h" #include "Level.h" #include "MessageSupport.h" #include "Messaging.h" @@ -168,7 +168,7 @@ data.p25Level = (U32)getLevelStatus(); levelsDataPublicationCounter = 0; - broadcastData( MSG_ID_FP_LEVEL_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( LEVEL_DATA_T ) ); + broadcastData( MSG_ID_FP_LEVEL_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( LEVEL_DATA_T ) ); } } Index: firmware/App/Monitors/Pressure.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Monitors/Pressure.c (.../Pressure.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,7 +15,7 @@ * ***************************************************************************/ -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" #include "Messaging.h" #include "Pressure.h" #include "PersistentAlarm.h" @@ -502,7 +502,7 @@ data.x4Temp = getFilteredPressureSensorTemperature( X4_PRES ); data.x4Temp = getFilteredPressureSensorTemperature( X5_PRES ); - broadcastData( MSG_ID_FP_PRESSURES_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( PRESSURE_TEMP_DATA_T ) ); + broadcastData( MSG_ID_FP_PRESSURES_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( PRESSURE_TEMP_DATA_T ) ); pressuresDataPublicationTimerCounter = 0; } } Index: firmware/App/Monitors/Temperature.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Monitors/Temperature.c (.../Temperature.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -215,7 +215,7 @@ data.p19Temp = getTemperatureValue( P19_TEMP ); data.boardTemp = 0.0F; // TODO - broadcastData( MSG_ID_FP_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_RO_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); + broadcastData( MSG_ID_FP_TEMPERATURE_DATA, COMM_BUFFER_OUT_CAN_FP_BROADCAST, (U08*)&data, sizeof( TEMPERATURE_SENSORS_DATA_T ) ); dataPublicationTimerCounter = 0; } } Index: firmware/App/Services/AlarmMgmtFP.c =================================================================== diff -u --- firmware/App/Services/AlarmMgmtFP.c (revision 0) +++ firmware/App/Services/AlarmMgmtFP.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,475 @@ +/************************************************************************** +* +* Copyright (c) 2024-2024 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 AlarmMgmtRO.c +* +* @author (last) Michael Garthwaite +* @date (last) 30-Jul-2024 +* +* @author (original) Michael Garthwaite +* @date (original) 30-Jul-2024 +* +***************************************************************************/ +#define __ALARM_MGMT_FP_C__ + +#include "AlarmMgmtFP.h" +#include "Messaging.h" +#include "OperationModes.h" +#include "PersistentAlarm.h" +#include "SafetyShutdown.h" +#include "SystemCommFP.h" +#include "TaskGeneral.h" +#include "Timers.h" + + +/** + * @addtogroup AlarmManagement + * @{ + */ + +// ********** private definitions ********** + +#define ALARM_INFO_PUB_INTERVAL ( MS_PER_SECOND / TASK_GENERAL_INTERVAL ) /// Interval (ms/task time) at which the alarm information is published on the CAN bus. +#define DATA_PUBLISH_COUNTER_START_COUNT 12 ///< Data publish counter start count. +#define SUPERVISOR_ALARM_KEY 0xD2C3B4A5 ///< 32-bit key required for clear all alarms request. + +const ALARM_DATA_T BLANK_ALARM_DATA = { ALARM_DATA_TYPE_NONE, 0 }; ///< A blank alarm data record for alarms that do not include alarm data when triggered. + +// ********** private data ********** + +static U32 alarmInfoPublicationTimerCounter; ///< Used to schedule alarm information publication to CAN bus. +static BOOL isAFaultAlarmActive; ///< Boolean flag to indicate whether a DD fault alarm is active. + +/// Interval (in task intervals) at which to publish alarm information to CAN bus. +static OVERRIDE_U32_T alarmInfoPublishInterval = { ALARM_INFO_PUB_INTERVAL, ALARM_INFO_PUB_INTERVAL, ALARM_INFO_PUB_INTERVAL, 0 }; + +// ********** private function prototypes ********** + +static void activateAlarmFP( ALARM_ID_T alarm ); +static void publishAlarmInfo( void ); +static BOOL isTransitionToFaultRequired( void ); + +/*********************************************************************//** + * @brief + * The initAlarmMgmtRO function initializes the AlarmMgmt unit. + * @details \b Inputs: none + * @details \b Outputs: unit variables initialized. + * @return none + *************************************************************************/ +void initAlarmMgmtFP( void ) +{ + alarmInfoPublicationTimerCounter = DATA_PUBLISH_COUNTER_START_COUNT; + isAFaultAlarmActive = FALSE; + + // Initialize common alarm mgmt unit + initAlarmMgmt(); +} + +/*********************************************************************//** + * @brief + * The execAlarmMgmt function executes periodic alarm management operations. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ +void execAlarmMgmt( void ) +{ + // Publish alarm information at interval + publishAlarmInfo(); +} + +/*********************************************************************//** + * @brief + * The activateAlarmDD function activates a given alarm. if the alarm is + * DD fault, transition fault operation mode immediately. + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[], isAFaultAlarmActive + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when invalid alarm asked to activate. + * @param alarm ID of alarm to activate + * @return none + *************************************************************************/ +static void activateAlarmFP( ALARM_ID_T alarm ) +{ + // verify given alarm + if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) + { + ALARM_T props = getAlarmProperties( alarm ); + + // no need to do anything if alarm is already active + if ( FALSE == isAlarmActive( alarm ) ) + { + // activate alarm + activateAlarm( alarm ); + + if ( TRUE == props.alarmIsDDFault ) + { + // There is a DD fault alarm. + isAFaultAlarmActive = TRUE; + + if ( TRUE == isTransitionToFaultRequired() ) + { + // If alarm is a DD fault and the alarm manager can transition to fault immediately, go to fault mode + requestNewOperationMode( FP_MODE_FAUL ); + } + } + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_ACTIVATE, alarm ) + } +} + +/*********************************************************************//** + * @brief + * The activateAlarmNoData function activates a given alarm. An alarm message + * is broadcast to the rest of the system.it doesn't contain any parameters + * associated to alarm. + * @details \b Inputs: none + * @details \b Outputs: alarm triggered message sent, alarm activated + * @param alarm ID of alarm to activate + * @return none + *************************************************************************/ +void activateAlarmNoData( ALARM_ID_T alarm ) +{ + activateAlarm2Data( alarm, BLANK_ALARM_DATA, BLANK_ALARM_DATA, FALSE ); +} + +/*********************************************************************//** + * @brief + * The activateAlarm1Data function activates a given alarm. An alarm message + * is broadcast to the rest of the system. This function will include given + * data in the broadcast message for logging. + * @details \b Inputs: none + * @details \b Outputs: alarm triggered message sent, alarm activated + * @param alarm ID of alarm to activate + * @param alarmData supporting data to include in alarm message + * @return none + *************************************************************************/ +void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ) +{ + activateAlarm2Data( alarm, alarmData, BLANK_ALARM_DATA, FALSE ); +} + +/*********************************************************************//** + * @brief + * The activateAlarm2Data function activates a given alarm. An alarm message + * is broadcast to the rest of the system. This function will include + * two given data in the broadcast message for logging. + * @details \b Inputs: none + * @details \b Outputs: alarm triggered message sent, alarm activated + * @details \b Message \b sent: MSG_ID_ALARM_TRIGGERED to update Alarm + * trigerred details along with the supporting data. + * @param alarm ID of alarm to activate + * @param alarmData1 supporting data to include in alarm message + * @param alarmData2 supporting data to include in alarm message + * @param outside flag indicates whether alarm is originating from outside HD f/w + * @return none + *************************************************************************/ +void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ) +{ + // broadcast alarm and data if alarm not already active + if ( ( FALSE == isAlarmActive( alarm ) ) && ( TRUE == isDDCommunicating() ) ) + { + broadcastAlarmTriggered( alarm, alarmData1, alarmData2 ); + } + activateAlarmFP( alarm ); + + /*RO_MODE_SUB_MODE_T tdModes; + ALARM_T props = getAlarmProperties( alarm ); + + //getROOperationMode( &tdModes ); + + // prevent alarm trigger if property blocks in current mode/state + if ( ( ( props.alarmBlockRinseback != TRUE ) || ( tdModes.tdMode != MODE_TREA ) || ( tdModes.tdSubMode != TREATMENT_RINSEBACK_STATE ) ) && + ( ( props.alarmBlockEndTx != TRUE ) || ( tdModes.tdMode != MODE_POST ) ) ) + { + // broadcast alarm and data if alarm not already active + if ( ( FALSE == isAlarmActive( alarm ) ) && ( TRUE == isDDCommunicating() ) ) + { + broadcastAlarmTriggered( alarm, alarmData1, alarmData2 ); + } + activateAlarmRO( alarm ); + } + */ +} + +/*********************************************************************//** + * @brief + * The clearAlarmDD function clears a given alarm if it is recoverable. + * An alarm message is broadcast to the rest of the system. + * @details \b Inputs: none + * @details \b Outputs: AlarmStatusTable[] + * @details \b Message \Sent: MSG_ID_ALARM_CLEARED to update clearance of + * the alarm. + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when invalid alarm needs + * to be cleared. + * @param alarm ID of alarm to clear + * @return none + *************************************************************************/ +void clearAlarmFP( ALARM_ID_T alarm ) +{ + ALARM_T props = getAlarmProperties( alarm ); + + // verify given alarm + if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) + { + // clear alarm and broadcast alarm clear if not already cleared (and not a DD fault which should not be cleared) + if ( ( TRUE == isAlarmActive( alarm ) ) && ( props.alarmIsDDFault != TRUE ) ) + { + if ( TRUE == isDDCommunicating() ) + { + broadcastAlarmCleared( alarm ); + } + setAlarmActive( alarm, FALSE ); + clearAlarmConditionFP( alarm ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_TO_CLEAR, alarm ) + } +} + +/*********************************************************************//** + * @brief + * The clearAlarmConditionDD function clears a given alarm's condition detected + * flag. Also an alarm message is broadcast to the rest of the system. + * @details \b Inputs: none + * @details \b Outputs: alarmIsDetected[] + * @details \b Message \b Sent: MSG_ID_ALARM_CONDITION_CLEARED to update + * alarm condition clearance. + * @details \b Alarm: ALARM_ID_DD_SOFTWARE_FAULT when invalid alarm conditioned + * needs to be cleared + * @param alarm ID of alarm to clear condition for + * @return none + *************************************************************************/ +void clearAlarmConditionFP( ALARM_ID_T alarm ) +{ + // verify given alarm + if ( ( alarm > ALARM_ID_NO_ALARM ) && ( alarm < NUM_OF_ALARM_IDS ) ) + { + // clear alarm and broadcast alarm clear if not already cleared + if ( TRUE == isAlarmConditionDetected( alarm ) ) + { + if ( TRUE == isDDCommunicating() ) + { + broadcastAlarmConditionCleared( alarm ); + } + setAlarmConditionDetected( alarm, FALSE ); + } + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_ALARM_MGMT_INVALID_ALARM_ID, alarm ) + } +} + +/*********************************************************************//** + * @brief + * The isDDFaultAlarmActive function determines whether a fault alarm is currently + * active. + * @details \b Inputs: alarmStatus + * @details \b Outputs: none + * @return TRUE if any alarm is active, FALSE if not + *************************************************************************/ +BOOL isDDFaultAlarmActive( void ) +{ + return isAFaultAlarmActive; +} + +/*********************************************************************//** + * @brief + * The publishAlarmInfo function publishes alarm information at the set + * interval. + * @details \b Inputs: + * @details \b Outputs: alarm information are published to CAN bus. + * @details \b Message \b Sent: MSG_ID_DD_ALARM_INFO_DATA to puslish saftey + * shutdown activation details. + * @return none + *************************************************************************/ +static void publishAlarmInfo( void ) +{ + // Publish voltages monitor data on interval + if ( ++alarmInfoPublicationTimerCounter >= getU32OverrideValue( &alarmInfoPublishInterval ) ) + { + SAFETY_SHUTDOWN_ACTIVATION_DATA_T data; + + data.safetyShutdownStatus = (U32)isSafetyShutdownActivated(); + + broadcastData( MSG_ID_FP_ALARM_INFO_DATA, COMM_BUFFER_OUT_CAN_FP_ALARM, (U08*)&data, sizeof( SAFETY_SHUTDOWN_ACTIVATION_DATA_T ) ); + alarmInfoPublicationTimerCounter = 0; + } +} + +/*********************************************************************//** + * @brief +* The handleResendActiveAlarmsRequest function processes the request to re-send +* all active alarms. +* @details \b Inputs: alarmIsActive[] +* @details \b Outputs: re-send active alarms to UI +* @details \b Message \b Sent: MSG_ID_ALARM_TRIGGERED to resend all active alarms. +* @return none +*************************************************************************/ +void handleResendActiveAlarmsRequest( void ) +{ + U32 index; + + for ( index = 0; index < NUM_OF_ALARM_IDS; index++ ) + { + if ( TRUE == isAlarmActive( (ALARM_ID_T)index ) ) + { + broadcastAlarmTriggered( index, BLANK_ALARM_DATA, BLANK_ALARM_DATA ); + } + } +} + +/*********************************************************************//** + * @brief +* The isAnyCleaningModeInletWaterConditionActive function returns the status +* of any of the inlet water conditions is active or not in a cleaning mode +* @details \b Inputs: none +* @details \b Outputs: none +* @return TRUE if any of the inlet water conditions is active otherwise, FALSE +*************************************************************************/ +BOOL isAnyCleaningModeInletWaterConditionActive( void ) +{ + BOOL status = FALSE; + + // Check all the inlet water conditions +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_TEMP_TOO_HIGH ); +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_TEMP_TOO_LOW ); +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_COND_TOO_HIGH ); +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_COND_TOO_LOW ); +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_PRESSURE_TOO_HIGH ); +// status |= isAlarmActive( ALARM_ID_DD_CLEANING_MODE_INLET_WATER_PRESSURE_TOO_LOW ); + + return status; +} + +/*********************************************************************//** + * @brief + * The isTransitionToFaultRequired function checks whether the alarm management + * should request a transition to fault mode immediately or it should be deferred + * @details \b Inputs: none + * @details \b Outputs: none + * @return TRUE if transition to fault is required otherwise, FALSE + *************************************************************************/ +static BOOL isTransitionToFaultRequired( void ) +{ + BOOL status = TRUE; + FP_OP_MODE_T opMode = getCurrentOperationMode(); + + switch( opMode ) + { + //case DD_MODE_FLUS: + //status = FALSE; + //break; + + default: + // NOTE: Do nothing for the other modes + break; + } + + return status; +} + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + +/*********************************************************************//** + * @brief + * The testClearAllAlarms function clears all active alarms, even if they + * are non-recoverable or faults. The caller of this function must provide + * the correct 32-bit key. A Dialin user must also be logged into DD. + * @details \b Inputs: none + * @details \b Outputs: alarmIsActive[], alarmStartedAt[] + * @details \b Message \b Sent: MSG_ID_ALARM_CLEARED to clear all alarms. + * @param key 32-bit supervisor alarm key required to perform this function + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testClearAllAlarms( U32 key ) +{ + BOOL result = FALSE; + + // Verify key + if ( SUPERVISOR_ALARM_KEY == key ) + { + // Verify tester has logged in with HD + if ( TRUE == isTestingActivated() ) + { + ALARM_ID_T a; + + // Clear all active alarms + for ( a = ALARM_ID_NO_ALARM; a < NUM_OF_ALARM_IDS; a++ ) + { + if ( TRUE == isAlarmActive( a ) ) + { + ALARM_NAME_DATA_T data; + + data.alarmName = (U32)a; + + broadcastData( MSG_ID_ALARM_CLEARED, COMM_BUFFER_OUT_CAN_FP_ALARM, (U08*)&data, sizeof( ALARM_NAME_DATA_T ) ); + setAlarmActive( a, FALSE ); + } + } + result = TRUE; + } + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testSetAlarmInfoPublishIntervalOverride function sets the override of the + * alarm information publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmInfoPublishInterval + * @param ms milliseconds between alarm info broadcasts + * @return TRUE if override set successful, FALSE if not + *************************************************************************/ +BOOL testSetAlarmInfoPublishIntervalOverride( U32 ms ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + U32 intvl = ms / TASK_GENERAL_INTERVAL; + + result = TRUE; + alarmInfoPublishInterval.ovData = intvl; + alarmInfoPublishInterval.override = OVERRIDE_KEY; + } + + return result; +} + +/*********************************************************************//** + * @brief + * The testResetAlarmInfoPublishIntervalOverride function resets the override of the + * alarm information publication interval. + * @details \b Inputs: none + * @details \b Outputs: alarmInfoPublishInterval + * @return TRUE if override reset successful, FALSE if not + *************************************************************************/ +BOOL testResetAlarmInfoPublishIntervalOverride( void ) +{ + BOOL result = FALSE; + + if ( TRUE == isTestingActivated() ) + { + result = TRUE; + alarmInfoPublishInterval.override = OVERRIDE_RESET; + alarmInfoPublishInterval.ovData = alarmInfoPublishInterval.ovInitData; + } + + return result; +} + +/**@}*/ Index: firmware/App/Services/AlarmMgmtFP.h =================================================================== diff -u --- firmware/App/Services/AlarmMgmtFP.h (revision 0) +++ firmware/App/Services/AlarmMgmtFP.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,56 @@ + +#ifndef __ALARM_MGMT_FP_H__ +#define __ALARM_MGMT_FP_H__ + +/** + * @defgroup AlarmManagement AlarmManagement + * @brief Alarm management service unit. Provides general alarm management functionality + * including support functions for triggering and clearing specific alarms. + * + * @addtogroup AlarmManagement + * @{ + */ + +// ********** public definitions ********** + +#include "FPCommon.h" +#include "FPDefs.h" +#include "AlarmDefs.h" +#include "AlarmMgmtSWFaults.h" + +/// Safety shutdown activation status +typedef struct +{ + U32 safetyShutdownStatus; ///< Safety shutdown activation status +} SAFETY_SHUTDOWN_ACTIVATION_DATA_T; + +/// Alarm name data publish +typedef struct +{ + U32 alarmName; ///< Alarm name. +} ALARM_NAME_DATA_T; + +// ********** public function prototypes ********** + +void initAlarmMgmtFP( void ); +void execAlarmMgmt( void ); + +void activateAlarmNoData( ALARM_ID_T alarm ); +void clearAlarmFP( ALARM_ID_T alarm ); +void clearAlarmConditionFP( ALARM_ID_T alarm ); +BOOL doesAlarmStatusIndicateStop( void ); +BOOL isDDFaultAlarmActive( void ); +void handleResendActiveAlarmsRequest( void ); + +void activateAlarm1Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData ); +void activateAlarm2Data( ALARM_ID_T alarm, ALARM_DATA_T alarmData1, ALARM_DATA_T alarmData2, BOOL outside ); + +BOOL isAnyCleaningModeInletWaterConditionActive( void ); + +BOOL testClearAllAlarms( U32 key ); +BOOL testSetAlarmInfoPublishIntervalOverride( U32 ms ); +BOOL testResetAlarmInfoPublishIntervalOverride( void ); + +/**@}*/ + +#endif Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/AlarmMgmtRO.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/AlarmMgmtRO.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Services/AlarmMgmtSWFaults.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Services/AlarmMgmtSWFaults.h (.../AlarmMgmtSWFaults.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -97,8 +97,8 @@ SW_FAULT_ID_INVALID_FLUID_PUMP_ID2 = 80, SW_FAULT_ID_INVALID_FLUID_PUMP_ID3 = 81, SW_FAULT_ID_INVALID_FLUID_PUMP_ID4 = 82, - SW_FAULT_ID_RO_PUMP_INVALID_EXEC_STATE = 83, - SW_FAULT_ID_RO_PUMP_INVALID_PUMP_ID1 = 84, + SW_FAULT_ID_FP_PUMP_INVALID_EXEC_STATE = 83, + SW_FAULT_ID_FP_PUMP_INVALID_PUMP_ID1 = 84, SW_FAULT_ID_OP_MODES_INVALID_MODE_TO_TRANSITION_TO = 85, SW_FAULT_ID_PRESSURE_SENSOR_INVALID_SENSOR1 = 86, SW_FAULT_ID_PRESSURE_SENSOR_INVALID_SENSOR2 = 87, @@ -126,12 +126,14 @@ SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED1 = 109, SW_FAULT_ID_INVALID_TEMPERATURE_SENSOR_SELECTED2 = 110, SW_FAULT_ID_HEATER_INVALID_EXEC_STATE = 111, - SW_FAULT_ID_RO_INVALID_GENW_STATE = 112, - SW_FAULT_ID_RO_INVALID_PGEN_STATE = 113, - SW_FAULT_ID_RO_INVALID_RO_CMD = 114, - SW_FAULT_ID_RO_INVALID_PUMP_DUTY_CYCLE_SELECTED = 115, - SW_FAULT_ID_RO_PUMP_INVALID_PRESSURE_SELECTED = 116, - SW_FAULT_ID_RO_PUMP_INVALID_FLOW_RATE_SET = 117, + SW_FAULT_ID_FP_INVALID_GENP_STATE = 112, + SW_FAULT_ID_FP_INVALID_PGEN_STATE = 113, + SW_FAULT_ID_FP_INVALID_FP_CMD = 114, + SW_FAULT_ID_FP_INVALID_PUMP_DUTY_CYCLE_SELECTED = 115, + SW_FAULT_ID_FP_PUMP_INVALID_PRESSURE_SELECTED = 116, + SW_FAULT_ID_FP_PUMP_INVALID_FLOW_RATE_SET = 117, + SW_FAULT_ID_FP_INVALID_FILTER_FLUSH_STATE = 118, + SW_FAULT_ID_FP_INVALID_PERMEATE_FLUSH_STATE = 119, NUM_OF_SW_FAULT_IDS } SW_FAULT_ID_T; Index: firmware/App/Services/DDInterface.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Services/DDInterface.c (.../DDInterface.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -15,16 +15,16 @@ * ***************************************************************************/ +#include +#include #include "DDInterface.h" #include "Messaging.h" #include "MessagePayloads.h" +#include "ModeGenPermeate.h" #include "ModeStandby.h" -#include "ModeWaterGen.h" -#include "ModeWaterPreGen.h" #include "OperationModes.h" #include "PersistentAlarm.h" #include "ROPump.h" -#include "SystemCommRO.h" #include "TaskGeneral.h" #include "Timers.h" @@ -154,7 +154,7 @@ result = handleGenWaterCmd( cmd.start, cmd.roRate ); break; default: - SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_RO_INVALID_RO_CMD, cmd.cmdID ) + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_FP_INVALID_FP_CMD, cmd.cmdID ) break; } } @@ -175,15 +175,15 @@ static BOOL handlePreGenCmd( BOOL start, F32 roRate ) { BOOL result = FALSE; - RO_OP_MODE_T roMode = getCurrentOperationMode(); + FP_OP_MODE_T roMode = getCurrentOperationMode(); - if ( ( RO_MODE_STAN == roMode ) && ( TRUE == start ) ) + if ( ( FP_MODE_STAN == roMode ) && ( TRUE == start ) ) { setDDPermeateFlowRate( roRate ); setFluidPumpPWMDutyCycle( P12_PUMP, roRate ); result = requestPreGenStart(); } - else if ( RO_MODE_PGEN == roMode ) + else if ( FP_MODE_PGEN == roMode ) { if ( FALSE == start ) { @@ -214,15 +214,15 @@ static BOOL handleGenWaterCmd( BOOL start, F32 roRate ) { BOOL result = FALSE; - RO_OP_MODE_T roMode = getCurrentOperationMode(); + FP_OP_MODE_T roMode = getCurrentOperationMode(); - if ( ( RO_MODE_PGEN == roMode ) && ( TRUE == start ) ) + if ( ( FP_MODE_PGEN == roMode ) && ( TRUE == start ) ) { setDDPermeateFlowRate( roRate ); setFluidPumpPWMDutyCycle( P12_PUMP,roRate ); result = requestGenWaterStart(); } - else if ( RO_MODE_GENW == roMode ) + else if ( FP_MODE_GENP == roMode ) { if ( FALSE == start ) { Index: firmware/App/Services/DDInterface.h =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/App/Services/DDInterface.h (.../DDInterface.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -18,8 +18,8 @@ #ifndef __DD_INTERFACE_H__ #define __DD_INTERFACE_H__ +#include "../../Common/FPDefs.h" #include "FPCommon.h" -#include "RODefs.h" #include "DDDefs.h" /** Index: firmware/App/Services/FpgaFP.c =================================================================== diff -u --- firmware/App/Services/FpgaFP.c (revision 0) +++ firmware/App/Services/FpgaFP.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,1413 @@ +/************************************************************************** +* +* Copyright (c) 2019-2024 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 FPGA.c +* +* @author (last) Sean Nash +* @date (last) 09-Nov-2024 +* +* @author (original) Sean Nash +* @date (original) 09-Nov-2024 +* +***************************************************************************/ + +#include +#include "string.h" // for memset(), memcpy() + +#include "Compatible.h" +#include "OperationModes.h" +#include "Timers.h" +#include "Utilities.h" + +/** + * @addtogroup FpgaRO + * @{ + */ + +// ********** private definitions ********** + +#define FPGA_EXPECTED_ID 0x01 ///< Expected ID for TD FPGA. + +#define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. + +#define MAX_FPGA_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< FPGA comm failures window +#define MAX_FPGA_COMM_FAILURES 3 ///< FPGA maximum comm failures per MAX_FPGA_COMM_FAILURES_WINDOW_MS +#define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up + +#define HEATER_ENABLED 0x01 ///< Heater enable bit. +#define HEATER_DISABLED 0x00 ///< Heater disabled. + +#define FPGA_CONDUCTIVITY_RESET_BIT 0x01 ///< Conductivity Sensor reset bit mask. +#define FPGA_CONDUCTIVITY_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor initialization enable bit mask. +#define FPGA_CONDUCTIVITY_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor write enable bit mask. +#define FPGA_CONDUCTIVITY_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor read enable bit mask. + +// FPGA Sensors Record +#pragma pack(push,1) + +/// Record structure for FPGA header read. +typedef struct +{ + U08 fpgaId; ///< Reg 0. FPGA ID code. Checked against expected value at power up to verify basic FPGA communication and operation. + U08 fpgaRev; ///< Reg 1. FPGA revision (minor) being reported. + U08 fpgaRevMajor; ///< Reg 2. FPGA revision (major) being reported. + U08 fpgaRevLab; ///< Reg 3. FPGA revision (lab) being reported. +} FPGA_HEADER_T; // Read only on FPGA + +/// Record structure for FPGA continuous priority reads. +typedef struct +{ + U16 compatibilityRev; ///< Reg 256. FPGA compatibility revision. + U16 counterTimer1ms; ///< Reg 258. FPGA 1ms timer counter. + U16 fpgaGenWrRd; ///< Reg 260. FPGA general read-back register (mirrored from a general write register in write page at addr 4). + U08 errorCountProcessor; ///< Reg 262. Error count for processor communications. + U08 errorCountPC; ///< Reg 263. Error count for TBD. + S16 pressureM1; ///< Reg 264. M1 pressure data. + U16 temperatureM1; ///< Reg 266. M1 temperature data. + U08 readCountM1; ///< Reg 268. M1 read counter. + U08 reserved1a; ///< Reg 269. M1 error counter. + S16 pressureM3; ///< Reg 270. M3 pressure data. + U16 temperatureM3; ///< Reg 272. M3 temperature data. + U08 readCountM3; ///< Reg 274. M3 read counter. + U08 reserved1b; ///< Reg 275. M3 error counter. + S16 pressureP8; ///< Reg 276. P8 pressure data. + U16 temperatureP8; ///< Reg 278. P8 temperature data. + U08 readCountP8; ///< Reg 280. P8 read counter. + U08 reserved1c; ///< Reg 281. P8 error counter. + S16 pressureP13; ///< Reg 282. P13 pressure data. + U16 temperatureP13; ///< Reg 284. P13 temperature data. + U08 readCountP13; ///< Reg 286. P13 read counter. + U08 reserved1d; ///< Reg 287. P13 error counter. + S16 pressureP17; ///< Reg 288. P17 pressure data. + U16 temperatureP17; ///< Reg 290. P17 temperature data. + U08 readCountP17; ///< Reg 292. P17 read counter. + U08 reserved1e; ///< Reg 293. P17 error counter. + S16 pressureX1; ///< Reg 294. X1 pressure data. + U16 temperatureX1; ///< Reg 296. X1 temperature data. + U08 readCountX1; ///< Reg 298. X1 read counter. + U08 reserved1f; ///< Reg 299. X1 error counter. + S16 pressureX2; ///< Reg 300. X2 pressure data. + U16 temperatureX2; ///< Reg 302. X2 temperature data. + U08 readCountX2; ///< Reg 304. X2 read counter. + U08 reserved1g; ///< Reg 305. X2 error counter. + S16 pressureX3; ///< Reg 306. X3 pressure data. + U16 temperatureX3; ///< Reg 308. X3 temperature data. + U08 readCountX3; ///< Reg 310. X3 read counter. + U08 reserved1h; ///< Reg 311. X3 error counter. + S16 pressureX4; ///< Reg 312. X4 pressure data. + U16 temperatureX4; ///< Reg 314. X4 temperature data. + U08 readCountX4; ///< Reg 316. X4 read counter. + U08 reserved1i; ///< Reg 317. X4 error counter. + S16 pressureX5; ///< Reg 318. X5 pressure data. + U16 temperatureX5; ///< Reg 320. X5 temperature data. + U08 readCountX5; ///< Reg 322. X5 read counter. + U08 reserved1j; ///< Reg 323. X5 error counter. + U16 p40PumpTachCount; ///< Reg 324. P40 pump tachometer counter. + U16 reserved2; ///< Reg 326. Reserved. + U08 p25LevelSwitch; ///< Reg 328. P25 level switch. + U08 reserved3; ///< Reg 329. Reserved. + U16 reserved4; ///< Reg 330. Reserved. + U16 reserved5; ///< Reg 332. Reserved. + U08 reserved6; ///< Reg 334. Reserved. + U08 reserved7; ///< Reg 335. Reserved. + U32 conductivityP9Data; ///< Reg 336. P9 conductivity sensor data. + U16 conductivityP9Cond; ///< Reg 340. P9 conductivity sensor conductivity. + U16 conductivityP9Temp; ///< Reg 342. P9 conductivity sensor temperature. + U08 conductivityP9ReadCount; ///< Reg 344. P9 conductivity sensor read counter. + U08 conductivityP9ErrorCount; ///< Reg 345. P9 conductivity sensor error counter. + U32 conductivityP18Data; ///< Reg 346. P18 conductivity sensor data. + U16 conductivityP18Cond; ///< Reg 350. P18 conductivity sensor conductivity. + U16 conductivityP18Temp; ///< Reg 352. P18 conductivity sensor temperature. + U08 conductivityP18ReadCount; ///< Reg 354. P18 conductivity sensor read counter. + U08 conductivityP18ErrorCount; ///< Reg 355. P18 conductivity sensor error counter. + U16 flowRateP7; ///< Reg 356. P7 flow sensor rate. + U16 flowTempP7; ///< Reg 358. P7 flow sensor temperature. + U16 p12PumpTachCount; ///< Reg 360. P12 pump tachometer counter. + U16 dsPumpTachCount; ///< Reg 362. DSP tachometer counter. + U16 flowIntTempP7; ///< Reg 364. P7 flow sensor internal temperature. + U16 valveControlReadback; ///< Reg 366. Valve control bits read back. + U16 p12PumpPWMReadback; ///< Reg 368. P12 pump PWM read back. + U16 p40PumpPWMReadback; ///< Reg 370. P40 pump PWM read back. + U08 p7flowReadCount; ///< Reg 372. P7 Flow sensor read counter. + U08 p7flowErrorCount; ///< Reg 373. P7 Flow sensor error counter. + U16 valvePWMEnableReadback; ///< Reg 374. Valve PWM enable read back. + U32 tempP23; ///< Reg 376. P23 temperature sensor reading. + U32 tempP22; ///< Reg 380. P22 ( TRO2 ) temperature sensor reading. + U32 tempTax1; ///< Reg 384. ( Tax1 ) temperature sensor reading. + U32 tempRTD; ///< Reg 388. spare temperature sensor reading. + U08 ad7124errcnt; ///< Reg 392. Counter which increments when an invalid transaction happen between FPGA and AD7124. + U08 ad7124readcnt; ///< Reg 393. Counter which increments when a valid transaction happens between FPGA and AD7124. + U16 flowRateP16; ///< Reg 394. P16 flow sensor rate. + U16 flowTempP16; ///< Reg 396. P16 flow sensor temperature. + U16 flowIntTempP16; ///< Reg 398. P16 flow sensor internal temperature. + U08 p16flowReadCount; ///< Reg 400. P16 Flow sensor read counter. + U08 p16flowErrorCount; ///< Reg 401. P16 Flow sensor error counter. + +} FPGA_SENSORS_T; + +/// Record structure for FPGA continuous priority writes. +typedef struct +{ + U16 valveControl; ///< Reg 04. Valve control register. + U08 conductivityP9Control; ///< Reg 06. P9 conductivity control register. + U08 conductivityP18Control; ///< Reg 07. P18 conductivity control register. + U16 conductivityP9Address; ///< Reg 08. P9 conductivity address register. + U32 conductivityP9Data; ///< Reg 10. P9 conductivity data in register. + U16 conductivityP18Address; ///< Reg 14. P18 conductivity address register. + U32 conductivityP18Data; ///< Reg 16. P18 conductivity data in register. + U16 fpgaGenWrRd; ///< Reg 20. FPGA general write/read-back register (mirrored to a general read register in read page at addr 256). + U16 descalePumpSpeed; ///< Reg 22. Descaler pump speed register. + U08 descalePumpControl; ///< Reg 24. Descaler pump control register. + U08 p12PumpControl; ///< Reg 25. P12 pump control register. + U16 valveVwiPWMLow; ///< Reg 26. Valve VWi PWM low pulse period in 0.1 uSec. + U16 valveVwiPWMPeriod; ///< Reg 28. Valve VWi PWM full period in 0.1 uSec. + U16 valvePWMPullIn; ///< Reg 30. Valve PWM high pulse period when valve is on in 0.1 uSec. + U16 p12PumpPWMDutyCyclePct; ///< Reg 32. P12 pump PWM duty cycle in percentage. + U16 p40PumpPWMDutyCyclePct; ///< Reg 34. P40 pump PWM duty cycle in percentage. + U08 p40PumpControl; ///< Reg 36. P40 pump control register. + U08 reserved1; ///< Reg 37. Reserved. + U08 flowControlp7; ///< Reg 38. P7 AVS Romer flow sensor control register. + U08 flowAddressp7; ///< Reg 39. P7 AVS Romer flow sensor I2C slave address register. + U16 valvePWMEnable; ///< Reg 40. Valve PWM enable register. + U08 flowControlp16; ///< Reg 42. P16 AVS Romer flow sensor control register. + U08 flowAddressp16; ///< Reg 43. P16 AVS Romer flow sensor I2C slave address register. +} FPGA_ACTUATORS_T; + +#pragma pack(pop) + +// ********** private data ********** + +// FPGA data +static FPGA_HEADER_T fpgaHeader; ///< Record of last received FPGA header data. +static FPGA_SENSORS_T fpgaSensorReadings; ///< Record of last received FPGA priority sensor data. +static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< Record of next transmitted FPGA priority actuator data. + +// FPGA Clock Speed Test +static U16 currentFPGATimerCount_ms = 0; ///< Last read ms timer count from FPGA. +static U32 currentTimerCount_ms = 0; ///< Last read ms timer count from processor. + +/*********************************************************************//** + * @brief + * The initFPGARO function initializes the RO FPGA unit. + * @details \b Inputs: none + * @details \b Outputs: RO FPGA unit initialized. + * @return none + *************************************************************************/ +void initFPGARO( void ) +{ + // Initialize fpga driver + initFPGA( (U08*)&fpgaHeader, (U08*)&fpgaSensorReadings, (U08*)&fpgaActuatorSetPoints, + sizeof(FPGA_HEADER_T), sizeof(FPGA_SENSORS_T), sizeof(FPGA_ACTUATORS_T) ); + // Initialize fpga data structures + memset( &fpgaHeader, 0, sizeof(FPGA_HEADER_T) ); + memset( &fpgaSensorReadings, 0, sizeof(FPGA_SENSORS_T) ); + memset( &fpgaActuatorSetPoints, 0, sizeof(FPGA_ACTUATORS_T) ); + + // initialize FPGA clock speed error time windowed count + initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES_WINDOW_MS); +} + +/*********************************************************************//** + * @brief + * The execFPGATest function executes the FPGA self-test. + * @details \b Alarm: ALARM_ID_RO_FPGA_POST_TEST_FAILED if self-test fails. + * @details \b Inputs: fpgaHeader + * @details \b Outputs: none + * @return passed or failed + *************************************************************************/ +SELF_TEST_STATUS_T execFPGATest( void ) +{ + SELF_TEST_STATUS_T result; + + // check FPGA reported correct ID + if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) + { + // Check FPGA compatibility w/ firmware + if ( RO_FPGA_COMPATIBILITY_REV == fpgaSensorReadings.compatibilityRev ) + { + result = SELF_TEST_STATUS_PASSED; + } + else + { + result = SELF_TEST_STATUS_FAILED; + // TODO uncomment +// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_POST_TEST_FAILED, (U32)TD_FPGA_COMPATIBILITY_REV, (U32)fpgaSensorReadings.fpgaCompatibilityRev ) + } + } + else + { + result = SELF_TEST_STATUS_FAILED; + // TODO uncomment +// SET_ALARM_WITH_1_U32_DATA( ALARM_ID_RO_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getFPGATimerCount function gets the latest FPGA timer millisecond count. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last FPGA millisecond timer count + *************************************************************************/ +U16 getFPGATimerCount( void ) +{ + return fpgaSensorReadings.counterTimer1ms; +} + +/*********************************************************************//** + * @brief + * The execFPGAClockSpeedTest function verifies the processor clock speed + * against the FPGA clock. + * @details \b Alarm: ALARM_ID_RO_FPGA_CLOCK_SPEED_CHECK_FAILURE if test fails. + * @details \b Inputs: fpgaSensorReadings.fpgaTimerCount_ms, msTimerCount, + * currentFPGATimerCount_ms, currentTimerCount_ms + * @details \b Outputs: currentFPGATimerCount_ms, currentTimerCount_ms + * @return none + *************************************************************************/ +void execFPGAClockSpeedTest( void ) +{ +// DEBUG WARNING +// It may be necessary to comment out the following +// code to prevent the alarm from occurring while +// debugging. + U16 newFPGATimerCount_ms = getFPGATimerCount(); + U32 newTimerCount_ms = getMSTimerCount(); + U32 diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); + U32 diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); + + if ( getCurrentOperationMode() != FP_MODE_INIT ) + { + if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) + { + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR ) ) + { + // TODO uncomment +// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); + } + } + } + + currentFPGATimerCount_ms = newFPGATimerCount_ms; + currentTimerCount_ms = newTimerCount_ms; +} + +/*********************************************************************//** + * @brief + * The getFPGAVersions function gets the fpga version numbers. + * @details \b Inputs: fpgaHeader + * @details \b Outputs: Given version reference variables are populated. + * @return none + *************************************************************************/ +void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) +{ + *Id = fpgaHeader.fpgaId; + *Min = fpgaHeader.fpgaRev; + *Maj = fpgaHeader.fpgaRevMajor; + *Lab = fpgaHeader.fpgaRevLab; +} + +/*********************************************************************//** + * @brief + * The checkFPGACommFailure function increments the FPGA comm failure + * windowed timer and returns whether or not the number of failures in + * the window have been reached. + * @details \b Inputs: none + * @details \b Outputs: none + * @return TRUE if windowed count exceeded, else false. + *************************************************************************/ +void checkFPGACommFailure( void ) +{ + if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) + { + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) + { + // TODO uncomment +// SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.errorCountProcessor ) + } + } +} + +/*********************************************************************//** + * @brief + * The checkFPGAAFEOEFailure function increments the FPGA comm failure + * windowed timer if an FE or OE error has occurred and returns whether + * or not the number of failures in + * the window have been reached. + * @details \b Inputs: none + * @details \b Outputs: none + * @details \b Alarm: ALARM_ID_DD_FPGA_COMM_TIMEOUT when FPGA communication is + * lost with the processor. + * @return TRUE if windowed count exceeded, else false. + *************************************************************************/ +BOOL checkFPGAFEOEFailure( void ) +{ + BOOL status = FALSE; + BOOL FPGAFEOEError = getSci2FEOEError(); + + if ( TRUE == FPGAFEOEError) + { + if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) + { + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) + { + // TODO uncomment + //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) + status = TRUE; + } + } + } + + return status; +} + +/*********************************************************************//** + * @brief + * The setFPGAValveStates function sets the RO valve states with an 8-bit + * mask of states - one bit per valve, with a 1 meaning "energized" and a 0 + * meaning "de-energized". The bit positions for these bit states are as follows: + * 0 - VWi.\n + * 1 - VFb.\n + * 2 - VFf.\n + * 3 - VPi.\n + * 4 - VCr.\n + * 5 - VCb.\n + * 6 - VCd.\n + * 7 - VROd.\n + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.valveControl + * @param valveStates bit mask for requested valve states + * @return none + *************************************************************************/ +void setFPGAValveStates( U16 valveStates ) +{ + fpgaActuatorSetPoints.valveControl = valveStates; +} + +/*********************************************************************//** + * @brief + * The getFPGAValveStates function gets the RO valve commanded states with + * an 8-bit mask representing the set of states with a 1 meaning "energized" + * and a 0 meaning "de-energized". + * @details \b Inputs: none + * @details \b Outputs: fpgaSensorReadings.valveControlReadback + * @return none + *************************************************************************/ +U16 getFPGAValveStates( void ) +{ + return fpgaSensorReadings.valveControlReadback; +} + +/*********************************************************************//** + * @brief + * The setFPGAP12PumpEnable function enables or disables the P12 pump. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p12PumpControl + * @param enable flag indicating whether to enable or disable the P12 pump. + * @return none + *************************************************************************/ +void setFPGAP12PumpEnable( BOOL enable ) +{ + fpgaActuatorSetPoints.p12PumpControl = ( TRUE == enable ? 0x1 : 0x0 ); +} + +/*********************************************************************//** + * @brief + * The setFPGAP12PumpPWM function sets the P12 pump PWM duty cycle. + * The higher the PWM duty cycle (0..500), the faster the pump will go. + * @note PWM values < 5% or > 95% will cause pump to stop so effective + * range is actually 25..475. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p12PumpPWMDutyCyclePct + * @param pwm PWM duty cycle magnitude + * @return none + *************************************************************************/ +void setFPGAP12PumpPWM( U16 pwm ) +{ + fpgaActuatorSetPoints.p12PumpPWMDutyCyclePct = pwm; +} + +/*********************************************************************//** + * @brief + * The getFPGAP12PumpPWM function gets a read back from FPGA of RO pump PWM + * duty cycle. + * @details \b Inputs: fpgaSensorReadings.roPumpPWMReadback + * @details \b Outputs: none + * @return measured speed (RPM) of the RO pump + *************************************************************************/ +U16 getFPGAP12PumpPWM( void ) +{ + return fpgaSensorReadings.p12PumpPWMReadback; +} + +/*********************************************************************//** + * @brief + * The getFPGAP12PumpTachCount function gets the running 16-bit tachometer count + * from the P12 pump hall sensor. + * @details \b Inputs: fpgaSensorReadings.p12PumpTachCount + * @details \b Outputs: none + * @return P12 pump tachometer count + *************************************************************************/ +U16 getFPGAP12PumpTachCount( void ) +{ + return fpgaSensorReadings.p12PumpTachCount; +} + +/*********************************************************************//** + * @brief + * The setFPGAP24Enabled function sets the heater enable on or off. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p24Control + * @param enable Flag indicating whether to enable or disable the P24 heater. + * @return none + *************************************************************************/ +void setFPGAP24Enabled( BOOL enable ) +{ + return; +} + +/*********************************************************************//** + * @brief + * The setFPGAP24PWM function sets the P24 heater PWM duty cycle. + * The higher the PWM duty cycle (0..500), the faster the pump will go. + * @note PWM values < 5% or > 95% will cause heater to go off so effective + * range is actually 25..475. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p24PWMDutyCyclePct + * @param pwm PWM duty cycle magnitude + * @return none + *************************************************************************/ +void setFPGAP24PWM( U16 pwm ) +{ + return; +} + +/*********************************************************************//** + * @brief + * The getFPGAM1RawPressure function gets the M1 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureM1 + * @details \b Outputs: none + * @return M1 pressure + *************************************************************************/ +S16 getFPGAM1RawPressure( void ) +{ + return fpgaSensorReadings.pressureM1; +} + +/*********************************************************************//** + * @brief + * The getFPGAM1RawTemperature function gets the M1 sensor temperature reading. + * @details \b Inputs: fpgaSensorReadings.temperatureM1 + * @details \b Outputs: none + * @return M1 sensor temperature + *************************************************************************/ +S16 getFPGAM1RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureM1; +} + +/*********************************************************************//** + * @brief + * The getFPGAM1ReadCount function gets the M1 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountM1 + * @details \b Outputs: none + * @return M1 sensor read count + *************************************************************************/ +U08 getFPGAM1ReadCount( void ) +{ + return fpgaSensorReadings.readCountM1; +} + +/*********************************************************************//** + * @brief + * The getFPGAM3RawPressure function gets the M3 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureM3 + * @details \b Outputs: none + * @return M3 pressure + *************************************************************************/ +S16 getFPGAM3RawPressure( void ) +{ + return fpgaSensorReadings.pressureM3; +} + +/*********************************************************************//** + * @brief + * The getFPGAM3RawTemperature function gets the M3 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureM3 + * @details \b Outputs: none + * @return M3 sensor temperature + *************************************************************************/ +S16 getFPGAM3RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureM3; +} + +/*********************************************************************//** + * @brief + * The getFPGAM3ReadCount function gets the M3 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountM3 + * @details \b Outputs: none + * @return M3 sensor read count + *************************************************************************/ +U08 getFPGAM3ReadCount( void ) +{ + return fpgaSensorReadings.readCountM3; +} + +/*********************************************************************//** + * @brief + * The getFPGAP8RawPressure function gets the P8 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureP8 + * @details \b Outputs: none + * @return P8 pressure + *************************************************************************/ +S16 getFPGAP8RawPressure( void ) +{ + return fpgaSensorReadings.pressureP8; +} + +/*********************************************************************//** + * @brief + * The getFPGAP8RawTemperature function gets the P8 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureP8 + * @details \b Outputs: none + * @return P8 sensor temperature + *************************************************************************/ +S16 getFPGAP8RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureP8; +} + +/*********************************************************************//** + * @brief + * The getFPGAP8ReadCount function gets the P8 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountP8 + * @details \b Outputs: none + * @return P8 sensor read count + *************************************************************************/ +U08 getFPGAP8ReadCount( void ) +{ + return fpgaSensorReadings.readCountP8; +} + +/*********************************************************************//** + * @brief + * The getFPGAP13RawPressure function gets the P13 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureP13 + * @details \b Outputs: none + * @return P13 pressure + *************************************************************************/ +S16 getFPGAP13RawPressure( void ) +{ + return fpgaSensorReadings.pressureP13; +} + +/*********************************************************************//** + * @brief + * The getFPGAP13RawTemperature function gets the P13 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureP13 + * @details \b Outputs: none + * @return P13 sensor temperature + *************************************************************************/ +S16 getFPGAP13RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureP13; +} + +/*********************************************************************//** + * @brief + * The getFPGAP13ReadCount function gets the P13 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountP13 + * @details \b Outputs: none + * @return P13 sensor read count + *************************************************************************/ +U08 getFPGAP13ReadCount( void ) +{ + return fpgaSensorReadings.readCountP13; +} + +/*********************************************************************//** + * @brief + * The getFPGAP17RawPressure function gets the P17 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureP17 + * @details \b Outputs: none + * @return P17 pressure + *************************************************************************/ +S16 getFPGAP17RawPressure( void ) +{ + return fpgaSensorReadings.pressureP17; +} + +/*********************************************************************//** + * @brief + * The getFPGAP17RawTemperature function gets the P17 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureP17 + * @details \b Outputs: none + * @return P17 sensor temperature + *************************************************************************/ +S16 getFPGAP17RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureP17; +} + +/*********************************************************************//** + * @brief + * The getFPGAP17ReadCount function gets the P17 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountP17 + * @details \b Outputs: none + * @return P17 sensor read count + *************************************************************************/ +U08 getFPGAP17ReadCount( void ) +{ + return fpgaSensorReadings.readCountP17; +} + +/*********************************************************************//** + * @brief + * The getFPGAX1RawPressure function gets the X1 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureX1 + * @details \b Outputs: none + * @return X1 pressure + *************************************************************************/ +S16 getFPGAX1RawPressure( void ) +{ + return fpgaSensorReadings.pressureX1; +} + +/*********************************************************************//** + * @brief + * The getFPGAX1RawTemperature function gets the X1 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureX1 + * @details \b Outputs: none + * @return X1 sensor temperature + *************************************************************************/ +S16 getFPGAX1RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureX1; +} + +/*********************************************************************//** + * @brief + * The getFPGAX1ReadCount function gets the X1 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountX1 + * @details \b Outputs: none + * @return X1 sensor read count + *************************************************************************/ +U08 getFPGAX1ReadCount( void ) +{ + return fpgaSensorReadings.readCountX1; +} + +/*********************************************************************//** + * @brief + * The getFPGAX2RawPressure function gets the X2 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureX2 + * @details \b Outputs: none + * @return X2 pressure + *************************************************************************/ +S16 getFPGAX2RawPressure( void ) +{ + return fpgaSensorReadings.pressureX2; +} + +/*********************************************************************//** + * @brief + * The getFPGAX2RawTemperature function gets the X2 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureX2 + * @details \b Outputs: none + * @return X2 sensor temperature + *************************************************************************/ +S16 getFPGAX2RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureX2; +} + +/*********************************************************************//** + * @brief + * The getFPGAX1ReadCount function gets the X2 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountX2 + * @details \b Outputs: none + * @return X2 sensor read count + *************************************************************************/ +U08 getFPGAX2ReadCount( void ) +{ + return fpgaSensorReadings.readCountX2; +} + +/*********************************************************************//** + * @brief + * The getFPGAX3RawPressure function gets the X3 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureX3 + * @details \b Outputs: none + * @return X3 pressure + *************************************************************************/ +S16 getFPGAX3RawPressure( void ) +{ + return fpgaSensorReadings.pressureX3; +} + +/*********************************************************************//** + * @brief + * The getFPGAX3RawTemperature function gets the X3 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureX3 + * @details \b Outputs: none + * @return X3 sensor temperature + *************************************************************************/ +S16 getFPGAX3RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureX3; +} + +/*********************************************************************//** + * @brief + * The getFPGAX3ReadCount function gets the X3 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountX3 + * @details \b Outputs: none + * @return X3 sensor read count + *************************************************************************/ +U08 getFPGAX3ReadCount( void ) +{ + return fpgaSensorReadings.readCountX3; +} + +/*********************************************************************//** + * @brief + * The getFPGAX4RawPressure function gets the X4 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureX4 + * @details \b Outputs: none + * @return X4 pressure + *************************************************************************/ +S16 getFPGAX4RawPressure( void ) +{ + return fpgaSensorReadings.pressureX4; +} + +/*********************************************************************//** + * @brief + * The getFPGAX4RawTemperature function gets the X4 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureX4 + * @details \b Outputs: none + * @return X4 sensor temperature + *************************************************************************/ +S16 getFPGAX4RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureX4; +} + +/*********************************************************************//** + * @brief + * The getFPGAX4ReadCount function gets the X4 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountX4 + * @details \b Outputs: none + * @return X4 sensor read count + *************************************************************************/ +U08 getFPGAX4ReadCount( void ) +{ + return fpgaSensorReadings.readCountX4; +} + +/*********************************************************************//** + * @brief + * The getFPGAX5RawPressure function gets the X5 pressure reading. + * @details \b Inputs: fpgaSensorReadings.pressureX5 + * @details \b Outputs: none + * @return X5 pressure + *************************************************************************/ +S16 getFPGAX5RawPressure( void ) +{ + return fpgaSensorReadings.pressureX5; +} + +/*********************************************************************//** + * @brief + * The getFPGAX5RawTemperature function gets the X5 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.temperatureX5 + * @details \b Outputs: none + * @return X5 sensor temperature + *************************************************************************/ +S16 getFPGAX5RawTemperature( void ) +{ + return fpgaSensorReadings.temperatureX5; +} + +/*********************************************************************//** + * @brief + * The getFPGAX5ReadCount function gets the X5 sensor read count. + * @details \b Inputs: fpgaSensorReadings.readCountX5 + * @details \b Outputs: none + * @return X5 sensor read count + *************************************************************************/ +U08 getFPGAX5ReadCount( void ) +{ + return fpgaSensorReadings.readCountX5; +} + +/*********************************************************************//** + * @brief + * The getFPGAP23Temperature function gets the TRO1 temperature sensor reading. + * @details \b Inputs: fpgaSensorReadings.tempP23 + * @details \b Outputs: none + * @return P23 temperature sensor reading + *************************************************************************/ +U32 getFPGAP23Temperature( void ) +{ + return fpgaSensorReadings.tempP23; +} + +/*********************************************************************//** + * @brief + * The getFPGAP22Temperature function gets the TRO2 temperature sensor reading. + * @details \b Inputs: fpgaSensorReadings.tempP22 + * @details \b Outputs: none + * @return P22 temperature sensor reading + *************************************************************************/ +U32 getFPGAP22Temperature( void ) +{ + return fpgaSensorReadings.tempP22; +} + +/*********************************************************************//** + * @brief + * The getFPGAP25FloaterState function gets the P25 floater level state. + * @details \b Inputs: fpgaSensorReadings.levelSwitch + * @details \b Outputs: none + * @return P25 floater level state + *************************************************************************/ +U08 getFPGAP25FloaterState( void ) +{ + return fpgaSensorReadings.p25LevelSwitch; +} + +/*********************************************************************//** + * @brief + * The getFPGAFlowFMP function gets the P16 flow rate (in mL/min). + * @details \b Inputs: fpgaSensorReadings.flowRateP16 + * @details \b Outputs: none + * @return P16 flow rate (in mL/min) + *************************************************************************/ +U16 getFPGAFlowP16( void ) +{ + return fpgaSensorReadings.flowRateP16; +} + +/*********************************************************************//** + * @brief + * The getFPGAFlowP16Temp function gets the P16 flow sensor temperature, the + * temperature of the fluid flowing through the sensor. + * @details \b Inputs: fpgaSensorReadings.flowTempP16 + * @details \b Outputs: none + * @return P16 fluid temperature + *************************************************************************/ +U16 getFPGAFlowP16Temp( void ) +{ + return fpgaSensorReadings.flowTempP16; +} + +/*********************************************************************//** + * @brief + * The getFPGAFlowP7 function gets the P7 flow rate (in mL/min). + * @details \b Inputs: fpgaSensorReadings.flowRateP7 + * @details \b Outputs: none + * @return P7 flow rate (in mL/min) + *************************************************************************/ +U16 getFPGAFlowP7( void ) +{ + return fpgaSensorReadings.flowRateP7; +} + +/*********************************************************************//** + * @brief + * The getFPGAFlowP7Temp function gets the P7 flow sensor temperature, the + * temperature of the fluid flowing through the sensor. + * @details \b Inputs: fpgaSensorReadings.flowTempP7 + * @details \b Outputs: none + * @return P7 fluid temperature + *************************************************************************/ +U16 getFPGAFlowP7Temp( void ) +{ + return fpgaSensorReadings.flowTempP7; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9Control function sets the FPGA P9 sensor control register + * to perform a given action. + * bit 4..7: unused + * bit 3: Enable P9 read transaction; address needed + * bit 2: Enable P9 write transaction; address and data needs to be set + * bit 1: Enable P9 initialization procedure + * bit 0: reset P9 sensor + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @param control bits indicating control action to take + * @return none + *************************************************************************/ +void setFPGAP9Control( U08 control ) +{ + fpgaActuatorSetPoints.conductivityP9Control = control; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9Address function sets the read/write address for a read/write + * action on the P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Address + * @param address The P9 sensor address to read from or write to + * @return none + *************************************************************************/ +void setFPGAP9Address( U16 address ) +{ + fpgaActuatorSetPoints.conductivityP9Address = address; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9Data function sets the write data for a write action on + * the P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Data + * @param data The 32-bit data to write to the P9 sensor + * @return none + *************************************************************************/ +void setFPGAP9Data( U32 data ) +{ + fpgaActuatorSetPoints.conductivityP9Data = data; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18Control function sets the FPGA P18 sensor control register + * to perform a given action. + * bit 4..7: unused + * bit 3: Enable P18 read transaction; address needed + * bit 2: Enable P18 write transaction; address and data needs to be set + * bit 1: Enable P18 initialization procedure + * bit 0: reset P18 sensor + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @param control bits indicating control action to take + * @return none + *************************************************************************/ +void setFPGAP18Control( U08 control ) +{ + fpgaActuatorSetPoints.conductivityP18Control = control; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18Address function sets the read/write address for a read/write + * action on the P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Address + * @param address The P18 sensor address to read from or write to + * @return none + *************************************************************************/ +void setFPGAP18Address( U16 address ) +{ + fpgaActuatorSetPoints.conductivityP18Address = address; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18Data function sets the write data for a write action on + * the P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Data + * @param data The 32-bit data to write to the P18 sensor + * @return none + *************************************************************************/ +void setFPGAP18Data( U32 data ) +{ + fpgaActuatorSetPoints.conductivityP18Data = data; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9Reset function sets the reset command bit for P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void setFPGAP9Reset( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control |= FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP9Reset function clears the reset command bit for P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void clearFPGAP9Reset( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control &= ~FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9InitEnable function sets the initialize command bit for + * P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void setFPGAP9InitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control |= FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP9InitEnable function clears the initialize command bit for + * P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void clearFPGAP9InitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control &= ~FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9WriteEnable function sets the write enable command bit for + * P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void setFPGAP9WriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control |= FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP9WriteEnable function clears the write enable command bit + * for P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void clearFPGAP9WriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control &= ~FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP9ReadEnable function sets the read enable command bit for + * P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void setFPGAP9ReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control |= FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP9ReadEnable function clears the read enable command bit + * for P9 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP9Control + * @return none + *************************************************************************/ +void clearFPGAP9ReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP9Control &= ~FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18Reset function sets the reset command bit for P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void setFPGAP18Reset( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control |= FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP18Reset function clears the reset command bit for P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void clearFPGAP18Reset( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control &= ~FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18InitEnable function sets the initialize command bit for + * P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void setFPGAP18InitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control |= FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP18InitEnable function clears the initialize command bit for + * P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void clearFPGAP18InitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control &= ~FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18WriteEnable function sets the write enable command bit for + * P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void setFPGAP18WriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control |= FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP18WriteEnable function clears the write enable command bit + * for P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void clearFPGAP18WriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control &= ~FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAP18ReadEnable function sets the read enable command bit for + * P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void setFPGAP18ReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control |= FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAP18ReadEnable function clears the read enable command bit + * for P18 sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityP18Control + * @return none + *************************************************************************/ +void clearFPGAP18ReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityP18Control &= ~FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The getFPGAP9ReadCount function gets the latest P9 sensor read count. + * @details \b Inputs: fpgaSensorReadings.conductivityP9ReadCount + * @details \b Outputs: none + * @return Current read count for P9 sensor. + *************************************************************************/ +U08 getFPGAP9ReadCount( void ) +{ + return fpgaSensorReadings.conductivityP9ReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGAP9ErrorCount function gets the latest P9 sensor error count. + * @details \b Inputs: fpgaSensorReadings.conductivityP9ErrorCount + * @details \b Outputs: none + * @return Current error count for P9 sensor. + *************************************************************************/ +U08 getFPGAP9ErrorCount( void ) +{ + return fpgaSensorReadings.conductivityP9ErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGAP9Conductivity function gets the latest P9 sensor conductivity + * reading. + * @details \b Inputs: fpgaSensorReadings.conductivityP9Cond + * @details \b Outputs: none + * @return Current conductivity reading from P9 sensor. + *************************************************************************/ +U16 getFPGAP9Conductivity( void ) +{ + return fpgaSensorReadings.conductivityP9Cond; +} + +/*********************************************************************//** + * @brief + * The getFPGAP9Temperature function gets the latest P9 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.conductivityP9Temp + * @details \b Outputs: none + * @return Current temperature from P9 sensor. + *************************************************************************/ +U16 getFPGAP9Temperature( void ) +{ + return fpgaSensorReadings.conductivityP9Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGAP9Data function gets the latest P9 sensor data from a read + * action. + * @details \b Inputs: fpgaSensorReadings.conductivityP9Data + * @details \b Outputs: none + * @return Latest data read from P9 sensor. + *************************************************************************/ +U32 getFPGAP9Data( void ) +{ + return fpgaSensorReadings.conductivityP9Data; +} + +/*********************************************************************//** + * @brief + * The getFPGAP18ReadCount function gets the latest P18 sensor read count. + * @details \b Inputs: fpgaSensorReadings.conductivityP18ReadCount + * @details \b Outputs: none + * @return Current read count for P18 sensor. + *************************************************************************/ +U08 getFPGAP18ReadCount( void ) +{ + return fpgaSensorReadings.conductivityP18ReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGAP18ErrorCount function gets the latest P18 sensor error count. + * @details \b Inputs: fpgaSensorReadings.conductivityP18ErrorCount + * @details \b Outputs: none + * @return Current error count for P18 sensor. + *************************************************************************/ +U08 getFPGAP18ErrorCount( void ) +{ + return fpgaSensorReadings.conductivityP18ErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGAP18Conductivity function gets the latest P18 sensor conductivity + * reading. + * @details \b Inputs: fpgaSensorReadings.conductivityP18Cond + * @details \b Outputs: none + * @return Current conductivity reading from P18 sensor. + *************************************************************************/ +U16 getFPGAP18Conductivity( void ) +{ + return fpgaSensorReadings.conductivityP18Cond; +} + +/*********************************************************************//** + * @brief + * The getFPGAP18Temperature function gets the latest P18 sensor temperature. + * @details \b Inputs: fpgaSensorReadings.conductivityP18Temp + * @details \b Outputs: none + * @return Current temperature from P18 sensor. + *************************************************************************/ +U16 getFPGAP18Temperature( void ) +{ + return fpgaSensorReadings.conductivityP18Temp; +} + +/*********************************************************************//** + * @brief + * The getFPGAP18Data function gets the latest P18 sensor data from a read + * action. + * @details \b Inputs: fpgaSensorReadings.conductivityP18Data + * @details \b Outputs: none + * @return Latest data read from P18 sensor. + *************************************************************************/ +U32 getFPGAP18Data( void ) +{ + return fpgaSensorReadings.conductivityP18Data; +} + +/*********************************************************************//** + * @brief + * The setFPGAP40PumpEnable function enables or disables the P40 pump. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p40PumpControl + * @param enable flag indicating whether to enable or disable the P40 pump. + * @return none + *************************************************************************/ +void setFPGAP40PumpEnable( BOOL enable ) +{ + fpgaActuatorSetPoints.p40PumpControl = ( TRUE == enable ? 0x1 : 0x0 ); +} + +/*********************************************************************//** + * @brief + * The setFPGAP40PumpPWM function sets the P40 pump PWM duty cycle. + * The higher the PWM duty cycle (0..500), the faster the pump will go. + * @note PWM values < 5% or > 95% will cause pump to stop so effective + * range is actually 25..475. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.p40PumpPWMDutyCyclePct + * @param pwm PWM duty cycle magnitude + * @return none + *************************************************************************/ +void setFPGAP40PumpPWM( U16 pwm ) +{ + fpgaActuatorSetPoints.p40PumpPWMDutyCyclePct = pwm; +} + +/*********************************************************************//** + * @brief + * The getFPGAP12PumpPWM function gets a read back from FPGA of RO pump PWM + * duty cycle. + * @details \b Inputs: fpgaSensorReadings.p40PumpPWMReadback + * @details \b Outputs: none + * @return measured speed (RPM) of the P40 pump + *************************************************************************/ +U16 getFPGAP40PumpPWM( void ) +{ + return fpgaSensorReadings.p40PumpPWMReadback; +} + +/*********************************************************************//** + * @brief + * The getFPGAP12PumpTachCount function gets the running 16-bit tachometer count + * from the P40 pump hall sensor. + * @details \b Inputs: fpgaSensorReadings.p40PumpTachCount + * @details \b Outputs: none + * @return P40 pump tachometer count + *************************************************************************/ +U16 getFPGAP40PumpTachCount( void ) +{ + return fpgaSensorReadings.p40PumpTachCount; +} + +/**@}*/ Index: firmware/App/Services/FpgaFP.h =================================================================== diff -u --- firmware/App/Services/FpgaFP.h (revision 0) +++ firmware/App/Services/FpgaFP.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,149 @@ +/************************************************************************** +* +* Copyright (c) 2019-2024 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 FpgaRO.h +* +* @author (last) Sean Nash +* @date (last) 09-Nov-2024 +* +* @author (original) Sean Nash +* @date (original) 09-Nov-2024 +* +***************************************************************************/ + +#ifndef __FPGA_RO_H__ +#define __FPGA_RO_H__ + +#include "FPCommon.h" +#include "FPGA.h" + +/** + * @defgroup FpgaRO FpgaRO + * @brief FPGA service unit for RO firmware. + * The FPGA unit contains get/set functions for the RO FPGA registers. + * + * @addtogroup FpgaRO + * @{ + */ + +// ********** public definitions ********** + + +// ********** public function prototypes ********** + +void initFPGARO( void ); +SELF_TEST_STATUS_T execFPGATest( void ); + +void checkFPGACommFailure( void ); +BOOL checkFPGAFEOEFailure( void ); + +void setFPGAValveStates( U16 valveStates ); +U16 getFPGAValveStates( void ); + +void setFPGAP12PumpEnable( BOOL enable ); +void setFPGAP12PumpPWM( U16 pwm ); +U16 getFPGAP12PumpPWM( void ); +U16 getFPGAP12PumpTachCount( void ); + +void setFPGAP24Enabled( BOOL enable ); +void setFPGAP24PWM( U16 pwm ); + +S16 getFPGAM1RawPressure( void ); +S16 getFPGAM1RawTemperature( void ); +U08 getFPGAM1ReadCount( void ); + +S16 getFPGAM3RawPressure( void ); +S16 getFPGAM3RawTemperature( void ); +U08 getFPGAM3ReadCount( void ); + +S16 getFPGAP8RawPressure( void ); +S16 getFPGAP8RawTemperature( void ); +U08 getFPGAP8ReadCount( void ); + +S16 getFPGAP13RawPressure( void ); +S16 getFPGAP13RawTemperature( void ); +U08 getFPGAP13ReadCount( void ); + +S16 getFPGAP17RawPressure( void ); +S16 getFPGAP17RawTemperature( void ); +U08 getFPGAP17ReadCount( void ); + +S16 getFPGAX1RawPressure( void ); +S16 getFPGAX1RawTemperature( void ); +U08 getFPGAX1ReadCount( void ); + +S16 getFPGAX2RawPressure( void ); +S16 getFPGAX2RawTemperature( void ); +U08 getFPGAX2ReadCount( void ); + +S16 getFPGAX3RawPressure( void ); +S16 getFPGAX3RawTemperature( void ); +U08 getFPGAX3ReadCount( void ); + +S16 getFPGAX4RawPressure( void ); +S16 getFPGAX4RawTemperature( void ); +U08 getFPGAX4ReadCount( void ); + +S16 getFPGAX5RawPressure( void ); +S16 getFPGAX5RawTemperature( void ); +U08 getFPGAX5ReadCount( void ); + +U32 getFPGAP23Temperature( void ); +U32 getFPGAP22Temperature( void ); + +U08 getFPGAP25FloaterState( void ); + +U16 getFPGAFlowP16( void ); +U16 getFPGAFlowP16Temp( void ); +U16 getFPGAFlowP7( void ); +U16 getFPGAFlowP7Temp( void ); + +void setFPGAP9Control( U08 control ); +void setFPGAP9Address( U16 address ); +void setFPGAP9Data( U32 data ); +void setFPGAP18Control( U08 control ); +void setFPGAP18Address( U16 address ); +void setFPGAP18Data( U32 data ); + +void setFPGAP9Reset( void ); +void clearFPGAP9Reset( void ); +void setFPGAP9InitEnable( void ); +void clearFPGAP9InitEnable( void ); +void setFPGAP9WriteEnable( void ); +void clearFPGAP9WriteEnable( void ); +void setFPGAP9ReadEnable( void ); +void clearFPGAP9ReadEnable( void ); + +void setFPGAP18Reset( void ); +void clearFPGAP18Reset( void ); +void setFPGAP18InitEnable( void ); +void clearFPGAP18InitEnable( void ); +void setFPGAP18WriteEnable( void ); +void clearFPGAP18WriteEnable( void ); +void setFPGAP18ReadEnable( void ); +void clearFPGAP18ReadEnable( void ); + +U08 getFPGAP9ReadCount( void ); +U08 getFPGAP9ErrorCount( void ); +U16 getFPGAP9Conductivity( void ); +U16 getFPGAP9Temperature( void ); +U32 getFPGAP9Data( void ); + +U08 getFPGAP18ReadCount( void ); +U08 getFPGAP18ErrorCount( void ); +U16 getFPGAP18Conductivity( void ); +U16 getFPGAP18Temperature( void ); +U32 getFPGAP18Data( void ); + +void setFPGAP40PumpEnable( BOOL enable ); +void setFPGAP40PumpPWM( U16 pwm ); +U16 getFPGAP40PumpPWM( void ); +U16 getFPGAP40PumpTachCount( void ); + +/**@}*/ + +#endif Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/FpgaRO.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/FpgaRO.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Services/Interrupts.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Services/Interrupts.c (.../Interrupts.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -5,7 +5,7 @@ #include "sci.h" #include "sys_dma.h" -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" #include "Comm.h" #include "Interrupts.h" #include "FPGA.h" Index: firmware/App/Services/Messaging.c =================================================================== diff -u -r051cd0430ef8342bd606115c98871e26dc24acf1 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/Messaging.c (.../Messaging.c) (revision 051cd0430ef8342bd606115c98871e26dc24acf1) +++ firmware/App/Services/Messaging.c (.../Messaging.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -1,4 +1,5 @@ +#include #include // for memcpy() #include "Compatible.h" @@ -8,13 +9,12 @@ #include "FluidPump.h" #include "Level.h" #include "Messaging.h" -#include "ModeWaterGen.h" -#include "ModeWaterPreGen.h" +#include "ModeGenPermeate.h" #include "OperationModes.h" #include "PAL.h" #include "Pressure.h" #include "ROPump.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "Temperature.h" #include "Utilities.h" #include "Valves.h" @@ -41,16 +41,16 @@ static const COMM_BUFFER_T tdResponseBuffers[ NUM_OF_COMM_BUFFERS ] = { COMM_BUFFER_NOT_USED, ///< CAN message boxes start at 1 so we will not use this buffer - COMM_BUFFER_OUT_CAN_RO_ALARM, ///< Buffer for responding to incoming TD alarm messages - COMM_BUFFER_OUT_CAN_RO_ALARM, ///< Buffer for responding to incoming DD alarm messages + COMM_BUFFER_OUT_CAN_FP_ALARM, ///< Buffer for responding to incoming TD alarm messages + COMM_BUFFER_OUT_CAN_FP_ALARM, ///< Buffer for responding to incoming DD alarm messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing RO alarm messages so no response buffer - COMM_BUFFER_OUT_CAN_RO_ALARM, ///< Buffer for responding to incoming UI alarm messages - COMM_BUFFER_OUT_CAN_RO_2_DD, ///< Buffer for responding to incoming DD to RO messages + COMM_BUFFER_OUT_CAN_FP_ALARM, ///< Buffer for responding to incoming UI alarm messages + COMM_BUFFER_OUT_CAN_FP_2_DD, ///< Buffer for responding to incoming DD to RO messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing RO to DD messages so no response buffer - COMM_BUFFER_OUT_CAN_RO_BROADCAST, ///< Buffer for responding to incoming TD broadcast messages - COMM_BUFFER_OUT_CAN_RO_BROADCAST, ///< Buffer for responding to incoming DD broadcast messages + COMM_BUFFER_OUT_CAN_FP_BROADCAST, ///< Buffer for responding to incoming TD broadcast messages + COMM_BUFFER_OUT_CAN_FP_BROADCAST, ///< Buffer for responding to incoming DD broadcast messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing RO broadcast messages so no response buffer - COMM_BUFFER_OUT_CAN_RO_BROADCAST, ///< Buffer for responding to incoming UI broadcast messages + COMM_BUFFER_OUT_CAN_FP_BROADCAST, ///< Buffer for responding to incoming UI broadcast messages COMM_BUFFER_OUT_CAN_PC, ///< Buffer for responding to incoming PC to RO messages COMM_BUFFER_NOT_USED, ///< Buffer for outgoing RO to PC messages so no response buffer }; @@ -94,7 +94,7 @@ { MSG_ID_FP_CONDUCTIVITY_ERROR_COUNT_OVERRIDE_REQUEST, &testConductivitySensorErrorCounterOverride }, { MSG_ID_FP_TEMPERATURE_OVERRIDE_REQUEST, &testMeasuredTemperatureOverride }, { MSG_ID_DD_FP_START_STOP_CMD_REQUEST, &handleGenerateWaterRequestMsg }, -{ MSG_ID_FP_PRE_GEN_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testPreGenWaterDataPublishIntervalOverride }, +{ MSG_ID_FP_PRE_GEN_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testPreGenDataPublishIntervalOverride }, { MSG_ID_FP_SET_OPERATION_MODE_REQUEST, &testSetOperationMode }, { MSG_ID_FP_TEMPERATURE_SENSOR_PUBLISH_INTERVAL_OVERRIDE_REQUEST, &testTemperatureSensorsDataPublishIntervalOverride }, }; @@ -222,7 +222,7 @@ msg.hdr.payloadLen = 0; // serialize and queue the message for transmit on broadcast channel - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_RO_BROADCAST, ACK_NOT_REQUIRED ); + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_FP_BROADCAST, ACK_NOT_REQUIRED ); return result; } @@ -382,7 +382,7 @@ memset( payloadPtr, 0, sizeof( U32) * 3 ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_RO_ALARM, ACK_REQUIRED ); + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_FP_ALARM, ACK_REQUIRED ); return result; } @@ -410,7 +410,7 @@ memcpy( payloadPtr, &alarm, sizeof( U32 ) ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_RO_ALARM, ACK_REQUIRED ); + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_FP_ALARM, ACK_REQUIRED ); return result; } @@ -439,7 +439,7 @@ memcpy( payloadPtr, &alarm, sizeof( U32 ) ); // serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_RO_ALARM, ACK_REQUIRED ); + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_FP_ALARM, ACK_REQUIRED ); return result; } @@ -455,7 +455,7 @@ * @param dat2 Second data associated with event * @return TRUE if msg successfully queued for transmit, FALSE if not *************************************************************************/ -BOOL sendEvent( RO_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ) +BOOL sendEvent( FP_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ) { BOOL result; MESSAGE_T msg; @@ -475,7 +475,7 @@ memcpy( &msg.payload, &eventStruct, sizeof( EVENT_PAYLOAD_T ) ); // Serialize the message (w/ sync, CRC, and appropriate CAN padding) and add serialized message data to appropriate comm buffer - result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_RO_BROADCAST, ACK_NOT_REQUIRED ); + result = serializeMessage( msg, COMM_BUFFER_OUT_CAN_FP_BROADCAST, ACK_NOT_REQUIRED ); return result; } Index: firmware/App/Services/Messaging.h =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Services/Messaging.h (.../Messaging.h) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Services/Messaging.h (.../Messaging.h) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -3,7 +3,7 @@ #define __MESSAGING_H__ #include "FPCommon.h" -#include "RODefs.h" +#include "FPDefs.h" #include "MessageSupport.h" #include "MsgQueues.h" @@ -41,7 +41,7 @@ BOOL broadcastAlarmCleared( U32 alarm ); BOOL broadcastAlarmConditionCleared( U32 alarm ); -BOOL sendEvent( RO_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ); +BOOL sendEvent( FP_EVENT_ID_T event, EVENT_DATA_T dat1, EVENT_DATA_T dat2 ); void handleUITDResetInServiceModeRequest( MESSAGE_T* message ); BOOL handleSetROOperationMode( MESSAGE_T *message ); Index: firmware/App/Services/SystemCommFP.c =================================================================== diff -u --- firmware/App/Services/SystemCommFP.c (revision 0) +++ firmware/App/Services/SystemCommFP.c (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,313 @@ + + +#include // For memcpy() + +#include "can.h" +#include "sci.h" +#include "sys_dma.h" + +#include "Comm.h" +#include "Interrupts.h" +#include "Messaging.h" +#include "OperationModes.h" +#include "SystemCommFP.h" +#include "Timers.h" +#include "Utilities.h" + +/** + * @addtogroup SystemCommFP + * @{ + */ + +// ********** private definitions ********** + +#define DD_COMM_TIMEOUT_IN_MS 1000 ///< DD has not checked in for this much time + +#define MAX_COMM_CRC_FAILURES 5 ///< Maximum number of CRC errors within window period before alarm +#define MAX_COMM_CRC_FAILURE_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< CRC error window + +#define MAX_FPGA_CLOCK_SPEED_ERRORS 3 ///< maximum number of FPGA clock speed errors within window period before alarm +#define MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS (10 * SEC_PER_MIN * MS_PER_SECOND) ///< FPGA clock speed error window + +/// Array of out-going CAN buffers. +const COMM_BUFFER_T CAN_OUT_BUFFERS[ NUM_OF_CAN_OUT_BUFFERS ] = +{ + COMM_BUFFER_OUT_CAN_FP_ALARM, + COMM_BUFFER_OUT_CAN_FP_2_DD, + COMM_BUFFER_OUT_CAN_FP_BROADCAST, + COMM_BUFFER_OUT_CAN_PC +}; + +/// Array of in-coming CAN buffers. +const COMM_BUFFER_T CAN_IN_BUFFERS[ NUM_OF_CAN_IN_BUFFERS ] = +{ + COMM_BUFFER_IN_CAN_TD_ALARM, + COMM_BUFFER_IN_CAN_DD_ALARM, + COMM_BUFFER_IN_CAN_UI_ALARM, + COMM_BUFFER_IN_CAN_DD_2_FP, + COMM_BUFFER_IN_CAN_TD_BROADCAST, + COMM_BUFFER_IN_CAN_DD_BROADCAST, + COMM_BUFFER_IN_CAN_UI_BROADCAST, + COMM_BUFFER_IN_CAN_PC, +}; + +// ********** private data ********** + +static volatile BOOL fpIsOnlyCANNode = TRUE; ///< Flag indicating whether FP is alone on CAN bus. +static volatile BOOL ddIsCommunicating = FALSE; ///< Has DD sent a message since last check +static U32 timeOfLastDDCheckIn = 0; ///< Last time DD checked in +static volatile BOOL uiIsCommunicating = FALSE; ///< Has UI sent a message since last check +static U32 timeOfLastUICheckIn = 0; ///< Last time UI checked in +static volatile BOOL uiDidCommunicate = FALSE; ///< Has UI every sent a message + +// ********** private function prototypes ********** + + +/*********************************************************************//** + * @brief + * The initSystemCommFP function initializes the system communication unit + * for the FP firmware. + * @details \b Inputs: none + * @details \b Outputs: SystemComm unit initialized. + * @return none + *************************************************************************/ +void initSystemCommFP( void ) +{ + // Initialize common system comm unit + initSystemComm(); + + // Initialize bad message CRC time windowed count + initTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC, MAX_COMM_CRC_FAILURES, MAX_COMM_CRC_FAILURE_WINDOW_MS ); + + // Initialize FPGA clock speed error time windowed count + initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR, MAX_FPGA_CLOCK_SPEED_ERRORS, MAX_FPGA_CLOCK_SPEED_ERROR_WINDOW_MS); +} + +/*********************************************************************//** + * @brief + * The checkInFromDD function checks in the DD with the TD - indicating that + * the DD is communicating. + * @details \b Inputs: none + * @details \b Outputs: ddIsCommunicating, timeOfLastDDCheckIn + * @return none + *************************************************************************/ +void checkInFromDD( void ) +{ + ddIsCommunicating = TRUE; + timeOfLastDDCheckIn = getMSTimerCount(); + + if ( TRUE == isAlarmActive( ALARM_ID_TD_DD_COMM_TIMEOUT ) ) + { + clearAlarmCondition( ALARM_ID_TD_DD_COMM_TIMEOUT ); + } +} + +/*********************************************************************//** + * @brief + * The checkInFromUI function checks in the UI with the TD - indicating that + * the UI is communicating. + * @details \b Inputs: none + * @details \b Outputs: uiIsCommunicating, timeOfLastUICheckIn, uiDidCommunicate + * @return none + *************************************************************************/ +void checkInFromUI( void ) +{ + if ( FALSE == uiDidCommunicate ) + { // Start DD check-in timer when UI first communicates + timeOfLastDDCheckIn = getMSTimerCount(); + } + + uiIsCommunicating = TRUE; + timeOfLastUICheckIn = getMSTimerCount(); + uiDidCommunicate = TRUE; +} + +/*********************************************************************//** + * @brief + * The isDDCommunicating function determines whether the DD is communicating + * with the TD. + * @details \b Inputs: ddIsCommunicating + * @details \b Outputs: none + * @return TRUE if DD is communicating, FALSE if not + *************************************************************************/ +BOOL isDDCommunicating( void ) +{ + return ddIsCommunicating; +} + +/*********************************************************************//** + * @brief + * The isOnlyCANNode function determines whether the TD is the only node + * currently on the CAN bus. + * @details \b Inputs: tdIsOnlyCANNode + * @details \b Outputs: none + * @return TRUE if TD is only node on CAN bus, FALSE if not + *************************************************************************/ +BOOL isOnlyCANNode( void ) +{ + return fpIsOnlyCANNode; +} + +/*********************************************************************//** + * @brief + * The setOnlyCANNode function sets whether the TD is the only node + * currently on the CAN bus. + * @details \b Inputs: none + * @details \b Outputs: tdIsOnlyCANNode + * @param only Flag indicating whether the TD is the only node on the CAN bus. + * @return none + *************************************************************************/ +void setOnlyCANNode( BOOL only ) +{ + fpIsOnlyCANNode = only; +} + +/*********************************************************************//** + * @brief + * The clearCANXmitBuffers function clears all CAN transmit buffers. + * @details \b Inputs: CAN_OUT_BUFFERS[] + * @details \b Outputs: CAN transmit buffers cleared. + * @return none + *************************************************************************/ +void clearCANXmitBuffers( void ) +{ + U32 i; + + for ( i = 0; i < NUM_OF_CAN_OUT_BUFFERS; i++ ) + { + clearBuffer( getOutBufferID( i ) ); + } +} + +/*********************************************************************//** + * @brief + * The checkForCommTimeouts function checks for sub-system communication + * timeout errors. + * @details \b Alarm: ALARM_ID_TD_UI_COMM_TIMEOUT if UI no longer communicating. + * @details \b Alarm: ALARM_ID_TD_DD_COMM_TIMEOUT if DD no longer communicating. + * @details \b Inputs: timeOfLastDDCheckIn, timeOfLastUICheckIn + * @details \b Outputs: none + * @return none + *************************************************************************/ +void checkForCommTimeouts( void ) +{ + if ( TRUE == uiDidCommunicate ) + { + FP_OP_MODE_T opMode = getCurrentOperationMode(); + + if ( TRUE == didTimeout( timeOfLastDDCheckIn, DD_COMM_TIMEOUT_IN_MS ) ) + { +#ifndef RUN_WITHOUT_DD + // Only alarm on DG comm loss while in the treatment workflow + /*if ( RO_MODE_PRET == opMode || RO_MODE_TREA == opMode || RO_MODE_POST == opMode ) + { + activateAlarmNoData( ALARM_ID_TD_DD_COMM_TIMEOUT ); + // we don't want to keep thinking DG is in a useful mode - set it to fault mode until DG is able to report its' true mode status +// setDGOpMode( DG_MODE_FAUL, 0 ); + } + else // Otherwise clear the alarm + { + clearAlarmCondition( ALARM_ID_TD_DD_COMM_TIMEOUT ); + } + ddIsCommunicating = FALSE; + */ +#endif + } + } +} + +/*********************************************************************//** + * @brief + * The checkTooManyBadMsgCRCs function checks for too many bad message CRCs + * within a set period of time. + * @note Assumed function is being called when a new bad CRC is detected. + * @details \b Alarm: ALARM_ID_TD_COMM_TOO_MANY_BAD_CRCS if too many (5) bad + * CRCs detected in the last 10 minutes. + * @details \b Inputs: none + * @details \b Outputs: none + * @return none + *************************************************************************/ +void checkTooManyBadMsgCRCs( void ) +{ + if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_BAD_MSG_CRC ) ) + { + SET_ALARM_WITH_1_U32_DATA( ALARM_ID_FP_COMM_TOO_MANY_BAD_CRCS, (U32)ALARM_SOURCE_FP ); + } +} + +/*********************************************************************//** + * @brief + * The getInBufferID function gets the incoming communication buffer ID for + * a given buffer index. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer index is invalid. + * @details \b Inputs: CAN_IN_BUFFERS[] + * @details \b Outputs: none + * @param idx incoming buffer index (e.g. 0 indicates first incoming buffer) + * @return ID of buffer associated with given incoming buffer index + *************************************************************************/ +COMM_BUFFER_T getInBufferID( U32 idx ) +{ + COMM_BUFFER_T result = COMM_BUFFER_NOT_USED; + + // validate given index + if ( idx < NUM_OF_CAN_IN_BUFFERS ) + { + result = CAN_IN_BUFFERS[ idx ]; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_FP_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX1, idx ) + } + + return result; +} + +/*********************************************************************//** + * @brief + * The getOutBufferID function gets the outgoing communication buffer ID for + * a given buffer index. + * @details \b Alarm: ALARM_ID_TD_SOFTWARE_FAULT if given buffer index is invalid. + * @details \b Inputs: CAN_OUT_BUFFERS[] + * @details \b Outputs: none + * @param idx outgoing buffer index (e.g. 0 indicates first outgoing buffer) + * @return ID of buffer associated with given outgoing buffer index + *************************************************************************/ +COMM_BUFFER_T getOutBufferID( U32 idx ) +{ + COMM_BUFFER_T result = COMM_BUFFER_NOT_USED; + + // validate given index + if ( idx < NUM_OF_CAN_OUT_BUFFERS ) + { + result = CAN_OUT_BUFFERS[ idx ]; + } + else + { + SET_ALARM_WITH_2_U32_DATA( ALARM_ID_TD_SOFTWARE_FAULT, SW_FAULT_ID_SYSTEM_COMM_INVALID_BUFFER_INDEX2, idx ) + } + + return result; + +} + +/*********************************************************************//** + * @brief + * The processReceivedMessage function processes a given message. + * @details \b Inputs: none + * @details \b Outputs: message processed + * @param message Pointer to the message to process. + * @return none + *************************************************************************/ +void processReceivedMessage( MESSAGE_T *message ) +{ + // Handle any messages from other sub-systems + handleIncomingMessage( message ); +} + + +/************************************************************************* + * TEST SUPPORT FUNCTIONS + *************************************************************************/ + + +/**@}*/ Index: firmware/App/Services/SystemCommFP.h =================================================================== diff -u --- firmware/App/Services/SystemCommFP.h (revision 0) +++ firmware/App/Services/SystemCommFP.h (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -0,0 +1,46 @@ + +#ifndef __SYSTEM_COMM_TD_H__ +#define __SYSTEM_COMM_TD_H__ + +#include "FPCommon.h" +#include "CommBuffers.h" +#include "MsgQueues.h" +#include "SystemComm.h" + +/** + * @defgroup SystemCommRO SystemCommRO + * @brief System communication unit. Manages incoming and outgoing CAN frames. + * + * @addtogroup SystemCommRO + * @{ + */ + +// ********** public definitions ********** + +#define MAX_MSG_SEQ_NO 0x7FFF ///< Maximum sequence number for Denali message (then wraps to 1). +#define MIN_MSG_SEQ_NO 0x0001 ///< Minimum sequence number for Denali message. + +#define NUM_OF_CAN_OUT_BUFFERS 4 ///< Number of CAN buffers for transmit +#define NUM_OF_CAN_IN_BUFFERS 8 ///< Number of CAN buffers for receiving + +// ********** public function prototypes ********** + +void initSystemCommFP( void ); +void processReceivedMessage( MESSAGE_T *message ); + +COMM_BUFFER_T getInBufferID( U32 idx ); +COMM_BUFFER_T getOutBufferID( U32 idx ); + +void checkForCommTimeouts( void ); +void checkTooManyBadMsgCRCs( void ); +void checkInFromDD( void ); +void checkInFromUI( void ); + +BOOL isDDCommunicating( void ); +BOOL isOnlyCANNode( void ); +void setOnlyCANNode( BOOL only ); +void clearCANXmitBuffers( void ); + +/**@}*/ + +#endif /* APP_SERVICES_SYSTEMCOMMRO_H_ */ Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/SystemCommRO.c'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 410afd26b3ae5e372310c696c82f58c59235e10d refers to a dead (removed) revision in file `firmware/App/Services/SystemCommRO.h'. Fisheye: No comparison available. Pass `N' to diff? Index: firmware/App/Tasks/TaskBG.c =================================================================== diff -u -r99498a5bab0a1f4c706376feceadc66df6d1c22e -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 99498a5bab0a1f4c706376feceadc66df6d1c22e) +++ firmware/App/Tasks/TaskBG.c (.../TaskBG.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -1,6 +1,6 @@ #include "FPCommon.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "TaskTimer.h" #include "Timers.h" #include "WatchdogMgmt.h" Index: firmware/App/Tasks/TaskGeneral.c =================================================================== diff -u -r0d2351b8e47e40fdcd706ed7b7ac1379b69a20ef -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 0d2351b8e47e40fdcd706ed7b7ac1379b69a20ef) +++ firmware/App/Tasks/TaskGeneral.c (.../TaskGeneral.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -1,9 +1,9 @@ -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" #include "Messaging.h" #include "OperationModes.h" #include "ROPump.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "TaskGeneral.h" //#include "Voltages.h" // TODO uncomment #include "WatchdogMgmt.h" Index: firmware/App/Tasks/TaskPriority.c =================================================================== diff -u -r340b6bedc5aac2ad47364ade48a842f00b12b8fe -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 340b6bedc5aac2ad47364ade48a842f00b12b8fe) +++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -5,7 +5,7 @@ #include "InternalADC.h" #include "Level.h" #include "Pressure.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "TaskPriority.h" #include "Temperature.h" #include "Valves.h" Index: firmware/source/sys_main.c =================================================================== diff -u -rd5574e12aa9638c933d11b9bee8d5cf024864440 -r410afd26b3ae5e372310c696c82f58c59235e10d --- firmware/source/sys_main.c (.../sys_main.c) (revision d5574e12aa9638c933d11b9bee8d5cf024864440) +++ firmware/source/sys_main.c (.../sys_main.c) (revision 410afd26b3ae5e372310c696c82f58c59235e10d) @@ -47,6 +47,8 @@ /* Include Files */ +#include +#include #include "sys_common.h" /* USER CODE BEGIN (1) */ @@ -61,28 +63,28 @@ #include "system.h" #include "sys_dma.h" -#include "AlarmMgmtRO.h" +#include "AlarmMgmtFP.h" #include "CommBuffers.h" #include "Conductivity.h" #include "DDInterface.h" -#include "FilterFlush.h" #include "Flow.h" -#include "FpgaRO.h" +#include "FpgaFP.h" #include "InternalADC.h" #include "Interrupts.h" #include "Level.h" -#include "MembraneFlush.h" #include "ModeFault.h" #include "ModeInitPOST.h" +#include "ModeGenPermeateDefeatured.h" +#include "ModePreGenPermeateDefeatured.h" +#include "ModeGenPermeate.h" +#include "ModePreGenPermeate.h" #include "ModeStandby.h" -#include "ModeWaterGen.h" -#include "ModeWaterPreGen.h" #include "MsgQueues.h" #include "OperationModes.h" #include "Pressure.h" #include "ROPump.h" #include "SafetyShutdown.h" -#include "SystemCommRO.h" +#include "SystemCommFP.h" #include "TaskBG.h" #include "Temperature.h" #include "Timers.h" @@ -167,11 +169,11 @@ initSemaphores(); initTimers(); initSafetyShutdown(); - initAlarmMgmtRO(); + initAlarmMgmtFP(); initWatchdogMgmt(); initCommBuffers(); initMsgQueues(); - initSystemCommRO(); + initSystemCommFP(); initTestConfigs(); // Services @@ -200,11 +202,12 @@ // Modes initOperationModes(); - initGenWaterMode(); + initGenPermeateMode(); initStandbyMode(); initInitAndPOSTMode(); initFaultMode(); - initPreGenWMode(); + initPreGenPMode(); + initFilterFlush(); } /*************************************************************************