Index: firmware/App/Services/FPGA.c =================================================================== diff -u -r6d3a38303c448c14f9f64781dd39cbf2ac0fceec -r3e9328290bdbc18a940935bd7f7c720ca8432b1d --- firmware/App/Services/FPGA.c (.../FPGA.c) (revision 6d3a38303c448c14f9f64781dd39cbf2ac0fceec) +++ firmware/App/Services/FPGA.c (.../FPGA.c) (revision 3e9328290bdbc18a940935bd7f7c720ca8432b1d) @@ -97,7 +97,7 @@ } FPGA_HEADER_T; // read only on FPGA /// FPGA sensors' readings struct. -typedef struct // TODO - add all sensor readings to this structure per FPGA register map +typedef struct { U32 fpgaLCA1; ///< Reg 256. ADC1 channel 0 - load cell A1 U32 fpgaLCB1; ///< Reg 260. ADC1 channel 1 - load cell B1 @@ -120,13 +120,8 @@ U32 fpgaTDi; ///< Reg 308. ADC TDi channel 0 - temperature U32 fpgaTDiTemp; ///< Reg 312. ADC TDi channel 1 - internal temperature -#ifndef ENABLE_DVT_BOARD U32 fpgaCPo; ///< Reg 316. CPo conductivity sensor value U32 fpgaCPi; ///< Reg 320. CPi conductivity sensor value -#else - U32 fpgaTHDi; ///< Reg 316. ADC THD channel 0 - temperature - U32 fpgaTHDiTemp; ///< Reg 320. ADC THD channel 1 - internal temperature -#endif U16 fpgaPrimaryHeaterIntTemp; ///< Reg 324. Primary heater temperature U16 fpgaPrimaryHeaterIntJunctionTemp; ///< Reg 326. Primary heater internal temperature @@ -162,7 +157,6 @@ U08 fpgaTrimmerHeaterFlags; ///< Reg 366. Trimmer heater flags U08 fpgaTrimmerHeaterReadCnt; ///< Reg 367. Trimmer heater read count -#ifndef ENABLE_DVT_BOARD U08 fpgaCPoFault; ///< Reg 368. CPo conductivity sensor fault U08 fpgaCPoReadCnt; ///< Reg 369. CPo conductivity sensor read count U08 fpgaCPoErrorCnt; ///< Reg 370. CPo conductivity sensor error count @@ -171,25 +165,17 @@ U08 fpgaCPiErrorCnt; ///< Reg 373. CPi conductivity sensor error count U08 fpgaCP1CP2Fault; ///< Reg 374. Concentrate pump fault register for CP1 and CP2 U08 fpgaReserved1; ///< Reg 375. Reserved -#else - U08 fpgaCPiCPoEmstatOutByte; ///< Reg 368. CPi/CPo Emstat output FIFO - U08 fpgaCPiCPoEmstatRxErrCount; ///< Reg 369. CPi/CPo Emstat receive error count - U16 fpgaCPiCPoEmstatTxFIFOCount; ///< Reg 370. CPi/CPo Emstat transmit FIFO count - U16 fpgaCPiCPoEmstatRxFIFOCount; ///< Reg 372. CPi/CPo Emstat receive FIFO count - U08 fpgaCP1CP2Fault; ///< Reg 374. Concentrate pump fault register for CP1 and CP2 - U08 fpgaDRPHallStatus; ///< Reg 375. Drain pump hall sensor status -#endif U16 fpgaValveStates; ///< Reg 376. Valves states U16 fpgaFanIn1Pulse; ///< Reg 378. Fan inlet 1 pulse time in 2.5 us resolution U16 fpgaFanOut1Pulse; ///< Reg 380. Fan outlet 1 pulse time in 2.5 us resolution - U08 fpgaEmstatOutByte; ///< Reg 382. Emstat output FIFO - data from the Emstat device - U08 fpgaEmstatRxErrorCount; ///< Reg 383. Number of receive errors since power-up - U16 fpgaEmstatTxFifoCount; ///< Reg 384. Number of bytes in the Emstat Tx FIFO buffer - U16 fpgaEmstatRxFifoCount; ///< Reg 386. Number of bytes in the Emstat Rx FIFO buffer - U16 fpgaCP1HallSense; ///< Reg 388. Concentrate pump CP1 hall sensor pulse width. - U16 fpgaCP2HallSense; ///< Reg 390. Concentrate pump CP2 hall sensor pulse width. + U08 fpgaCD1CD2EmstatOutByte; ///< Reg 382. Emstat output FIFO - data from the Emstat device + U08 fpgaCD1CD2EmstatRxErrorCount; ///< Reg 383. Number of receive errors since power-up + U16 fpgaCD1CD2EmstatTxFifoCount; ///< Reg 384. Number of bytes in the Emstat Tx FIFO buffer + U16 fpgaCD1CD2EmstatRxFifoCount; ///< Reg 386. Number of bytes in the Emstat Rx FIFO buffer + U16 fpgaCP1HallSense; ///< Reg 388. Concentrate pump CP1 hall sensor pulse width + U16 fpgaCP2HallSense; ///< Reg 390. Concentrate pump CP2 hall sensor pulse width U08 fpgaGPIO; ///< Reg 392. FGPA GPIO register U08 fpgaDummyByte2Addr; ///< Reg 393. Dummy byte address to maintain an even addressing scheme @@ -199,22 +185,17 @@ U16 fpgaFanOut2Pulse; ///< Reg 398. Fan outlet 2 pulse time in 2.5 resolution U16 fpgaFanIn3Pulse; ///< Reg 400. Fan inlet 3 pulse time in 2.5 resolution U16 fpgaFanOut3Pulse; ///< Reg 402. Fan outlet 3 pulse time in 2.5 resolution - U16 fpgaTimerCount_ms; ///< Reg 404. Internal FPGA timer count in ms. - + U16 fpgaTimerCountMS; ///< Reg 404. Internal FPGA timer count in milliseconds U16 fpgaADCVccInt; ///< Reg 406. Internal FPGA Vcc Voltage. - U16 fpgaADCVccAux; ///< Reg 408. Internal FPGA Vcc auxiliary voltage. - U16 fpgaADCVPVN; ///< Reg 410. Internal FPGA VPVN voltage. + U16 fpgaADCVccAux; ///< Reg 408. Internal FPGA Vcc auxiliary voltage + U16 fpgaADCVPVN; ///< Reg 410. Internal FPGA VPVN voltage - // DVT only + // DVT changes U08 fpgaBaroReadCount; ///< Reg 412. Barometric sensor read count U08 fpgaBaroErroCount; ///< Reg 413. Barometric sensor error count - // DVT only - - U16 fpgaDrainPumpSpeedFeedback; ///< Reg 414. Drain pump speed feedback. - U16 fpgaDrainPumpCurrentFeedback; ///< Reg 416. Drain pump current feedback. + U16 fpgaDrainPumpSpeedFeedback; ///< Reg 414. Drain pump speed feedback + U16 fpgaDrainPumpCurrentFeedback; ///< Reg 416. Drain pump current feedback U16 fpgaDialysateFlowRate; ///< Req 418. Dialysate flow rate measurement - - // DVT only U16 fpgaHeaterGateADC; ///< Reg 420. Heater gate ADC U16 fpgaHeaterGNDADC; ///< Reg 422. Heater ground ADC U08 fpgaHeater1ADCReadCount; ///< Reg 424. Heater 1 ADC read count @@ -229,9 +210,16 @@ U16 fpgaBaroPROMCRC; ///< Reg 440. Barometric sensor PROM CRC U32 fpgaBaroPressure; ///< Reg 442. Barometric sensor pressure value U32 fpgaBaroTemperature; ///< Reg 446. Barometric sensor temperature sensor - U08 fpgaTHDRTDReadCount; ///< Reg 450. THD RTD read count - U08 fpgaTHDRTDErrorCount; ///< Reg 451. THD RTD error count - // DVT only + U08 fpgaTHdRTDReadCount; ///< Reg 450. THD RTD read count + U08 fpgaTHdRTDErrorCount; ///< Reg 451. THD RTD error count + U32 fpgaTHdTemp; ///< Reg 452. THD channel 0 read data - temperature sensor + U32 fpgaTHdInternalTemp; ///< Reg 456. THD channel 1 read data - ADC internal temperature sensor + U08 fpgaCPiCPoEmstatOutByte; ///< Reg 460. CPi/CPo Emstat out byte + U08 fpgaCPiCPoEmstatRxErrCount; ///< Reg 461. CPi/CPo Emstat Rx error count + U16 fpgaCPiCPoEmstatTxFIFOCount; ///< Reg 462. CPi/CPo Emstat Tx FIFO count + U16 fpgaCPiCPoEmstatRxFIFOCount; ///< Reg 464. CPi/CPo Emstat Rx FIFO count + U16 fpgaPowerSupply2; ///< Reg 466. power supply 2 count + U16 fpgaOnBoardThermistor; ///< Reg 468. onboard thermistor } DG_FPGA_SENSORS_T; typedef struct @@ -248,13 +236,68 @@ U16 fpgaCP2StepSpeed; ///< Reg 26. Concentrate pump CP2 step speed register U08 fpgaCP2Control; ///< Reg 28. Concentrate pump CP2 control register U08 fpgaEmstatControl; ///< Reg 29. Emstat conductivity sensor control register + U16 fpgaVRfPWMLow; ///< Reg 30. VRf PWM low + U16 fpgaVRfPWMPeriod; ///< Reg 32. VRf PWM period + U16 fpgaVRiPWMLow; ///< Reg 34. VRi PWM low + U16 fpgaVRiPWMPeriod; ///< Reg 36. VRi PWM period + U16 fpgaVRdPWMLow; ///< Reg 38. VRd PWM low + U16 fpgaVRdPWMPeriod; ///< Reg 40. VRD PWM period + U16 fpgaVRoPWMLow; ///< Reg 42. VRo PWM low + U16 fpgaVRoPWMPeriod; ///< Reg 44. VRo PWM period + U16 fpgaVPoPWMLow; ///< Reg 46. VPo PWM low + U16 fpgaVPoPWMPeriod; ///< Reg 48. VPo PWM period + U16 fpgaVBfPWMLow; ///< Reg 50. VBf PWM low + U16 fpgaVBFPWMPeriod; ///< Reg 52. VBf PWM period + U16 fpgaVRcPWMLow; ///< Reg 54. VRc PWM low + U16 fpgaVRcPWMPeriod; ///< Reg 56. VRc PWM period + U16 fpgaVDrPWMLow; ///< Reg 58. VDr PWM Low + U16 fpgaVDrPWMPeriod; ///< Reg 60. VDr PWM period + U16 fpgaVPiPWMLow; ///< Reg 62. VPi PWM low + U16 fpgaVPiPWMPeriod; ///< Reg 64. VPi PWM period + U16 fpgaVSPPWMLow; ///< Reg 66. VSP PWM low + U16 fpgaVSPPWMPeriod; ///< Reg 68. VSP PWM period + U16 fpgaVRd1PWMLow; ///< Reg 70. VRd1 PWM low + U16 fpgaVRd1PWMPeriod; ///< Reg 72. VRd1 PWM period + U16 fpgaVRd2PWMLow; ///< Reg 74. VRd2 PWM low + U16 fpgaVRd2PWMPeriod; ///< Reg 76. VRd2 PWM period + U16 fpgaVPdPWMLow; ///< Reg 78. VPd PWM low + U16 fpgaVPdPWMPeriod; ///< Reg 80. VPd PWM period + U16 fpgaVSOLPWMLow; ///< Reg 82. VSOL PWM low + U16 fpgaVSOLPWMPeriod; ///< Reg 84. VSOL PWM period + U16 fpgaVRfPWMPullin; ///< Reg 86. VRf PWM pull in + U16 fpgaVRiPWMPullin; ///< Reg 88. VRi PWM pull in + U16 fpgaVRdPWMPullin; ///< Reg 90. VRd PWM pull in + U16 fpgaVRoPWMPullin; ///< Reg 92. VRo PWM pull in + U16 fpgaVPoPWMPullin; ///< Reg 94. VPo PWM pull in + U16 fpgaVBfPWMPullin; ///< Reg 96. VBf PWM pull in + U16 fpgaVRcPWMPullin; ///< Reg 98. VRc PWM pull in + U16 fpgaVDrPWMPullin; ///< Reg 100. VDr PWM pull in + U16 fpgaVPiPWMPullin; ///< Reg 102. VPi PWM pull in + U16 fpgaVSPPWMPullin; ///< Reg 104. VSP PWM pull in + U16 fpgaVRd1PWMPullin; ///< Reg 106. VRd1 PWM pull in + U16 fpgaVRd2PWMPullin; ///< Reg 108. VRd2 PWM pull in + U16 fpgaVPdPWMPullin; ///< Reg 110. VPd PWM pull in + U16 fpgaVSPR2PWMPullin; ///< Reg 112. VSPR2 PWM pull in + U16 fpgaValvePWMEnable; ///< Reg 114. valve PWM enable + + // DVT Registers + U08 fpgaTHdControlReg; ///< Reg 116. THd control register + U08 fpgaCPiCPoEmstatControl; ///< Reg 117. CPi/CPo Emstat control + U16 fpgaDACRegBIn; ///< Reg 118. Debug DAC channel B output + U16 fpgaDACRegCIn; ///< Reg 120. Debug DAC channel C output + U16 fpgaDACRegDIn; ///< Reg 122. Debug DAC channel D output + U16 fpgaDACRegEIn; ///< Reg 124. Debug DAC channel E output + U16 fpgaDACRegFIn; ///< Reg 126. Debug DAC channel F output + U16 fpgaDACRegGIn; ///< Reg 128. Debug DAC channel G output + U16 fpgaDACRegHIn; ///< Reg 130. Debug DAC channel H output + U08 fgpaNewCP2Control; ///< Reg 132. Concentrate pump 2 control + U08 fpgaNewCP1Control; ///< Reg 133. Concentrate pump 1 control } FPGA_ACTUATORS_T; #pragma pack(pop) // ********** private data ********** static FPGA_STATE_T fpgaState = FPGA_STATE_START; ///< FPGA current state. - static U32 fpgaCommRetryCount = 0; ///< FPGA communication retry count. static U32 fpgaReceiptCounter = 0; ///< FPGA receipt completed counter. static U32 fpgaTransmitCounter = 0; ///< FPGA transmit completed counter. @@ -1072,60 +1115,92 @@ /*********************************************************************//** * @brief - * The setFPGACP1Control function sets the control configuration for + * The setFPGAcidPumpControl function sets the control configuration for * concentrate pump CP1. * @details Inputs: none * @details Outputs: fpgaActuatorSetPoints.fpgaCP1Control * @param pumpControl The concentrate pump control configuration * @return none *************************************************************************/ -void setFPGACP1Control( U08 pumpControl ) +void setFPGAV3AcidPumpControl( U08 pumpControl ) { fpgaActuatorSetPoints.fpgaCP1Control = pumpControl; } /*********************************************************************//** * @brief - * The setFPGACP2Control function sets the control configuration for + * The setFPGABicarbPumpControl function sets the control configuration for * concentrate pump CP2. * @details Inputs: none * @details Outputs: fpgaActuatorSetPoints.fpgaCP2Control * @param pumpControl The concentrate pump control configuration * @return none *************************************************************************/ -void setFPGACP2Control( U08 pumpControl ) +void setFPGAV3BicarbPumpControl( U08 pumpControl ) { fpgaActuatorSetPoints.fpgaCP2Control = pumpControl; } /*********************************************************************//** * @brief - * The setFPGACP1SetStepSpeed function sets the step speed period for concentrate pump CP1. + * The setFPGAAcidPumpSetStepSpeed function sets the step speed period for + * concentrate pump CP1. * @details Inputs: none * @details Outputs: fpgaActuatorSetPoints.fpgaCP1StepSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ -void setFPGACP1SetStepSpeed( U16 stepSpeed ) +void setFPGAAcidPumpSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaCP1StepSpeed = stepSpeed; } /*********************************************************************//** * @brief - * The setFPGACP2SetStepSpeed function sets the step speed period for concentrate pump CP2. + * The setFPGABicarbSetStepSpeed function sets the step speed period for + * concentrate pump CP2. * @details Inputs: none * @details Outputs: fpgaActuatorSetPoints.fpgaCP2StepSpeed * @param stepSpeed The concentrate pump step speed period * @return none *************************************************************************/ -void setFPGACP2SetStepSpeed( U16 stepSpeed ) +void setFPGABicarbSetStepSpeed( U16 stepSpeed ) { fpgaActuatorSetPoints.fpgaCP2StepSpeed = stepSpeed; } +/****************************DVT Functions*******************************************/ + /*********************************************************************//** * @brief + * The setFPGAAcidPumpControl function sets the DVT concentrate pump 1 + * (acid pump) control mode. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints.fpgaNewCP1Control + * @param control Concentrate pump control set + * @return none + *************************************************************************/ +void setFPGAAcidPumpControl( U08 control ) +{ + fpgaActuatorSetPoints.fpgaNewCP1Control = control; +} + +/*********************************************************************//** + * @brief + * The setFPGABicarbPumpControl function sets the DVT concentrate pump 2 + * (bicarb pump) control mode. + * @details Inputs: none + * @details Outputs: fpgaActuatorSetPoints.fgpaNewCP2Control + * @param control Concentrate pump control set + * @return none + *************************************************************************/ +void setFPGABicarbPumpControl( U08 control ) +{ + fpgaActuatorSetPoints.fgpaNewCP2Control = control; +} + +/*********************************************************************//** + * @brief * The getFPGAVersions function gets the FPGA version numbers. * @details Inputs: fpgaHeader * @details Outputs: none @@ -1557,11 +1632,7 @@ *************************************************************************/ U08 getFPGACPiFault( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPiFault; -#else - return 0; -#endif } /*********************************************************************//** @@ -1573,11 +1644,7 @@ *************************************************************************/ U08 getFPGACPiReadCount( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPiReadCnt; -#else - return 0; -#endif } /*********************************************************************//** @@ -1589,11 +1656,7 @@ *************************************************************************/ U08 getFPGACPiErrorCount( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPiErrorCnt; -#else - return 0; -#endif } /*********************************************************************//** @@ -1605,11 +1668,7 @@ *************************************************************************/ U32 getFPGACPi( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPi; -#else - return 0; -#endif } /*********************************************************************//** @@ -1621,11 +1680,7 @@ *************************************************************************/ U08 getFPGACPoFault( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPoFault; -#else - return 0; -#endif } /*********************************************************************//** @@ -1637,11 +1692,7 @@ *************************************************************************/ U08 getFPGACPoReadCount( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPoReadCnt; -#else - return 0; -#endif } /*********************************************************************//** @@ -1654,11 +1705,7 @@ *************************************************************************/ U08 getFPGACPoErrorCount( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPoErrorCnt; -#else - return 0; -#endif } /*********************************************************************//** @@ -1670,11 +1717,7 @@ *************************************************************************/ U32 getFPGACPo( void ) { -#ifndef ENABLE_DVT_BOARD return fpgaSensorReadings.fpgaCPo; -#else - return 0; -#endif } /*********************************************************************//** @@ -1697,34 +1740,35 @@ * @details Outputs: none * @return Emstat conductivity sensor output byte *************************************************************************/ -U08 getFPGAEmstatOutByte( void ) +U08 getFPGAEmstatCD1CD2OutByte( void ) { - return fpgaSensorReadings.fpgaEmstatOutByte; + return fpgaSensorReadings.fpgaCD1CD2EmstatOutByte; } /*********************************************************************//** * @brief - * The getFPGAEmstatRxErrCount function gets Emstat conductivity sensor error count. + * The getFPGAEmstatCD1CD2RxErrCount function gets Emstat conductivity sensor + * error count. * @details Inputs: fpgaSensorReadings.fpgaEmstatRxErrorCount * @details Outputs: none * @return Emstat conductivity sensor receive error count *************************************************************************/ -U08 getFPGAEmstatRxErrCount( void ) +U08 getFPGAEmstatCD1CD2RxErrCount( void ) { - return fpgaSensorReadings.fpgaEmstatRxErrorCount; + return fpgaSensorReadings.fpgaCD1CD2EmstatRxErrorCount; } /*********************************************************************//** * @brief - * The getFPGAEmstatRxFifoCount function gets Emstat conductivity sensor receive - * fifo buffer count. + * The getFPGAEmstatCD1CD2RxFifoCount function gets Emstat conductivity + * sensor receive fifo buffer count. * @details Inputs: fpgaSensorReadings.fpgaEmstatTxFifoCount * @details Outputs: none * @return Emstat conductivity sensor receive fifo buffer count *************************************************************************/ -U16 getFPGAEmstatRxFifoCount( void ) +U16 getFPGAEmstatCD1CD2RxFifoCount( void ) { - return fpgaSensorReadings.fpgaEmstatRxFifoCount; + return fpgaSensorReadings.fpgaCD1CD2EmstatRxFifoCount; } /*********************************************************************//** @@ -1955,7 +1999,7 @@ *************************************************************************/ U16 getFPGATimerCount( void ) { - return fpgaSensorReadings.fpgaTimerCount_ms; + return fpgaSensorReadings.fpgaTimerCountMS; } /*********************************************************************//** @@ -2127,4 +2171,63 @@ return ( fpgaSensorReadings.fpgaBaroTemperature & MASK_OFF_U32_MSB ); } +/*********************************************************************//** + * @brief + * The getFPGAEmstatCPiCPoByteOut function gets the FPGA Emstat CPi/CPo + * byte out data. + * @details Inputs: fpgaSensorReadings.fpgaCPiCPoEmstatOutByte + * @details Outputs: none + * @return CPi/CPo Emstat byte out + *************************************************************************/ +U08 getFPGAEmstatCPiCPoByteOut( void ) +{ + return fpgaSensorReadings.fpgaCPiCPoEmstatOutByte; +} + +/*********************************************************************//** + * @brief + * The getFPGAEmstatCPiCPoRxFifoCount function gets the FPGA Emstat CPi/CPo + * receive FIFO count. + * @details Inputs: fpgaSensorReadings.fpgaCD1CD2EmstatRxFifoCount + * @details Outputs: none + * @return CPi/CPo Rx FIFO count + *************************************************************************/ +U16 getFPGAEmstatCPiCPoRxFifoCount( void ) +{ + return fpgaSensorReadings.fpgaCPiCPoEmstatRxFIFOCount; +} + +/*********************************************************************//** + * @brief + * The getFPGAEmstatCPiCPoRxErrCount function gets the FPGA Emstat CPi/CPo + * receive FIFO error count. + * @details Inputs: fpgaSensorReadings.fpgaCD1CD2EmstatRxErrorCount + * @details Outputs: none + * @return CPi/CPo Rx FIFO error count + *************************************************************************/ +U08 getFPGAEmstatCPiCPoRxErrCount( void ) +{ + return fpgaSensorReadings.fpgaCPiCPoEmstatRxErrCount; +} + +U32 getFPGATHdTemp( void ) +{ + return fpgaSensorReadings.fpgaTHdTemp; +} + +U32 getFPGATHdInternalTemp( void ) +{ + return fpgaSensorReadings.fpgaTHdInternalTemp; +} + +U08 getFPGATHdReadCount( void ) +{ + return fpgaSensorReadings.fpgaTHdRTDReadCount; +} + +U08 getFPGATHdErrorCount( void ) +{ + return fpgaSensorReadings.fpgaTHdRTDErrorCount; +} + /**@}*/