Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r0dec8744af40d0c87a6d7cd1923920c1c2bd1d2f -rf308cc4c35eab630ebbbde405cfe47d049afeafb --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 0dec8744af40d0c87a6d7cd1923920c1c2bd1d2f) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision f308cc4c35eab630ebbbde405cfe47d049afeafb) @@ -76,7 +76,9 @@ 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 being reported. + U08 fpgaRev; ///< Reg 1. FPGA revision being reported. + U08 fpgaRevLab; ///< Reg 2. FPGA lab rev number. + U08 fpgaRevMajor; ///< Reg 3. FPGA minor rev number. } FPGA_HEADER_T; // read only on FPGA typedef struct // TODO - add all sensor readings to this structure per FPGA register map @@ -215,7 +217,6 @@ * @details * Inputs : none * Outputs : FPGA module initialized. - * @param none * @return none *************************************************************************/ void initFPGA( void ) @@ -332,7 +333,6 @@ * @details * Inputs : none * Outputs : fpga comm flags & counters reset - * @param none * @return none *************************************************************************/ static void resetFPGACommFlags( void ) @@ -353,7 +353,6 @@ * @details * Inputs : none * Outputs : fpgaReceiptCounter - * @param none * @return none *************************************************************************/ void signalFPGAReceiptCompleted( void ) @@ -389,7 +388,6 @@ * @details * Inputs : none * Outputs : fpgaReceiptCounter - * @param none * @return none *************************************************************************/ void signalFPGATransmitCompleted( void ) @@ -403,7 +401,6 @@ * @details * Inputs : fpgaState * Outputs : fpgaState - * @param none * @return none *************************************************************************/ void execFPGAIn( void ) @@ -457,7 +454,6 @@ * @details * Inputs : fpgaState * Outputs : fpgaState - * @param none * @return none *************************************************************************/ void execFPGAOut( void ) @@ -499,7 +495,6 @@ * @details * Inputs : none * Outputs : read command sent to FPGA - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReadHeaderState( void ) @@ -532,7 +527,6 @@ * @details * Inputs : none * Outputs : header register values updated - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveHeaderState( void ) @@ -585,7 +579,6 @@ * @details * Inputs : actuator set points * Outputs : actuator set points sent to FPGA - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAWriteAllActuatorsState( void ) @@ -637,7 +630,6 @@ * @details * Inputs : none * Outputs : sensor values updated - * @param none * @return next FPGA state *************************************************************************/ static FPGA_STATE_T handleFPGAReceiveAllSensorsState( void ) @@ -695,7 +687,6 @@ * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return passed, or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) @@ -727,7 +718,7 @@ * @details * Inputs : none * Outputs : # of bytes for next FPGA write command is set - * @param bytes2Transmit : # of bytes to be transmitted via DMA to the FPGA. + * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA. * @return none *************************************************************************/ static void setupDMAForWriteCmd( U32 bytes2Transmit ) @@ -750,7 +741,6 @@ * @details * Inputs : none * Outputs : DMA write command to FPGA is initiated - * @param none * @return none *************************************************************************/ static void startDMAWriteCmd( void ) @@ -767,7 +757,7 @@ * @details * Inputs : none * Outputs : # of expected bytes for next FPGA write command response is set - * @param bytes2Receive : # of bytes expected to be transmitted via DMA from the FPGA. + * @param bytes2Receive number of bytes expected to be transmitted via DMA from the FPGA. * @return none *************************************************************************/ static void setupDMAForWriteResp( U32 bytes2Receive ) @@ -790,7 +780,6 @@ * @details * Inputs : none * Outputs : DMA write command response is ready to be received from the FPGA - * @param none * @return none *************************************************************************/ static void startDMAReceiptOfWriteResp( void ) @@ -807,7 +796,7 @@ * @details * Inputs : none * Outputs : # of bytes for next FPGA read command is set - * @param bytes2Transmit : # of bytes to be transmitted via DMA to the FPGA. + * @param bytes2Transmit number of bytes to be transmitted via DMA to the FPGA. * @return none *************************************************************************/ static void setupDMAForReadCmd( U32 bytes2Transmit ) @@ -830,7 +819,6 @@ * @details * Inputs : none * Outputs : DMA read command to FPGA is initiated - * @param none * @return none *************************************************************************/ static void startDMAReadCmd( void ) @@ -847,7 +835,7 @@ * @details * Inputs : none * Outputs : # of expected bytes for next FPGA read command response is set - * @param bytes2Receive : # of expected bytes to be transmitted via DMA from the FPGA. + * @param bytes2Receive number of expected bytes to be transmitted via DMA from the FPGA. * @return none *************************************************************************/ static void setupDMAForReadResp( U32 bytes2Receive ) @@ -870,7 +858,6 @@ * @details * Inputs : none * Outputs : DMA read command response is ready to be received from the FPGA - * @param none * @return none *************************************************************************/ static void startDMAReceiptOfReadResp( void ) @@ -887,7 +874,6 @@ * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return fpgaDiag *************************************************************************/ static void consumeUnexpectedData( void ) @@ -922,7 +908,7 @@ * @details * Inputs : none * Outputs : fpgaActuatorSetPoints.fpgaValveStates - * @param valveStates + * @param valveStates bit mask for the various valve states * @return none *************************************************************************/ void setFPGAValveStates( U16 valveStates ) @@ -937,7 +923,7 @@ * @details * Inputs : none * Outputs : fpgaActuatorSetPoints.fpgaDrainPumpSetSpeed - * @param drainPumpDAC + * @param drainPumpDAC DAC value to command for the drain pump * @return none *************************************************************************/ void setFPGADrainPumpSpeed( U08 drainPumpDAC ) @@ -955,7 +941,6 @@ * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return Id *************************************************************************/ U08 getFPGAId( void ) @@ -970,36 +955,35 @@ * @details * Inputs : fpgaHeader * Outputs : none - * @param none * @return Revision *************************************************************************/ U08 getFPGARev( void ) { return fpgaHeader.fpgaRev; } +/*********************************************************************//** + * @brief + * The getFPGAVersions function gets the FPGA version numbers. + * @details + * Inputs : fpgaHeader + * Outputs : none + * @return none + *************************************************************************/ +void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) +{ + *Id = fpgaHeader.fpgaId; + *Maj = fpgaHeader.fpgaRev; + *Min = fpgaHeader.fpgaRevMajor; + *Lab = fpgaHeader.fpgaRevLab; +} + /*********************************************************************//** * @brief - * The getFPGAStatus function gets the version read from the diagnostic register \n - * of the FPGA. - * @details - * Inputs : fpgaHeader - * Outputs : none - * @param none - * @return fpgaHeader.fpgaStatus - *************************************************************************/ -U16 getFPGAStatus( void ) -{ - return 0;//fpgaSensorReadings.fpgaStatus; -} - -/*********************************************************************//** - * @brief * The getFPGALoadCellA1 function gets the latest load cell A 1 reading. * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last load cell A 1 reading *************************************************************************/ U32 getFPGALoadCellA1( void ) @@ -1013,7 +997,6 @@ * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last load cell A 2 reading *************************************************************************/ U32 getFPGALoadCellA2( void ) @@ -1027,7 +1010,6 @@ * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last load cell B 1 reading *************************************************************************/ U32 getFPGALoadCellB1( void ) @@ -1041,7 +1023,6 @@ * @details * Inputs : fpgaSensorReadings * Outputs : none - * @param none * @return last load cell B 2 reading *************************************************************************/ U32 getFPGALoadCellB2( void ) @@ -1056,7 +1037,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaValveStates * Outputs : none - * @param none * @return last valve states reading *************************************************************************/ U16 getFPGAValveStates( void ) @@ -1070,7 +1050,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaROFlowRate * Outputs : none - * @param none * @return last RO flow rate reading *************************************************************************/ U16 getFPGAROPumpFlowRate( void ) @@ -1084,7 +1063,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaDrainPumpSpeed * Outputs : none - * @param none * @return last drain pump speed reading *************************************************************************/ U16 getFPGADrainPumpSpeed( void ) @@ -1099,7 +1077,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTPiTemp * Outputs : none - * @param none * @return last primary heater inlet temperature reading *************************************************************************/ U32 getFPGATPiTemp( void ) @@ -1114,7 +1091,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTPoTemp * Outputs : none - * @param none * @return last primary heater outlet temperature reading *************************************************************************/ U32 getFPGATPoTemp( void ) @@ -1129,7 +1105,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaCD1Temp * Outputs : none - * @param none * @return last conductivity sensor 1 outlet temperature reading *************************************************************************/ U32 getFPGACD1Temp( void ) @@ -1144,7 +1119,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaCD2Temp * Outputs : none - * @param none * @return last conductivity sensor 2 outlet temperature reading *************************************************************************/ U32 getFPGACD2Temp( void ) @@ -1159,7 +1133,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaRTDErrorCnt * Outputs : none - * @param none * @return Last error count of the RTD conductivity sensors *************************************************************************/ U08 getFPGARTDErrorCount( void ) @@ -1174,7 +1147,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaRTDReadCnt * Outputs : none - * @param none * @return Last read count of the RTC conductivity sensors *************************************************************************/ U08 getFPGARTDReadCount( void ) @@ -1189,7 +1161,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTHDoTemp * Outputs : none - * @param none * @return Last redundant sensor outlet temperature reading *************************************************************************/ U32 getFPGATHDoTemp( void ) @@ -1204,7 +1175,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTHDoErrorCnt * Outputs : none - * @param none * @return Last redundant sensor outlet temperature error count *************************************************************************/ U08 getFPGATHDoErrorCount( void ) @@ -1218,7 +1188,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTHDoReadCnt * Outputs : none - * @param none * @return Last redundant sensor outlet temperature error count reading *************************************************************************/ U08 getFPGATHDoReadCount( void ) @@ -1233,7 +1202,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTDiTemp * Outputs : none - * @param none * @return last primary heater outlet temperature reading *************************************************************************/ U32 getFPGATDiTemp( void ) @@ -1248,7 +1216,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTDiErrorCnt * Outputs : none - * @param none * @return Last dialysate inlet error count *************************************************************************/ U08 getFPGATDiErrorCount( void ) @@ -1263,7 +1230,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTDiReadCnt * Outputs : none - * @param none * @return Last dialysate inlet read count *************************************************************************/ U08 getFPGATDiReadCount( void ) @@ -1278,7 +1244,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterIntTemp * Outputs : none - * @param none * @return last primary heater temperature reading *************************************************************************/ U16 getFPGAPrimaryHeaterTemp( void ) @@ -1293,7 +1258,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterFlags * Outputs : none - * @param none * @return Last primary heater internal temperature sensor flag read *************************************************************************/ U08 getFPGAPrimaryHeaterFlags( void ) @@ -1308,7 +1272,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterReadCnt * Outputs : none - * @param none * @return Last primary heater internal temperature sensor read count *************************************************************************/ U08 getFPGAPrimaryHeaterReadCount( void ) @@ -1323,7 +1286,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterIntTemp * Outputs : none - * @param none * @return last trimmer heater temperature reading *************************************************************************/ U16 getFPGATrimmerHeaterTemp( void ) @@ -1338,7 +1300,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterFlags * Outputs : none - * @param none * @return Last trimmer heater internal temperature flags read *************************************************************************/ U08 getFPGATrimmerHeaterFlags( void ) @@ -1353,7 +1314,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterReadCnt * Outputs : none - * @param none * @return Last trimmer heater internal temperature read count *************************************************************************/ U08 getFPGATrimmerHeaterReadCount( void ) @@ -1368,7 +1328,6 @@ * @details * Inputs : fpgaSensorReadings.fpgaPrimaryHeaterIntJunctionTemp * Outputs : none - * @param none * @return Last primary cold junction temperature *************************************************************************/ U16 getFPGAPRimaryColdJunctionTemp ( void ) @@ -1383,14 +1342,69 @@ * @details * Inputs : fpgaSensorReadings.fpgaTrimmerHeaterIntJunctionTemp * Outputs : none - * @param none * @return Last trimmer cold junction temperature *************************************************************************/ U16 getFPGATrimmerColdJunctionTemp ( void ) { return fpgaSensorReadings.fpgaTrimmerHeaterIntJunctionTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGAAccelAxes function gets the accelerometer axis readings. \n + * Axis readings are in ADC counts. 0.004 g per LSB. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @param x Populate this param with X axis reading + * @param y Populate this param with Y axis reading + * @param z Populate this param with Z axis reading + * @return none + *************************************************************************/ +void getFPGAAccelAxes( S16 *x, S16 *y, S16 *z ) +{ + *x = (S16)fpgaSensorReadings.accelX; + *y = (S16)fpgaSensorReadings.accelY; + *z = (S16)fpgaSensorReadings.accelZ; } +/*********************************************************************//** + * @brief + * The getFPGAAccelMaxes function gets the maximum accelerometer axis readings. \n + * from last FPGA read (every 10ms). \n + * Axis readings are in ADC counts. 0.004 g per LSB. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @param x Populate this param with maximum X axis reading + * @param y Populate this param with maximum Y axis reading + * @param z Populate this param with maximum Z axis reading + * @return none + *************************************************************************/ +void getFPGAAccelMaxes( S16 *xmax, S16*ymax, S16*zmax ) +{ + *xmax = (S16)fpgaSensorReadings.accelXMax; + *ymax = (S16)fpgaSensorReadings.accelYMax; + *zmax = (S16)fpgaSensorReadings.accelZMax; +} + +/*********************************************************************//** + * @brief + * The getFPGAAccelStatus function gets the accelerometer reading count \n + * and error register values. + * @details + * Inputs : fpgaSensorReadings + * Outputs : none + * @param cnt Populate this param with latest sample counter value + * @param err Populate this param with latest error + * @return none + *************************************************************************/ +void getFPGAAccelStatus( U16 *cnt, U16 *err ) +{ + *cnt = fpgaSensorReadings.accelSampleCounter; + *err = fpgaSensorReadings.accelFaultRegister; +} + /************************************************************************* * @brief * The getFPGACPiReadCount function gets inlet water conductivity sensor