Index: firmware/App/Services/FpgaRO.c =================================================================== diff -u -r3edf8084a5028ee0d00a3fba496284e593e4254d -rf47296145b6a0adb78df0e325587629171909fd6 --- firmware/App/Services/FpgaRO.c (.../FpgaRO.c) (revision 3edf8084a5028ee0d00a3fba496284e593e4254d) +++ firmware/App/Services/FpgaRO.c (.../FpgaRO.c) (revision f47296145b6a0adb78df0e325587629171909fd6) @@ -38,6 +38,11 @@ #define MAX_FPGA_COMM_FAILURES 3 ///< FPGA maximum comm failures per MAX_FPGA_COMM_FAILURES_WINDOW_MS #define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up +#define FPGA_CONDUCTIVITY_RESET_BIT 0x01 ///< Conductivity Sensor reset bit mask. +#define FPGA_CONDUCTIVITY_INIT_ENABLE_BIT 0x02 ///< Conductivity Sensor initialization enable bit mask. +#define FPGA_CONDUCTIVITY_WR_ENABLE_BIT 0x04 ///< Conductivity Sensor write enable bit mask. +#define FPGA_CONDUCTIVITY_RD_ENABLE_BIT 0x08 ///< Conductivity Sensor read enable bit mask. + // FPGA Sensors Record #pragma pack(push,1) @@ -106,16 +111,16 @@ U16 reserved5; ///< Reg 332. Reserved. U08 reserved6; ///< Reg 334. Reserved. U08 reserved7; ///< Reg 335. Reserved. - U32 conductSensor1; ///< Reg 336. Conductivity sensor 1. - U16 conductSensor1Data; ///< Reg 340. Conductivity sensor 1 data. - U16 conductSensor1Temp; ///< Reg 342. Conductivity sensor 1 temperature. - U08 conductSensor1ReadCount; ///< Reg 344. Conductivity sensor 1 read counter. - U08 conductSensor1ErrorCount; ///< Reg 345. Conductivity sensor 1 error counter. - U32 conductSensor2; ///< Reg 346. Conductivity sensor 2. - U16 conductSensor2Data; ///< Reg 350. Conductivity sensor 2 data. - U16 conductSensor2Temp; ///< Reg 352. Conductivity sensor 2 temperature. - U08 conductSensor2ReadCount; ///< Reg 354. Conductivity sensor 2 read counter. - U08 conductSensor2ErrorCount; ///< Reg 355. Conductivity sensor 2 error counter. + U32 conductivityCpiData; ///< Reg 336. CPi conductivity sensor data. + U16 conductivityCpiCond; ///< Reg 340. CPi conductivity sensor conductivity. + U16 conductivityCpiTemp; ///< Reg 342. CPi conductivity sensor temperature. + U08 conductivityCpiReadCount; ///< Reg 344. CPi conductivity sensor read counter. + U08 conductivityCpiErrorCount; ///< Reg 345. CPi conductivity sensor error counter. + U32 conductivityCpoData; ///< Reg 346. CPo conductivity sensor data. + U16 conductivityCpoCond; ///< Reg 350. CPo conductivity sensor conductivity. + U16 conductivityCpoTemp; ///< Reg 352. CPo conductivity sensor temperature. + U08 conductivityCpoReadCount; ///< Reg 354. CPo conductivity sensor read counter. + U08 conductivityCpoErrorCount; ///< Reg 355. CPo conductivity sensor error counter. U16 flowRateFmp; ///< Reg 356. FMP flow sensor rate. U16 flowTempFmp; ///< Reg 358. FMP flow sensor temperature. U16 roPumpTachCount; ///< Reg 360. ROP tachometer counter. @@ -132,12 +137,12 @@ { U08 valveControl; ///< Reg 04. Valve control register. U08 valvePWMEnable; ///< Reg 05. Valve PWM enable register. - U08 conductSensorControl1; ///< Reg 06. Conductivity sensor control register 1. - U08 conductSensorControl2; ///< Reg 07. Conductivity sensor control register 2. - U16 conductAddress1; ///< Reg 08. Conductivity sensor address register 1. - U32 conductData1; ///< Reg 10. Conductivity sensor data in register 1. - U16 conductAddress2; ///< Reg 14. Conductivity sensor address register 2. - U32 conductData2; ///< Reg 16. Conductivity sensor data in register 2. + U08 conductivityCPiControl; ///< Reg 06. CPi conductivity control register. + U08 conductivityCPoControl; ///< Reg 07. CPo conductivity control register. + U16 conductivityCPiAddress; ///< Reg 08. CPi conductivity address register. + U32 conductivityCPiData; ///< Reg 10. CPi conductivity data in register. + U16 conductivityCPoAddress; ///< Reg 14. CPo conductivity address register. + U32 conductivityCPoData; ///< Reg 16. CPo conductivity data in register. U16 fpgaGenWrRd; ///< Reg 20. FPGA general write/read-back register (mirrored to a general read register in read page at addr 256). U16 descalePumpSpeed; ///< Reg 22. Descaler pump speed register. U08 descalePumpControl; ///< Reg 24. Descaler pump control register. @@ -692,4 +697,426 @@ return fpgaSensorReadings.flowTempFmp; } +/*********************************************************************//** + * @brief + * The setFPGACPiControl function sets the FPGA CPi sensor control register + * to perform a given action. + * bit 4..7: unused + * bit 3: Enable CPi read transaction; address needed + * bit 2: Enable CPi write transaction; address and data needs to be set + * bit 1: Enable CPi initialization procedure + * bit 0: reset CPi sensor + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @param control bits indicating control action to take + * @return none + *************************************************************************/ +void setFPGACPiControl( U08 control ) +{ + fpgaActuatorSetPoints.conductivityCPiControl = control; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiAddress function sets the read/write address for a read/write + * action on the CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiAddress + * @param address The CPi sensor address to read from or write to + * @return none + *************************************************************************/ +void setFPGACPiAddress( U16 address ) +{ + fpgaActuatorSetPoints.conductivityCPiAddress = address; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiData function sets the write data for a write action on + * the CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiData + * @param data The 32-bit data to write to the CPi sensor + * @return none + *************************************************************************/ +void setFPGACPiData( U32 data ) +{ + fpgaActuatorSetPoints.conductivityCPiData = data; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiControl function sets the FPGA CPo sensor control register + * to perform a given action. + * bit 4..7: unused + * bit 3: Enable CPo read transaction; address needed + * bit 2: Enable CPo write transaction; address and data needs to be set + * bit 1: Enable CPo initialization procedure + * bit 0: reset CPo sensor + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @param control bits indicating control action to take + * @return none + *************************************************************************/ +void setFPGACPoControl( U08 control ) +{ + fpgaActuatorSetPoints.conductivityCPoControl = control; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoAddress function sets the read/write address for a read/write + * action on the CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoAddress + * @param address The CPo sensor address to read from or write to + * @return none + *************************************************************************/ +void setFPGACPoAddress( U16 address ) +{ + fpgaActuatorSetPoints.conductivityCPoAddress = address; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoData function sets the write data for a write action on + * the CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoData + * @param data The 32-bit data to write to the CPo sensor + * @return none + *************************************************************************/ +void setFPGACPoData( U32 data ) +{ + fpgaActuatorSetPoints.conductivityCPoData = data; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiReset function sets the reset command bit for CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void setFPGACPiReset( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl |= FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPiReset function clears the reset command bit for CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void clearFPGACPiReset( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl &= ~FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiInitEnable function sets the initialize command bit for + * CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void setFPGACPiInitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl |= FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPiInitEnable function clears the initialize command bit for + * CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void clearFPGACPiInitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl &= ~FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiWriteEnable function sets the write enable command bit for + * CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void setFPGACPiWriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl |= FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPiWriteEnable function clears the write enable command bit + * for CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void clearFPGACPiWriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl &= ~FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPiReadEnable function sets the read enable command bit for + * CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void setFPGACPiReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl |= FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPiReadEnable function clears the read enable command bit + * for CPi sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPiControl + * @return none + *************************************************************************/ +void clearFPGACPiReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPiControl &= ~FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoReset function sets the reset command bit for CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void setFPGACPoReset( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl |= FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPoReset function clears the reset command bit for CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void clearFPGACPoReset( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl &= ~FPGA_CONDUCTIVITY_RESET_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoInitEnable function sets the initialize command bit for + * CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void setFPGACPoInitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl |= FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPoInitEnable function clears the initialize command bit for + * CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void clearFPGACPoInitEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl &= ~FPGA_CONDUCTIVITY_INIT_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoWriteEnable function sets the write enable command bit for + * CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void setFPGACPoWriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl |= FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPoWriteEnable function clears the write enable command bit + * for CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void clearFPGACPoWriteEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl &= ~FPGA_CONDUCTIVITY_WR_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The setFPGACPoReadEnable function sets the read enable command bit for + * CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void setFPGACPoReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl |= FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The clearFPGACPoReadEnable function clears the read enable command bit + * for CPo sensor. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints.conductivityCPoControl + * @return none + *************************************************************************/ +void clearFPGACPoReadEnable( void ) +{ + fpgaActuatorSetPoints.conductivityCPoControl &= ~FPGA_CONDUCTIVITY_RD_ENABLE_BIT; +} + +/*********************************************************************//** + * @brief + * The getFPGACPiReadCount function gets the latest CPi sensor read count. + * @details \b Inputs: fpgaSensorReadings.conductivityCPiReadCount + * @details \b Outputs: none + * @return Current read count for CPi sensor. + *************************************************************************/ +U08 getFPGACPiReadCount( void ) +{ + return fpgaSensorReadings.conductivityCpiReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGACPiErrorCount function gets the latest CPi sensor error count. + * @details \b Inputs: fpgaSensorReadings.conductivityCpiErrorCount + * @details \b Outputs: none + * @return Current error count for CPi sensor. + *************************************************************************/ +U08 getFPGACPiErrorCount( void ) +{ + return fpgaSensorReadings.conductivityCpiErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGACPiConductivity function gets the latest CPi sensor conductivity + * reading. + * @details \b Inputs: fpgaSensorReadings.conductivityCpiCond + * @details \b Outputs: none + * @return Current conductivity reading from CPi sensor. + *************************************************************************/ +U16 getFPGACPiConductivity( void ) +{ + return fpgaSensorReadings.conductivityCpiCond; +} + +/*********************************************************************//** + * @brief + * The getFPGACPiTemperature function gets the latest CPi sensor temperature. + * @details \b Inputs: fpgaSensorReadings.conductivityCpiTemp + * @details \b Outputs: none + * @return Current temperature from CPi sensor. + *************************************************************************/ +U16 getFPGACPiTemperature( void ) +{ + return fpgaSensorReadings.conductivityCpiTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGACPiData function gets the latest CPi sensor data from a read + * action. + * @details \b Inputs: fpgaSensorReadings.conductivityCpiData + * @details \b Outputs: none + * @return Latest data read from CPi sensor. + *************************************************************************/ +U32 getFPGACPiData( void ) +{ + return fpgaSensorReadings.conductivityCpiData; +} + +/*********************************************************************//** + * @brief + * The getFPGACPoReadCount function gets the latest CPo sensor read count. + * @details \b Inputs: fpgaSensorReadings.conductivityCpoReadCount + * @details \b Outputs: none + * @return Current read count for CPo sensor. + *************************************************************************/ +U08 getFPGACPoReadCount( void ) +{ + return fpgaSensorReadings.conductivityCpoReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGACPoErrorCount function gets the latest CPo sensor error count. + * @details \b Inputs: fpgaSensorReadings.conductivityCpoErrorCount + * @details \b Outputs: none + * @return Current error count for CPo sensor. + *************************************************************************/ +U08 getFPGACPoErrorCount( void ) +{ + return fpgaSensorReadings.conductivityCpoErrorCount; +} + +/*********************************************************************//** + * @brief + * The getFPGACPoConductivity function gets the latest CPo sensor conductivity + * reading. + * @details \b Inputs: fpgaSensorReadings.conductivityCpoCond + * @details \b Outputs: none + * @return Current conductivity reading from CPo sensor. + *************************************************************************/ +U16 getFPGACPoConductivity( void ) +{ + return fpgaSensorReadings.conductivityCpoCond; +} + +/*********************************************************************//** + * @brief + * The getFPGACPoTemperature function gets the latest CPo sensor temperature. + * @details \b Inputs: fpgaSensorReadings.conductivityCpoTemp + * @details \b Outputs: none + * @return Current temperature from CPo sensor. + *************************************************************************/ +U16 getFPGACPoTemperature( void ) +{ + return fpgaSensorReadings.conductivityCpoTemp; +} + +/*********************************************************************//** + * @brief + * The getFPGACPoData function gets the latest CPo sensor data from a read + * action. + * @details \b Inputs: fpgaSensorReadings.conductivityCpoData + * @details \b Outputs: none + * @return Latest data read from CPo sensor. + *************************************************************************/ +U32 getFPGACPoData( void ) +{ + return fpgaSensorReadings.conductivityCpoData; +} + /**@}*/