Index: firmware/.cproject
===================================================================
diff -u -rdd3356035996866e5db7678d352f933fc22ad789 -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/.cproject (.../.cproject) (revision dd3356035996866e5db7678d352f933fc22ad789)
+++ firmware/.cproject (.../.cproject) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -10,36 +10,33 @@
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -108,35 +114,33 @@
+
-
-
+
+
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
@@ -150,38 +154,46 @@
-
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
+
+
+
+
Index: firmware/.project
===================================================================
diff -u -r2656aa6e11f4804dad57791321808fc0e925567e -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/.project (.../.project) (revision 2656aa6e11f4804dad57791321808fc0e925567e)
+++ firmware/.project (.../.project) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -18,6 +18,7 @@
+ org.eclipse.rtsc.xdctools.buildDefinitions.XDC.xdcNature
com.ti.ccstudio.core.ccsNature
org.eclipse.cdt.core.cnature
org.eclipse.cdt.managedbuilder.core.managedBuildNature
Index: firmware/App/Controllers/Valves.c
===================================================================
diff -u
--- firmware/App/Controllers/Valves.c (revision 0)
+++ firmware/App/Controllers/Valves.c (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -0,0 +1,301 @@
+/**********************************************************************//**
+ *
+ * Copyright (c) 2020-2020 Diality Inc. - All Rights Reserved.
+ *
+ * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
+ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
+ *
+ * @file Valves.c
+ *
+ * @date 21-Apr-2020
+ * @author P. Montazemi
+ *
+ * @brief Valves source file.
+ *
+ **************************************************************************/
+
+#include "AlarmMgmt.h"
+#include "FPGA.h"
+#include "OperationModes.h"
+#include "SystemCommMessages.h"
+#include "TaskPriority.h"
+#include "Timers.h"
+#include "Valves.h"
+
+/**
+ * @addtogroup DGValves
+ * @{
+ */
+
+// ********** private definitions **********
+
+//#define DEENERGIZED 0
+//#define ENERGIZED 1
+//#define INIT_VALVE_STATE 0b0000000000000000
+
+/// Default publication interval for valve states
+#define VALVES_STATE_PUB_INTERVAL ( 500 / TASK_PRIORITY_INTERVAL ) ///< interval (ms/task time) at which the valves state is published on the CAN bus
+
+// ********** private data **********
+
+static U32 valveStatePublicationTimerCounter = 0; ///< used to schedule valve state publication to CAN bus
+
+static OVERRIDE_U32_T valveStatePublishInterval = { VALVES_STATE_PUB_INTERVAL, VALVES_STATE_PUB_INTERVAL, 0, 0 }; ///< interval (in ms/task interval) at which to publish valves state to CAN bus
+static OVERRIDE_F32_T valves[ NUM_OF_VALVE_IDS ]; ///< Obtained state from valves
+
+// ********** private function prototypes **********
+
+static void checkValves( void );
+static void publishValvesState( void );
+static DATA_GET_PROTOTYPE( U32, getPublishValvesStateInterval );
+
+/**@}*/
+
+/*********************************************************************//**
+ * @brief
+ * The initValves function initializes the Valves module.
+ * @details
+ * Inputs : none
+ * Outputs : Valves module initialized.
+ * @return none
+ *************************************************************************/
+void initValves( void )
+{
+ setFPGAValveStates( INIT_VALVES_STATES )
+ valvesStatePublicationTimerCounter = 0;
+ valvesSelfTestTimerCount = 0;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The execValves function executes the valve driver.
+ * @details
+ * Inputs : valvesState
+ * Outputs : valvesState
+ * @return none
+ *************************************************************************/
+void execValves( void )
+{
+ setFPGAValveStates( valvesStates );
+
+ // publish valves states on interval
+ publishValvesStates();
+}
+
+/*********************************************************************//**
+ * @brief
+ * The checkValveState function checks the validity of the requested valve state.
+ * @details
+ * Inputs : valveID, valveState
+ * Outputs : none
+ * @return none
+ *************************************************************************/
+static void checkValveState( void )
+{
+ /* TODO: compare the requested valve state to the allowable valves \n
+ * states for a given valve;
+ * - if checks, return True
+ * - if not, return false
+ */
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getPublishValveStateInterval function gets the valves states \n
+ * publication interval.
+ * @details
+ * Inputs : valvesStatePublishInterval
+ * Outputs : none
+ * @return the current valves states publication interval (in task intervals).
+ *************************************************************************/
+U32 getPublishValvesStatesInterval( void )
+{
+ U32 result = valvesStatesPublishInterval.data;
+
+ if ( OVERRIDE_KEY == valvesStatesPublishInterval.override )
+ {
+ result = valvesStatesPublishInterval.ovData;
+ }
+
+ return result;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getValveState function gets the current valve state for given valve ID.
+ * @details
+ * Inputs : valveState
+ * Outputs : none
+ * @return the current valve state for given valve ID.
+ *************************************************************************/
+F32 getValveState( U32 valveID )
+{
+ BOOL valveState = DEENERGIZED;
+
+ if ( valveID < NUM_OF_VALVE_IDS )
+ {
+ if ( OVERRIDE_KEY == valves[ valveID ].override )
+ {
+ valveState = valves[ valveID ].ovData;
+ }
+ else
+ {
+ valveState = valves[ valveID ].data;
+ }
+ }
+ else
+ {
+ activateAlarmNoData( ALARM_ID_VALVE_STATE_ERROR );
+ }
+
+ return valveState;
+}
+
+/*********************************************************************//**
+ *
+ * @brief
+ * The publishValvesState function publishes DG valves state at the \n
+ * set interval.
+ * @details
+ * Inputs : valvesStatePublicationTimerCounter
+ * Outputs : DG valves states are published to CAN bus
+ * @return none
+ *************************************************************************/
+static void publishValvesStates( void )
+{
+ // publish valve state on interval
+ if ( ++valvesStatesPublicationTimerCounter >= getPublishValvesStatesInterval() )
+ {
+ broadcastValvesState( getFPGAValveStates() );
+ valvesStatesPublicationTimerCounter = 0;
+ }
+}
+
+/*********************************************************************//**
+ * @brief
+ * The execPressuresTest function executes the state machine for the \n
+ * Pressures self test.
+ * @details
+ * Inputs : none
+ * Outputs : none
+ * @return the current state of the Pressures self test.
+ *************************************************************************/
+SELF_TEST_STATUS_T execPressuresTest( void )
+{
+ SELF_TEST_STATUS_T result = SELF_TEST_STATUS_FAILED;
+
+ // TODO - implement self test(s)
+
+ return result;
+}
+
+/**@}*/
+
+
+/*************************************************************************
+ * TEST SUPPORT FUNCTIONS
+ *************************************************************************/
+
+
+/*********************************************************************//**
+ * @brief
+ * The testSetPressuresDataPublishIntervalOverride function overrides the \n
+ * pressure and occlusion data publish interval.
+ * @details
+ * Inputs : none
+ * Outputs : pressuresDataPublishInterval
+ * @param value : override pressure and occlusion data publish interval with (in ms)
+ * @return TRUE if override successful, FALSE if not
+ *************************************************************************/
+BOOL testSetPressuresDataPublishIntervalOverride( U32 value )
+{
+ BOOL result = FALSE;
+
+ if ( TRUE == isTestingActivated() )
+ {
+ U32 intvl = value / TASK_PRIORITY_INTERVAL;
+
+ result = TRUE;
+ pressuresDataPublishInterval.ovData = intvl;
+ pressuresDataPublishInterval.override = OVERRIDE_KEY;
+ }
+
+ return result;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The testResetPressuresDataPublishIntervalOverride function resets the override \n
+ * of the pressure and occlusion data publish interval.
+ * @details
+ * Inputs : none
+ * Outputs : pressuresDataPublishInterval
+ * @return TRUE if override reset successful, FALSE if not
+ *************************************************************************/
+BOOL testResetPressuresDataPublishIntervalOverride( void )
+{
+ BOOL result = FALSE;
+
+ if ( TRUE == isTestingActivated() )
+ {
+ result = TRUE;
+ pressuresDataPublishInterval.override = OVERRIDE_RESET;
+ pressuresDataPublishInterval.ovData = pressuresDataPublishInterval.ovInitData;
+ }
+
+ return result;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The testSetDGPressureSensorOverride function overrides the value of the \n
+ * specified pressure sensor with a given value.
+ * Inputs : none
+ * Outputs : pressures[]
+ * @param sensor : ID of pressure sensor to override for
+ * @param value : override value for the given pressure sensor ID
+ * @return TRUE if override successful, FALSE if not
+ *************************************************************************/
+BOOL testSetDGPressureSensorOverride( U32 sensor, F32 value )
+{
+ BOOL result = FALSE;
+
+ if ( sensor < NUM_OF_PRESSURE_SENSORS )
+ {
+ if ( TRUE == isTestingActivated() )
+ {
+ result = TRUE;
+ pressures[ sensor ].ovData = value;
+ pressures[ sensor ].override = OVERRIDE_KEY;
+ }
+ }
+
+ return result;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The testResetDGPressureSensorOverride function resets the override of the \n
+ * specified DG pressure sensor.
+ * @details
+ * Inputs : none
+ * Outputs : pressures[]
+ * @param value : ID of sensor to reset override pressure for
+ * @return TRUE if override successful, FALSE if not
+ *************************************************************************/
+BOOL testResetDGPressureSensorOverride( U32 sensor )
+{
+ BOOL result = FALSE;
+
+ if ( sensor < NUM_OF_PRESSURE_SENSORS )
+ {
+ if ( TRUE == isTestingActivated() )
+ {
+ result = TRUE;
+ pressures[ sensor ].override = OVERRIDE_RESET;
+ pressures[ sensor ].ovData = pressures[ sensor ].ovInitData;
+ }
+ }
+
+ return result;
+}
Index: firmware/App/Controllers/Valves.h
===================================================================
diff -u
--- firmware/App/Controllers/Valves.h (revision 0)
+++ firmware/App/Controllers/Valves.h (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -0,0 +1,84 @@
+/**************************************************************************
+ *
+ * Copyright (c) 2020-2020 Diality Inc. - All Rights Reserved.
+ *
+ * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN
+ * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER.
+ *
+ * @file Valves.h
+ *
+ * @date 21-Apr-2020
+ * @author P. Montazemi
+ *
+ * @brief Valves header file.
+ *
+ **************************************************************************/
+
+#ifndef __VALVES_H__
+#define __VALVES_H__
+
+#include "DGCommon.h"
+
+/**
+ * @defgroup Valves Valves
+ * @brief Valves driver module.
+ * Controls valves.
+ *
+ * @addtogroup Valves
+ * @{
+ */
+
+// ********** public definitions **********
+
+/// Enumeration of valve states
+typedef enum ValveStates
+{
+ VALVE_STATE_OPEN = 0, ///< Open valve state
+ VALVE_STATE_CLOSED, ///< Closed valve state
+ VALVE_STATE_FILL, ///< Fill valve state
+ VALVE_STATE_NOFILL, ///< No Fill valve state
+ VALVE_STATE_DRAIN, ///< Drain valve state
+ VALVE_STATE_RECIRCULATE, ///< Recirculate valve state
+ VALVE_STATE_R1_C_TO_NO, ///< Reservoir 1 Common to Normally Open valve state
+ VALVE_STATE_R1_C_TO_NC, ///< Reservoir 1 Common to Normally Closed valve state
+ VALVE_STATE_R2_C_TO_NO, ///< Reservoir 2 Common to Normally Open valve state
+ VALVE_STATE_R2_C_TO_NC, ///< Reservoir 2 Common to Normally Closed valve state
+ NUM_OF_VALVE_STATES ///< Number of valve states
+} VALVE_STATES_T;
+
+/// Enumeration of valve IDs
+typedef enum ValveIds
+{
+ VRF = 0, ///< Valve Reservoir Fill
+ VRI, ///< Valve Reservoir Inlet
+ VRD, ///< Valve Reservoir Drain
+ VRO, ///< Valve Reservoir Outlet
+ VPO, ///< Valve Pressure Outlet
+ VBF, ///< Valve Bypass Filter
+ VRC, ///< Valve Recirculate
+ VDR, ///< Valve Drain
+ VPI, ///< Valve Pressure inlet
+ VSP, ///< Valve Sampling Port
+ VPD, ///< Valve Production Drain
+ NUM_OF_VALVE_IDS ///< Number of valves
+} VALVE_IDS_T;
+
+// ********** public function prototypes **********
+
+void initValves( void ); // Initialize the valves module
+void execValves( void ); // Execute the valves driver
+
+// SELF_TEST_STATUS_T execValvesTest( void ); // TODO: Add back in for POST on DG valves
+
+BOOL setValveState( VALVE_IDS_T valveID, VALVE_STATES_T valveState ); // Set valveID's state to valveState
+
+DATA_ARRAY_GET_PROTOTYPE( VALVE_STATES_T, getValveState, valveID ); // Get valveID's state
+
+BOOL testSetValveStatePublishIntervalOverride( U32 value );
+BOOL testResetValveStatePublishIntervalOverride( void );
+BOOL testSetValveStateOverride( U32 valve, F32 state );
+BOOL testResetValveStateOverride( U32 valveID );
+
+/**@}*/
+
+#endif /* __VALVES_H__ */
Index: firmware/App/Services/FPGA.c
===================================================================
diff -u -r4fa5628781e2b420cad6afc42a4b754dd484b997 -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 4fa5628781e2b420cad6afc42a4b754dd484b997)
+++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -1,4 +1,4 @@
-/**************************************************************************
+/**********************************************************************//**
*
* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
*
@@ -68,45 +68,88 @@
#define MAX_COMM_ERROR_RETRIES 5
+#define MASK_OFF_U32_MSB 0x00FFFFFF
+#define DRAIN_PUMP_DAC_SHIFT_BITS 4
+
// FPGA Sensors Record
#pragma pack(push,1)
typedef struct
{
U08 fpgaId;
U08 fpgaRev;
- U16 fpgaADC1Control;
- U08 fpagDiag;
- U08 reserved1;
- U16 fpagADC2Control;
- U16 fpagRTDControl;
} FPGA_HEADER_T; // read only on FPGA
typedef struct // TODO - add all sensor readings to this structure per FPGA register map
{
- U08 fpgaId;
- U08 fpgaRev;
- U16 fpgaADC1Control;
+ U32 fpgaLCA1;
+ U32 fpgaLCA2;
+ U32 fpgaADC1Temp;
+
+ U32 fpgaLCB1;
+ U32 fpgaLCB2;
+ U32 fpgaADC2Temp;
+
+ U32 fpgaCD1;
+ U32 fpgaCD2;
+ U32 fpgaTPiTemp;
+ U32 fpgaTPoTemp;
+ U32 fpgaRTDTemp;
+
+ U32 fpgaTHDo;
+ U32 fpgaTHDoTemp;
+
+ U32 fpgaTDi;
+ U32 fpgaTDiTemp;
+
+ U32 fpgaCPoEc;
+ U32 fpgaCPoTds;
+
U16 fpgaStatus;
+
+ U16 fpgaPrimaryHeaterIntTemp;
+ U16 fpgaPrimaryHeaterIntJunctionTemp;
+ U16 fpgaTrimmerHeaterIntTemp;
+ U16 fpgaTrimmerHeaterIntJunctionTemp;
+
+ U16 fpgaDrainPumpSpeed;
+ U16 fpgaROFlowRate;
+ U16 fpgaValveStates;
+
U08 fpgaIOErrorCntProcessor;
U08 fpgaIOErrorCntPC;
- U32 reserved1;
- U32 reserved2;
- U32 reserved3;
- U32 reserved4;
- U32 reserved5;
- U32 reserved6;
- U32 reserved7;
- U32 reserved8;
- U32 reserved9;
- U32 LCA1;
- U32 LCA2;
- U32 LCB1;
- U32 LCB2;
+ U08 fpgaADC1ReadCnt;
+ U08 fpgaADC1ErrorCnt;
+ U08 fpgaADC2ReadCnt;
+ U08 fpgaADC2ErrorCnt;
+ U08 fpgaRTDReadCnt;
+ U08 fpgaRTDErrorCnt;
+ U08 fpgaTHDoReadCnt;
+ U08 fpgaTHDoErrorCnt;
+ U08 fpgaTDiReadCnt;
+ U08 fpgaTDiErrorCnt;
+ U08 fpgaPrimaryHeaterFlags;
+ U08 fpgaPrimaryHeaterReadCnt;
+ U08 fpgaTrimmerHeaterFlags;
+ U08 fpgaTrimmerHeaterReadCnt;
+ U08 fpgaCPoTempConf;
+ U08 fpgaCPoSanityData;
+ U08 fpgaCPoReadCnt;
+ U08 fpgaCPoErrorCnt;
} DG_FPGA_SENSORS_T;
-typedef struct // TODO - add all actuator set points to this structure per FPGA register map
+typedef struct
{
- U08 bloodValveSetState;
+ U16 fpgaCPoProbeType;
+ U16 fpgaDrainPumpSetSpeed;
+ U16 fpgaValveStates;
+ U08 fpgaID;
+ U08 fpgaRev;
+ U08 fpgaADC1Control;
+ U08 fpgaDiag;
+ U08 fpgaADC2Control;
+ U08 fpgaRTDControl;
+ U08 fpgaTHDoControl;
+ U08 fpgaTDiControl;
} FPGA_ACTUATORS_T;
#pragma pack(pop)
@@ -138,7 +181,7 @@
// FPGA data
static FPGA_HEADER_T fpgaHeader;
-static DG_FPGA_SENSORS_T fpgaSensorReadings;
+static DG_FPGA_SENSORS_T fpgaSensorReadings;
static FPGA_ACTUATORS_T fpgaActuatorSetPoints;
// ********** private function prototypes **********
@@ -160,8 +203,8 @@
static void consumeUnexpectedData( void );
-/*************************************************************************
- * @brief initFPGA
+/*********************************************************************//**
+ * @brief
* The initFPGA function initializes the FPGA module.
* @details
* Inputs : none
@@ -175,6 +218,7 @@
memset( &fpgaHeader, 0, sizeof(FPGA_HEADER_T) );
memset( &fpgaSensorReadings, 0, sizeof(DG_FPGA_SENSORS_T) );
memset( &fpgaActuatorSetPoints, 0, sizeof(FPGA_ACTUATORS_T) );
+ fpgaActuatorSetPoints.fpgaValveStates = 0x015F; // TODO - temporary init per Blaine while testing - remove later.
// initialize fpga comm buffers
memset( &fpgaWriteCmdBuffer, 0, FPGA_WRITE_CMD_BUFFER_LEN );
@@ -271,8 +315,8 @@
consumeUnexpectedData();
}
-/*************************************************************************
- * @brief resetFPGACommFlags
+/*********************************************************************//**
+ * @brief
* The resetFPGACommFlags function resets the various fpga comm flags and \n
* counters.
* @details
@@ -292,8 +336,8 @@
fpgaReceiptCounter = 0;
}
-/*************************************************************************
- * @brief signalFPGAReceiptCompleted
+/*********************************************************************//**
+ * @brief
* The signalFPGAReceiptCompleted function increments a counter to indicate \n
* that another DMA receipt from the FPGA has completed.
* @details
@@ -328,8 +372,8 @@
}
}
-/*************************************************************************
- * @brief signalFPGATransmitCompleted
+/*********************************************************************//**
+ * @brief
* The signalFPGATransmitCompleted function increments a counter to indicate \n
* that another DMA transmit to the FPGA has completed.
* @details
@@ -343,8 +387,8 @@
fpgaTransmitCounter++;
}
-/*************************************************************************
- * @brief execFPGAIn
+/*********************************************************************//**
+ * @brief
* The execFPGA function manages incoming data exchanges with the FPGA.
* @details
* Inputs : fpgaState
@@ -397,8 +441,8 @@
resetFPGACommFlags();
}
-/*************************************************************************
- * @brief execFPGAOut
+/*********************************************************************//**
+ * @brief
* The execFPGAOut function manages outgoing data exchanges with the FPGA.
* @details
* Inputs : fpgaState
@@ -438,8 +482,8 @@
}
}
-/*************************************************************************
- * @brief handleFPGAReadHeaderState
+/*********************************************************************//**
+ * @brief
* The handleFPGAReadHeaderState function handles the FPGA state where \n
* the read header registers command is sent to the FPGA.
* @details
@@ -455,7 +499,7 @@
// construct read command to read 3 registers starting at address 0
fpgaReadCmdBuffer[ 0 ] = FPGA_READ_CMD_CODE;
- fpgaReadCmdBuffer[ 1 ] = 0x00; // start at FPGA address 0
+ fpgaReadCmdBuffer[ 1 ] = 0x06; // start at FPGA address 6
fpgaReadCmdBuffer[ 2 ] = 0x00;
fpgaReadCmdBuffer[ 3 ] = sizeof(FPGA_HEADER_T);
crc = crc16( fpgaReadCmdBuffer, FPGA_READ_CMD_HDR_LEN );
@@ -471,8 +515,8 @@
return result;
}
-/*************************************************************************
- * @brief handleFPGAReceiveHeaderState
+/*********************************************************************//**
+ * @brief
* The handleFPGAReceiveHeaderState function handles the FPGA state \n
* where the header registers read response should be ready to take in.
* @details
@@ -524,8 +568,8 @@
return result;
}
-/*************************************************************************
- * @brief handleFPGAWriteAllActuatorsState
+/*********************************************************************//**
+ * @brief
* The handleFPGAWriteAllActuatorsState function handles the FPGA state \n
* where the bulk write command is sent to the FPGA.
* @details
@@ -541,7 +585,7 @@
// construct bulk write command to write actuator data registers starting at address 3 (TODO - change address later)
fpgaWriteCmdBuffer[ 0 ] = FPGA_WRITE_CMD_CODE;
- fpgaWriteCmdBuffer[ 1 ] = 0x08; // start at FPGA address 8
+ fpgaWriteCmdBuffer[ 1 ] = 0x00; // start at FPGA address 0
fpgaWriteCmdBuffer[ 2 ] = 0x00;
fpgaWriteCmdBuffer[ 3 ] = sizeof(FPGA_ACTUATORS_T);
memcpy( &( fpgaWriteCmdBuffer[ FPGA_WRITE_CMD_HDR_LEN ] ), &fpgaActuatorSetPoints, sizeof( FPGA_ACTUATORS_T ) );
@@ -572,8 +616,8 @@
return result;
}
-/*************************************************************************
- * @brief handleFPGAReceiveAllSensorsState
+/*********************************************************************//**
+ * @brief
* The handleFPGAReceiveAllSensorsState function handles the FPGA state \n
* where the bulk read response should be ready to parse.
* @details
@@ -631,8 +675,8 @@
return result;
}
-/*************************************************************************
- * @brief execFPGATest
+/*********************************************************************//**
+ * @brief
* The execFPGATest function executes the FPGA self-test. \n
* @details
* Inputs : fpgaHeader
@@ -662,8 +706,8 @@
return result;
}
-/*************************************************************************
- * @brief setupDMAForWriteCmd
+/*********************************************************************//**
+ * @brief
* The setupDMAForWriteCmd function sets the byte count for the next DMA \n
* write command to the FPGA.
* @details
@@ -685,8 +729,8 @@
}
}
-/*************************************************************************
- * @brief startDMAWriteCmd
+/*********************************************************************//**
+ * @brief
* The startDMAWriteCmd function initiates the DMA transmit for the next \n
* DMA write command to the FPGA.
* @details
@@ -702,8 +746,8 @@
setSCI2DMATransmitInterrupt();
}
-/*************************************************************************
- * @brief setupDMAForWriteResp
+/*********************************************************************//**
+ * @brief
* The setupDMAForWriteResp function sets the expected byte count for the \n
* next DMA write command response from the FPGA.
* @details
@@ -725,8 +769,8 @@
}
}
-/*************************************************************************
- * @brief startDMAReceiptOfWriteResp
+/*********************************************************************//**
+ * @brief
* The startDMAReceiptOfWriteResp function initiates readiness of the DMA \n
* receiver for the next DMA write command response from the FPGA.
* @details
@@ -742,8 +786,8 @@
setSCI2DMAReceiveInterrupt();
}
-/*************************************************************************
- * @brief setupDMAForReadCmd
+/*********************************************************************//**
+ * @brief
* The setupDMAForReadCmd function sets the byte count for the next DMA \n
* read command to the FPGA.
* @details
@@ -765,8 +809,8 @@
}
}
-/*************************************************************************
- * @brief startDMAReadCmd
+/*********************************************************************//**
+ * @brief
* The startDMAReadCmd function initiates the DMA transmit for the next \n
* DMA read command to the FPGA.
* @details
@@ -782,8 +826,8 @@
setSCI2DMATransmitInterrupt();
}
-/*************************************************************************
- * @brief setupDMAForReadResp
+/*********************************************************************//**
+ * @brief
* The setupDMAForReadResp function sets the expected byte count for the \n
* next DMA read command response from the FPGA.
* @details
@@ -805,8 +849,8 @@
}
}
-/*************************************************************************
- * @brief startDMAReceiptOfReadResp
+/*********************************************************************//**
+ * @brief
* The startDMAReceiptOfReadResp function initiates readiness of the DMA \n
* receiver for the next DMA read command response from the FPGA.
* @details
@@ -822,8 +866,75 @@
setSCI2DMAReceiveInterrupt();
}
-/*************************************************************************
- * @brief getFPGAId
+/*********************************************************************//**
+ * @brief
+ * The consumeUnexpectedData function checks to see if a byte is sitting in \n
+ * the SCI2 received data register.
+ * @details
+ * Inputs : fpgaHeader
+ * Outputs : none
+ * @param none
+ * @return fpgaDiag
+ *************************************************************************/
+static void consumeUnexpectedData( void )
+{
+ // clear any errors
+ sciRxError( scilinREG );
+ // if a byte is pending read, read it
+ if ( sciIsRxReady( scilinREG ) != 0 )
+ {
+ sciReceiveByte( scilinREG );
+ }
+}
+
+/*********************************************************************//**
+ * @brief
+ * The setFPGAValveStates function sets the DG valve states with a 16-bit \n
+ * set of states - one bit per valve, with a 1 meaning "energized" and a 0 \n
+ * meaning "de-energized". The bit positions for these bit states are as follows: \n
+ * 0 - VRf.\n
+ * 1 - VRi.\n
+ * 2 - VRd.\n
+ * 3 - VRo.\n
+ * 4 - VPo.\n
+ * 5 - VBf.\n
+ * 6 - VRc.\n
+ * 7 - VDr.\n
+ * 8 - VPi.\n
+ * 9 - VSP.\n
+ * 10- VPd.\n
+ * 11..15 - reserved or unused.
+ * @details
+ * Inputs : none
+ * Outputs : fpgaActuatorSetPoints.fpgaValveStates
+ * @param valveStates
+ * @return none
+ *************************************************************************/
+void setFPGAValveStates( U16 valveStates )
+{
+ fpgaActuatorSetPoints.fpgaValveStates = valveStates;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The setFPGADrainPumpSpeed function sets the drain pump target speed. \n
+ * The drain pump DAC value should be set to 1 count for each 12.94 RPM desired.
+ * @details
+ * Inputs : none
+ * Outputs : fpgaActuatorSetPoints.fpgaDrainPumpSetSpeed
+ * @param drainPumpDAC
+ * @return none
+ *************************************************************************/
+void setFPGADrainPumpSpeed( U08 drainPumpDAC )
+{
+ U16 dac = (U16)drainPumpDAC & MASK_OFF_MSB;
+
+ dac = dac << DRAIN_PUMP_DAC_SHIFT_BITS;
+ fpgaActuatorSetPoints.fpgaDrainPumpSetSpeed = dac;
+}
+
+/*********************************************************************//**
+ * @brief
* The getFPGAId function gets the version read from the Id register \n
* of the FPGA.
* @details
@@ -837,8 +948,8 @@
return fpgaHeader.fpgaId;
}
-/*************************************************************************
- * @brief getFPGARev
+/*********************************************************************//**
+ * @brief
* The getFPGARev function gets the revision read from the Rev register \n
* of the FPGA.
* @details
@@ -852,8 +963,8 @@
return fpgaHeader.fpgaRev;
}
-/*************************************************************************
- * @brief getFPGAStatus
+/*********************************************************************//**
+ * @brief
* The getFPGAStatus function gets the version read from the diagnostic register \n
* of the FPGA.
* @details
@@ -867,8 +978,8 @@
return fpgaSensorReadings.fpgaStatus;
}
-/*************************************************************************
- * @brief getFPGALoadCellA1
+/*********************************************************************//**
+ * @brief
* The getFPGALoadCellA1 function gets the latest load cell A 1 reading.
* @details
* Inputs : fpgaSensorReadings
@@ -878,11 +989,11 @@
*************************************************************************/
U32 getFPGALoadCellA1( void )
{
- return fpgaSensorReadings.LCA1;
+ return ( fpgaSensorReadings.fpgaLCA1 & MASK_OFF_U32_MSB );
}
-/*************************************************************************
- * @brief getFPGALoadCellA2
+/*********************************************************************//**
+ * @brief
* The getFPGALoadCellA2 function gets the latest load cell A 2 reading.
* @details
* Inputs : fpgaSensorReadings
@@ -892,11 +1003,11 @@
*************************************************************************/
U32 getFPGALoadCellA2( void )
{
- return fpgaSensorReadings.LCA2;
+ return ( fpgaSensorReadings.fpgaLCA2 & MASK_OFF_U32_MSB );
}
-/*************************************************************************
- * @brief getFPGALoadCellB1
+/*********************************************************************//**
+ * @brief
* The getFPGALoadCellB1 function gets the latest load cell B 1 reading.
* @details
* Inputs : fpgaSensorReadings
@@ -906,11 +1017,11 @@
*************************************************************************/
U32 getFPGALoadCellB1( void )
{
- return fpgaSensorReadings.LCB1;
+ return ( fpgaSensorReadings.fpgaLCB1 & MASK_OFF_U32_MSB );
}
-/*************************************************************************
- * @brief getFPGALoadCellB2
+/*********************************************************************//**
+ * @brief
* The getFPGALoadCellB2 function gets the latest load cell B 2 reading.
* @details
* Inputs : fpgaSensorReadings
@@ -920,27 +1031,108 @@
*************************************************************************/
U32 getFPGALoadCellB2( void )
{
- return fpgaSensorReadings.LCB2;
+ return ( fpgaSensorReadings.fpgaLCB2 & MASK_OFF_U32_MSB );
}
-/*************************************************************************
- * @brief consumeUnexpectedData
- * The consumeUnexpectedData function checks to see if a byte is sitting in \n
- * the SCI2 received data register.
+/*********************************************************************//**
+ * @brief
+ * The getFPGAValveStates function gets the latest sensed valve states. \n
+ * See setFPGAValveStates for valve state bit positions.
* @details
- * Inputs : fpgaHeader
+ * Inputs : fpgaSensorReadings.fpgaValveStates
* Outputs : none
* @param none
- * @return fpgaDiag
+ * @return last valve states reading
*************************************************************************/
-static void consumeUnexpectedData( void )
+U16 getFPGAValveStates( void )
{
- // clear any errors
- sciRxError( scilinREG );
- // if a byte is pending read, read it
- if ( sciIsRxReady( scilinREG ) != 0 )
- {
- sciReceiveByte( scilinREG );
- }
+ return fpgaSensorReadings.fpgaValveStates;
}
+/*********************************************************************//**
+ * @brief
+ * The getFPGAROPumpFlowRate function gets the latest RO flow rate.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaROFlowRate
+ * Outputs : none
+ * @param none
+ * @return last RO flow rate reading
+ *************************************************************************/
+U16 getFPGAROPumpFlowRate( void )
+{
+ return fpgaSensorReadings.fpgaROFlowRate;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getFPGADrainPumpSpeed function gets the latest sensed drain pump speed.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaDrainPumpSpeed
+ * Outputs : none
+ * @param none
+ * @return last drain pump speed reading
+ *************************************************************************/
+U16 getFPGADrainPumpSpeed( void )
+{
+ return fpgaSensorReadings.fpgaDrainPumpSpeed;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getFPGATPiTemp function gets the latest primary heater inlet \n
+ * temperature reading.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaTPiTemp
+ * Outputs : none
+ * @param none
+ * @return last primary heater inlet temperature reading
+ *************************************************************************/
+U32 getFPGATPiTemp( void )
+{
+ return ( fpgaSensorReadings.fpgaTPiTemp & MASK_OFF_U32_MSB );
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getFPGATPoTemp function gets the latest primary heater outlet \n
+ * temperature reading.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaTPoTemp
+ * Outputs : none
+ * @param none
+ * @return last primary heater outlet temperature reading
+ *************************************************************************/
+U32 getFPGATPoTemp( void )
+{
+ return ( fpgaSensorReadings.fpgaTPoTemp & MASK_OFF_U32_MSB );
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getFPGAPrimaryHeaterTemp function gets the latest primary heater \n
+ * internal temperature reading.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterIntTemp
+ * Outputs : none
+ * @param none
+ * @return last primary heater temperature reading
+ *************************************************************************/
+U16 getFPGAPrimaryHeaterTemp( void )
+{
+ return fpgaSensorReadings.fpgaPrimaryHeaterIntTemp;
+}
+
+/*********************************************************************//**
+ * @brief
+ * The getFPGATrimmerHeaterTemp function gets the latest trimmer heater \n
+ * internal temperature reading.
+ * @details
+ * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterIntTemp
+ * Outputs : none
+ * @param none
+ * @return last trimmer heater temperature reading
+ *************************************************************************/
+U16 getFPGATrimmerHeaterTemp( void )
+{
+ return fpgaSensorReadings.fpgaTrimmerHeaterIntTemp;
+}
Index: firmware/App/Services/FPGA.h
===================================================================
diff -u -r4fa5628781e2b420cad6afc42a4b754dd484b997 -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/App/Services/FPGA.h (.../FPGA.h) (revision 4fa5628781e2b420cad6afc42a4b754dd484b997)
+++ firmware/App/Services/FPGA.h (.../FPGA.h) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -1,4 +1,4 @@
-/**************************************************************************
+/**********************************************************************//**
*
* Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved.
*
@@ -32,10 +32,20 @@
void signalFPGAReceiptCompleted( void );
void signalFPGATransmitCompleted( void );
+void setFPGAValveStates( U16 valveStates );
+void setFPGADrainPumpSpeed( U08 drainPumpDAC );
+
U16 getFPGAStatus( void );
+U16 getFPGAValveStates( void );
+U16 getFPGAROPumpFlowRate( void );
+U16 getFPGADrainPumpSpeed( void );
U32 getFPGALoadCellA1( void );
U32 getFPGALoadCellA2( void );
U32 getFPGALoadCellB1( void );
U32 getFPGALoadCellB2( void );
+U32 getFPGATPiTemp( void );
+U32 getFPGATPoTemp( void );
+U16 getFPGAPrimaryHeaterTemp( void );
+U16 getFPGATrimmerHeaterTemp( void );
#endif
Index: firmware/App/Tasks/TaskPriority.c
===================================================================
diff -u -r8b56b0c617ac49536b8d53852b9621be873bade6 -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision 8b56b0c617ac49536b8d53852b9621be873bade6)
+++ firmware/App/Tasks/TaskPriority.c (.../TaskPriority.c) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -38,16 +38,18 @@
// monitor internal ADC channels
execInternalADC();
- // load cells monitor
+ // monitor load cells
execLoadCell();
+ // monitor valves
+ execValves();
+
// 2nd pass for FPGA
execFPGAOut();
// check in with watchdog manager
checkInWithWatchdogMgmt( TASK_PRIORITY );
// toggle GPIO to indicate priority task has executed
-// gioToggleBit( gioPORTB, 3 );
+ //gioToggleBit( gioPORTB, 3 );
}
-
Index: firmware/source/sys_main.c
===================================================================
diff -u -r8638b207699a3a48e3657e838e24ae838369c867 -rc8c60f543b53cd96008914a01145f5b08426903e
--- firmware/source/sys_main.c (.../sys_main.c) (revision 8638b207699a3a48e3657e838e24ae838369c867)
+++ firmware/source/sys_main.c (.../sys_main.c) (revision c8c60f543b53cd96008914a01145f5b08426903e)
@@ -50,20 +50,20 @@
#include "sys_common.h"
/* USER CODE BEGIN (1) */
-#include "system.h"
-#include "sys_dma.h"
#include "adc.h"
#include "can.h"
#include "etpwm.h"
#include "gio.h"
#include "mibspi.h"
-#include "sci.h"
#include "rti.h"
+#include "sci.h"
+#include "sys_dma.h"
+#include "system.h"
-#include "DGCommon.h"
#include "AlarmMgmt.h"
#include "CommBuffers.h"
#include "CPLD.h"
+#include "DGCommon.h"
#include "FPGA.h"
#include "InternalADC.h"
#include "MsgQueues.h"
@@ -74,6 +74,7 @@
#include "SystemComm.h"
#include "TaskBG.h"
#include "Timers.h"
+#include "Valves.h"
#include "WatchdogMgmt.h"
static void initProcessor( void );
@@ -93,7 +94,7 @@
/* USER CODE BEGIN (2) */
/* USER CODE END */
-int main(void)
+int main( void )
{
/* USER CODE BEGIN (3) */
@@ -163,6 +164,7 @@
initMsgQueues();
initSystemComm();
initReservoirs();
+ initValves();
initOperationModes();
}