Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r322747d530c1b8205be257557e53dcfe9caad50a -r333e2d0c0462dcb4343a279420949cce716ebab7 --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 322747d530c1b8205be257557e53dcfe9caad50a) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 333e2d0c0462dcb4343a279420949cce716ebab7) @@ -65,6 +65,11 @@ #define FPGA_D43_WR_ENABLE_BIT 0x40 ///< Conductivity Sensor D43 write enable bit mask. #define FPGA_D43_RD_ENABLE_BIT 0x80 ///< Conductivity Sensor D43 read enable bit mask. +#define FPGA_D74_RESET_BIT 0x01 ///< Conductivity Sensor D74 reset bit mask. +#define FPGA_D74_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor D74 Initialization enable bit mask. +#define FPGA_D74_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor D74 write enable bit mask. +#define FPGA_D74_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor D74 read enable bit mask. + // Assuming all valves are ON/OFF based control ( No PWM control used) #define FPGA_ENABLE_VALVES_PWM 0x0000 ///< FPGA enable valves PWM. #define FPGA_ENABLE_BC_VALVES_PWM 0x00 ///< FPGA enable Balancing chamber valves PWM. @@ -90,7 +95,8 @@ #define FPGA_D6_FLOATER_LEVEL_BIT 0x03 ///< Floater level bit mask. -#define FPGA_D5_HEATER_CNTRL_BIT 0x01 ///< FPGA GIO D5 heater control bit mask +#define FPGA_D5_HEATER_CNTRL_BIT 0x01 ///< FPGA GIO D5 heater control bit mask +#define FPGA_D5_HEATER_PWM_ENABLE_BIT 0x02 ///< FPGA D5 PWM based heater control bit mask /// FPGA size of V3 read bytes. #define FPGA_SIZE_OF_V3_READ_BYTES ( FPGA_READ_V3_END_BYTE_NUM - FPGA_READ_V3_START_BYTE_NUM ) @@ -232,6 +238,21 @@ U08 fpgaFloater2Status; ///< Reg 427. Floater 2 level sensor status U16 fpgaD11PumpStepCountStatus; ///< Reg 428. Acid concentrate pump revolution down count status U16 fpgaD10PumpStepCountStatus; ///< Reg 430. Bicarb concentrate pump revolution down count status + + U16 fpgaAdcTemp; ///< Reg 432. TBD + U16 fpgaAdcVccInt; ///< Reg 434. TBD + U16 fpgaAdcVccAux; ///< Reg 436. TBD + U16 fpgaAdcVpVn; ///< Reg 438. TBD + U16 fpgaD12PumpSpeedFeedback; ///< Reg 440. D12 Pump speed feedback + U16 fpgaD48PumpSpeedFeedback; ///< Reg 442. D48 Pump Speed feedback + U16 fpgaD76PumpHallSense; ///< Reg 444. UF D76_Pump hall sensor pulse width + U16 fpgaD76PumpStepCountStatus; ///< Reg 446. UF pump revolution down count status + + U32 fpgaD74CondDataOut; ///< Reg 448. Data read from Conductivity Sensor D74 register + U16 fpgaD74CondCond; ///< Reg 452. D74 conductivity + U16 fpgaD74CondTemp; ///< Reg 454. D74 Temperature + U08 fpgaD74CondReadCnt; ///< Reg 456. D74 successful read count + U08 fpgaD74CondErrorCnt; ///< Reg 457. D74 error read count } DD_FPGA_SENSORS_T; typedef struct @@ -324,6 +345,15 @@ U16 fpgaD10PumpRevCount; ///< Reg 144. Bicarb Concentrate pump revolution count U08 fpgaADCControl; ///< Reg 146. FPGA internal ADC Control register for debugging U08 fpgaGPIOControl; ///< Reg 147. FPGA GPIO control interface + U16 fpgaACRelayPWMLow; ///< Reg 148. Length of time in 10us resoultion that PWM output stays low. + U16 fpgaACRelayPWMPeriod; ///< Reg 150. PWM period for AC relay/heater. + + U16 fpgaD76PumpSpeed; ///< Reg 152. UF Pump Speed/RPM Control + U16 fpgaD76PumpRevCount; ///< Reg 154. UF pump revolution count + U08 fpgaD76PumpControl; ///< Reg 156. UF Pump Control + U08 fpgaConSensD74Control; ///< Reg 157. Conductivity/Temperature Sensors D74 Control registers + U16 fpgaConSensD74_Addrs; ///< Reg 158. D74 Initialization Address register + U32 fpgaConSensD74_Data_In; ///< Reg 160. D74 Initialization data register } FPGA_ACTUATORS_T; #pragma pack(pop) @@ -618,6 +648,20 @@ /*********************************************************************//** * @brief + * The setFPGAD76PumpSetStepSpeed function sets the step speed period for + * UF D76_Pump. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpSpeed + * @param stepSpeed The concentrate pump step speed period + * @return none + *************************************************************************/ +void setFPGAD76PumpSetStepSpeed( U16 stepSpeed ) +{ + fpgaActuatorSetPoints.fpgaD76PumpSpeed = stepSpeed; +} + +/*********************************************************************//** + * @brief * The setFPGAD11PumpControl function sets the DVT concentrate pump 1 * (acid pump) control mode. * bit 7: Park (set in different function) @@ -660,6 +704,27 @@ /*********************************************************************//** * @brief + * The setFPGAD76PumpControl function sets the UF pump + * (D76 pump) control mode. + * bit 7: Park (set in different function) + * bit 6: nSleep + * bit 5: nReset + * bit 4: nEnable + * bit 3: Direction (1=Fwd, 0=Rev) + * bit 0-2: Microstepping resolution + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl + * @param control UF pump control set + * @return none + *************************************************************************/ +void setFPGAD76PumpControl( U08 control ) +{ + fpgaActuatorSetPoints.fpgaD76PumpControl &= FPGA_CONC_PUMP_PARK_COMMAND; // preserve msb (park command bit) + fpgaActuatorSetPoints.fpgaD76PumpControl |= control; +} + +/*********************************************************************//** + * @brief * The setFPGAD11PumpParkCmd function sets the DVT concentrate pump 1 * (acid pump) park command bit. * bit 7: Park command bit @@ -692,6 +757,22 @@ /*********************************************************************//** * @brief + * The setFPGAD76PumpParkCmd function sets the Ultrafiltration pump + * (D76 pump) park command bit. + * bit 7: Park command bit + * bit 0-6: Other pump control bits (set in different function) + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl + * @param Park command bit set + * @return none + *************************************************************************/ +void setFPGAD76PumpParkCmd( void ) +{ + fpgaActuatorSetPoints.fpgaD76PumpControl |= FPGA_CONC_PUMP_PARK_COMMAND; // this bit must be cleared after next transmit to prevent continuous park commands +} + +/*********************************************************************//** + * @brief * The setFPGAD17CondReset function resets the FPGA Conductivity * Sensor D17. * @details \b Inputs: none @@ -1164,6 +1245,125 @@ /*********************************************************************//** * @brief + * The setFPGAD74CondReset function resets the FPGA Conductivity + * Sensor D74. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void setFPGAD74CondReset( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control |= FPGA_D74_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAD74CondReset function clears the reset of FPGA Conductivity + * Sensor D74. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void clearFPGAD74CondReset( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control &= ~FPGA_D74_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAD74CondInitEnable function enables the FPGA Conductivity + * Sensor D74 initialzation procedure. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void setFPGAD74CondInitEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control |= FPGA_D74_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAD74CondInitEnable function clears the init process of FPGA Conductivity + * Sensor D74. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void clearFPGAD74CondInitEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control &= ~FPGA_D74_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAD74CondWriteEnable function enables the FPGA Conductivity + * Sensor D74 write transaction. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @warning: The address (setFPGACD74Address) and data (setFPGACD74Data) register + * must be populated before invoking this write enable function to initiate + * write transaction with the sensor. + * @return none + *************************************************************************/ +void setFPGAD74CondWriteEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control |= FPGA_D74_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAD74CondWriteEnable function clears the write enable of FPGA Conductivity + * Sensor D74. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void clearFPGAD74CondWriteEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control &= ~FPGA_D74_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGAD74CondReadEnable function enables the FPGA Conductivity + * Sensor D74 read transaction. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @warning: The address (setFPGACD74Address) register must be populated + * before invoking this read enable function to initiate read transaction + * with the sensor. + * @return none + *************************************************************************/ +void setFPGAD74CondReadEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control |= FPGA_D74_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGAD74CondReadEnable function clears the read enable of FPGA Conductivity + * Sensor D74. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param none + * @return none + *************************************************************************/ +void clearFPGAD74CondReadEnable( void ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control &= ~FPGA_D74_RD_ENABLE_BIT; +} + + +/*********************************************************************//** + * @brief * The setFpgaCD12Control function sets the FPGA Conductivity * Sensor control register for CD1&2. * bit 7: Enables D27 read transaction (1), address needed @@ -1208,6 +1408,25 @@ /*********************************************************************//** * @brief + * The setFpgaCD5Control function sets the FPGA Conductivity + * Sensor control register for CD5. + * bit 4- 7: Reserved. + * bit 3: Enables D74 read transaction (1), address needed + * bit 2: Enables D74 write transaction (1), address and data needs to be set + * bit 1: Enable D74 Init procedure (1) + * bit 0: reset D74 Conduct sensor (1) + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74Control + * @param control Conductivity sensor control set + * @return none + *************************************************************************/ +void setFPGACD5Control( U08 control ) +{ + fpgaActuatorSetPoints.fpgaConSensD74Control = control; +} + +/*********************************************************************//** + * @brief * The setFPGACD12Address function sets the conductivity sensor * CD12 address register to perform read and write operations. * @details \b Inputs: none @@ -1236,6 +1455,20 @@ /*********************************************************************//** * @brief + * The setFPGACD5Address function sets the conductivity sensor + * D74 address register to perform read and write operations. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74_Addrs + * @param address The conductivity sensor CD74 address + * @return none + *************************************************************************/ +void setFPGACD5Address( U16 address ) +{ + fpgaActuatorSetPoints.fpgaConSensD74_Addrs = address; +} + +/*********************************************************************//** + * @brief * The setFPGACD12Data function sets the conductivity sensor * CD12 data outputfor write operations. * @details \b Inputs: none @@ -1264,6 +1497,20 @@ /*********************************************************************//** * @brief + * The setFPGACD5Data function sets the conductivity sensor + * CD5 data outputfor write operations. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaConSensD74_Data_In + * @param data The conductivity sensor CD74 Data + * @return none + *************************************************************************/ +void setFPGACD5Data( U32 data ) +{ + fpgaActuatorSetPoints.fpgaConSensD74_Data_In = data; +} + +/*********************************************************************//** + * @brief * The setFPGAD5HeaterPWMControl function sets the primary heater * PWM input. * @details \b Inputs: none @@ -1320,6 +1567,20 @@ /*********************************************************************//** * @brief + * The setFPGAD76PumpRevolutionCount function sets the UltraFilteration + * pump revolution count. + * @details \b Inputs: none + * @details \b Outputs: fpgaD76PumpRevCount + * @param count the number of revolution to be rotated for the pump. + * @return none + *************************************************************************/ +void setFPGAD76PumpRevolutionCount( U16 count ) +{ + fpgaActuatorSetPoints.fpgaD76PumpRevCount = count; +} + +/*********************************************************************//** + * @brief * The setFPGAD5HeaterOnOffControl function sets the primary heater * On/Off control. * @details \b Inputs: none @@ -1341,6 +1602,55 @@ /*********************************************************************//** * @brief + * The setFPGAD5HeaterPWMEnableControl function sets whether the primary heater + * control based out of On/OFF (0) or PWM based control (1). + * @details \b Inputs: none + * @details \b Outputs: fpgaGPIOControl + * @param enable PWM based heater control when true, otherwise On/Off Control. + * @return none + *************************************************************************/ +void setFPGAD5HeaterPWMEnableControl( BOOL enable ) +{ + if ( TRUE == enable) + { + fpgaActuatorSetPoints.fpgaGPIOControl |= FPGA_D5_HEATER_PWM_ENABLE_BIT; + } + else + { + fpgaActuatorSetPoints.fpgaGPIOControl &= ~FPGA_D5_HEATER_PWM_ENABLE_BIT; + } +} + +/*********************************************************************//** + * @brief + * The setFPGAD5HeaterPWMLowState function sets the PWM low period( Off time) + * for AC heater. + * @details \b Inputs: none + * @details \b Outputs: fpgaACRelayPWMLow + * @param count the number of count that PWM stays low for the AC relay/heater. + * @return none + *************************************************************************/ +void setFPGAD5HeaterPWMLowState( U16 count ) +{ + fpgaActuatorSetPoints.fpgaACRelayPWMLow = count; +} + +/*********************************************************************//** + * @brief + * The setFPGAD5HeaterPWMPeriod function sets the PWM period( On and Off time) + * for AC heater. + * @details \b Inputs: none + * @details \b Outputs: fpgaACRelayPWMPeriod + * @param period the total period of PWM cycle ( On and Off time). + * @return none + *************************************************************************/ +void setFPGAD5HeaterPWMPeriod( U16 period ) +{ + fpgaActuatorSetPoints.fpgaACRelayPWMPeriod = period; +} + +/*********************************************************************//** + * @brief * The getFPGAVersions function gets the FPGA version numbers. * @details \b Inputs: fpgaHeader * @details \b Outputs: none @@ -1550,6 +1860,25 @@ /*********************************************************************//** * @brief + * The getFPGAD76PumpControlStatus function gets the Ultrafilteration pump + * (D76 pump) control mode. + * bit 7: Park (set in different function) + * bit 6: nSleep + * bit 5: nReset + * bit 4: nEnable + * bit 3: Direction (1=Fwd, 0=Rev) + * bit 0-2: Microstepping resolution + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.fpgaD76PumpControl + * @return UF pump control status bit + *************************************************************************/ +U08 getFPGAD76PumpControlStatus( void ) +{ + return fpgaActuatorSetPoints.fpgaD76PumpControl; +} + +/*********************************************************************//** + * @brief * The getFPGAConcentratePumpsFault function gets concentrate pumps fault * reported by FGPA. * @details \b Inputs: fpgaSensorReadings.fpgaD11_D10_PumpFault @@ -1653,6 +1982,19 @@ /*********************************************************************//** * @brief + * The getFPGAD76PumpHallSensePulseWidth function gets UF pump D76_Pump + * hall sense pulse width. + * @details \b Inputs: fpgaSensorReadings.fpgaD76PumpHallSense + * @details \b Outputs: none + * @return ultrafiltration pump D76_Pump hall sense pulse width + *************************************************************************/ +U16 getFPGAD76PumpHallSensePulseWidth( void ) +{ + return fpgaSensorReadings.fpgaD76PumpHallSense; +} + +/*********************************************************************//** + * @brief * The getFPGAValveStates function gets the latest sensed valve states. * See setFPGAValveStates for valve state bit positions. * @details \b Inputs: fpgaSensorReadings.fpgaValveStates @@ -2293,6 +2635,66 @@ /*********************************************************************//** * @brief + * The getFPGAD74CondReadCount function gets D74 conductivity sensor read count. + * @details \b Inputs: fpgaSensorReadings.fpgaD74CondReadCnt + * @details \b Outputs: none + * @return Latest D74 conductivity sensor read count + *************************************************************************/ +U08 getFPGAD74CondReadCount( void ) +{ + return fpgaSensorReadings.fpgaD74CondReadCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGAD74CondErrorCount function gets D74 conductivity sensor error count. + * @details \b Inputs: fpgaSensorReadings.fpgaD74CondErrorCnt + * @details \b Outputs: none + * @return Latest D74 conductivity sensor read error count + *************************************************************************/ +U08 getFPGAD74CondErrorCount( void ) +{ + return fpgaSensorReadings.fpgaD74CondErrorCnt; +} + +/*********************************************************************//** + * @brief + * The getFPGAD74Cond function gets D74 conductivity sensor value. + * @details \b Inputs: fpgaSensorReadings.fpgaD74Cond + * @details \b Outputs: none + * @return Latest D74 conductivity sensor value + *************************************************************************/ +U16 getFPGAD74Cond( void ) +{ + return fpgaSensorReadings.fpgaD74CondCond; +} + +/*********************************************************************//** + * @brief + * The getFPGAD74CondTemp function gets D74 conductivity sensor temperature value. + * @details \b Inputs: fpgaSensorReadings.fpgaD74CondTemp + * @details \b Outputs: none + * @return Latest D74 conductivity sensor temperature value + *************************************************************************/ +U16 getFPGAD74CondTemp( void ) +{ + return fpgaSensorReadings.fpgaD74CondTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGAD74CondData function gets D74 conductivity sensor register value. + * @details \b Inputs: fpgaSensorReadings.fpgaD74CondDataOut + * @details \b Outputs: none + * @return Latest D74 conductivity sensor register data value + *************************************************************************/ +U32 getFPGAD74CondData( void ) +{ + return fpgaSensorReadings.fpgaD74CondDataOut; +} + +/*********************************************************************//** + * @brief * The getFPGAD63LevelSensor function gets the latest FPGA D63 level sensor * reading. * @details \b Inputs: fpgaSensorReadings.fpgaD63LevelSensor @@ -2634,6 +3036,19 @@ /*********************************************************************//** * @brief + * The getFPGAD76PumpRevolutionCountStatus function gets the current revolution of + * UF pump (down counter) status. + * @details \b Inputs: fpgaD76PumpStepCountStatus + * @details \b Outputs: none + * @return the current revolution of the UF pump + *************************************************************************/ +U16 getFPGAD76PumpRevolutionCountStatus( void ) +{ + return fpgaSensorReadings.fpgaD76PumpStepCountStatus; +} + +/*********************************************************************//** + * @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