/************************************************************************** * * Copyright (c) 2019-2024 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 FPGA.c * * @author (last) Sean Nash * @date (last) 09-Nov-2024 * * @author (original) Sean Nash * @date (original) 09-Nov-2024 * ***************************************************************************/ #include "string.h" // for memset(), memcpy() #include "Compatible.h" #include "FpgaRO.h" #include "OperationModes.h" #include "Timers.h" #include "Utilities.h" /** * @addtogroup FpgaRO * @{ */ // ********** private definitions ********** #define FPGA_EXPECTED_ID 0x01 ///< Expected ID for TD FPGA. #define PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE 1 ///< Tolerance for processor clock speed check against FPGA clock. #define MAX_FPGA_COMM_FAILURES_WINDOW_MS ( 1 * SEC_PER_MIN * MS_PER_SECOND ) ///< FPGA comm failures window #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) /// Record structure for FPGA header read. 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 (minor) being reported. U08 fpgaRevMajor; ///< Reg 2. FPGA revision (major) being reported. U08 fpgaRevLab; ///< Reg 3. FPGA revision (lab) being reported. } FPGA_HEADER_T; // Read only on FPGA /// Record structure for FPGA continuous priority reads. typedef struct { U16 compatibilityRev; ///< Reg 256. FPGA compatibility revision. U16 counterTimer1ms; ///< Reg 258. FPGA 1ms timer counter. U16 fpgaGenWrRd; ///< Reg 260. FPGA general read-back register (mirrored from a general write register in write page at addr 4). U08 errorCountProcessor; ///< Reg 262. Error count for processor communications. U08 errorCountPC; ///< Reg 263. Error count for TBD. S16 pressurePri; ///< Reg 264. PRi pressure data. U16 temperaturePri; ///< Reg 266. PRi temperature data. U08 readCountPri; ///< Reg 268. PRi read counter. U08 errorCountPri; ///< Reg 269. PRi error counter. S16 pressurePro; ///< Reg 270. PRo pressure data. U16 temperaturePro; ///< Reg 272. PRo temperature data. U08 readCountPro; ///< Reg 274. PRo read counter. U08 errorCountPro; ///< Reg 275. PRo error counter. S16 pressurePc2o; ///< Reg 276. PC2o pressure data. U16 temperaturePc2o; ///< Reg 278. PC2o temperature data. U08 readCountPc2o; ///< Reg 280. PC2o read counter. U08 errorCountPc2o; ///< Reg 281. PC2o error counter. S16 pressurePpo; ///< Reg 282. PPo pressure data. U16 temperaturePpo; ///< Reg 284. PPo temperature data. U08 readCountPpo; ///< Reg 286. PPo read counter. U08 errorCountPpo; ///< Reg 287. PPo error counter. S16 pressurePmp; ///< Reg 288. PMp pressure data. U16 temperaturePmp; ///< Reg 290. PMp temperature data. U08 readCountPmp; ///< Reg 292. PMp read counter. U08 errorCountPmp; ///< Reg 293. PMp error counter. S16 pressurePpi; ///< Reg 294. PPi pressure data. U16 temperaturePpi; ///< Reg 296. PPi temperature data. U08 readCountPpi; ///< Reg 298. PPi read counter. U08 errorCountPpi; ///< Reg 299. PPi error counter. S16 pressurePmc; ///< Reg 300. PMc pressure data. U16 temperaturePmc; ///< Reg 302. PMc temperature data. U08 readCountPmc; ///< Reg 304. PMc read counter. U08 errorCountPmc; ///< Reg 305. PMc error counter. S16 pressurePax1; ///< Reg 306. Pax1 pressure data. U16 temperaturePax1; ///< Reg 308. Pax1 temperature data. U08 readCountPax1; ///< Reg 310. Pax1 read counter. U08 errorCountPax1; ///< Reg 311. Pax1 error counter. S16 pressurePax2; ///< Reg 312. Pax2 pressure data. U16 temperaturePax2; ///< Reg 314. Pax2 temperature data. U08 readCountPax2; ///< Reg 316. Pax2 read counter. U08 errorCountPax2; ///< Reg 317. Pax2 error counter. S16 pressurePax3; ///< Reg 318. Pax3 pressure data. U16 temperaturePax3; ///< Reg 320. Pax3 temperature data. U08 readCountPax3; ///< Reg 322. Pax3 read counter. U08 errorCountPax3; ///< Reg 323. Pax3 error counter. U16 reserved1; ///< Reg 324. Reserved. U16 reserved2; ///< Reg 326. Reserved. U08 levelSwitch; ///< Reg 328. Level switch. U08 reserved3; ///< Reg 329. Reserved. U16 reserved4; ///< Reg 330. Reserved. U16 reserved5; ///< Reg 332. Reserved. U08 reserved6; ///< Reg 334. Reserved. U08 reserved7; ///< Reg 335. Reserved. 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. U16 dsPumpTachCount; ///< Reg 362. DSP tachometer counter. U16 flowIntTempFmp; ///< Reg 364. FMP flow sensor internal temperature. U16 valveControlReadback; ///< Reg 366. Valve control bits read back. U16 roPumpPWMReadback; ///< Reg 368. ROP PWM read back. U16 heaterPWMReadback; ///< Reg 370. Heater PWM read back. U08 flowReadCount; ///< Reg 372. Flow sensor read counter. U08 flowErrorCount; ///< Reg 373. Flow sensor error counter. U16 valvePWMEnableReadback; ///< Reg 374. Valve PWM enable read back. } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. typedef struct { U16 valveControl; ///< Reg 04. Valve control register. 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. U08 roPumpControl; ///< Reg 25. RO pump control register.. U16 valveVwiPWMLow; ///< Reg 26. Valve VWi PWM low pulse period in 0.1 uSec. U16 valveVwiPWMPeriod; ///< Reg 28. Valve VWi PWM full period in 0.1 uSec. U16 valvePWMPullIn; ///< Reg 30. Valve PWM high pulse period when valve is on in 0.1 uSec. U16 roPumpPWMDutyCyclePct; ///< Reg 32. ROP PWM duty cycle in percentage. U16 heaterPWMDutyCyclePct; ///< Reg 34. HRO PWM duty cycle in percentage. U08 reserved1; ///< Reg 36. Not used. U08 heaterControl; ///< Reg 37. Heater (HRO) control register. U08 flowControl; ///< Reg 38. AVS Romer flow sensor control register. U08 flowAddress; ///< Reg 39. AVS Romer flow sensor I2C slave address register. U16 valvePWMEnable; ///< Reg 40. Valve PWM enable register. } FPGA_ACTUATORS_T; #pragma pack(pop) // ********** private data ********** // FPGA data static FPGA_HEADER_T fpgaHeader; ///< Record of last received FPGA header data. static FPGA_SENSORS_T fpgaSensorReadings; ///< Record of last received FPGA priority sensor data. static FPGA_ACTUATORS_T fpgaActuatorSetPoints; ///< Record of next transmitted FPGA priority actuator data. // FPGA Clock Speed Test static U16 currentFPGATimerCount_ms = 0; ///< Last read ms timer count from FPGA. static U32 currentTimerCount_ms = 0; ///< Last read ms timer count from processor. /*********************************************************************//** * @brief * The initFPGARO function initializes the RO FPGA unit. * @details \b Inputs: none * @details \b Outputs: RO FPGA unit initialized. * @return none *************************************************************************/ void initFPGARO( void ) { // Initialize fpga driver initFPGA( (U08*)&fpgaHeader, (U08*)&fpgaSensorReadings, (U08*)&fpgaActuatorSetPoints, sizeof(FPGA_HEADER_T), sizeof(FPGA_SENSORS_T), sizeof(FPGA_ACTUATORS_T) ); // Initialize fpga data structures memset( &fpgaHeader, 0, sizeof(FPGA_HEADER_T) ); memset( &fpgaSensorReadings, 0, sizeof(FPGA_SENSORS_T) ); memset( &fpgaActuatorSetPoints, 0, sizeof(FPGA_ACTUATORS_T) ); // initialize FPGA clock speed error time windowed count initTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES, MAX_FPGA_COMM_FAILURES_WINDOW_MS); } /*********************************************************************//** * @brief * The execFPGATest function executes the FPGA self-test. * @details \b Alarm: ALARM_ID_RO_FPGA_POST_TEST_FAILED if self-test fails. * @details \b Inputs: fpgaHeader * @details \b Outputs: none * @return passed or failed *************************************************************************/ SELF_TEST_STATUS_T execFPGATest( void ) { SELF_TEST_STATUS_T result; // check FPGA reported correct ID if ( FPGA_EXPECTED_ID == fpgaHeader.fpgaId ) { // Check FPGA compatibility w/ firmware if ( RO_FPGA_COMPATIBILITY_REV == fpgaSensorReadings.compatibilityRev ) { result = SELF_TEST_STATUS_PASSED; } else { result = SELF_TEST_STATUS_FAILED; // TODO uncomment // SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_POST_TEST_FAILED, (U32)TD_FPGA_COMPATIBILITY_REV, (U32)fpgaSensorReadings.fpgaCompatibilityRev ) } } else { result = SELF_TEST_STATUS_FAILED; // TODO uncomment // SET_ALARM_WITH_1_U32_DATA( ALARM_ID_RO_FPGA_POST_TEST_FAILED, (U32)fpgaHeader.fpgaId ) } return result; } /*********************************************************************//** * @brief * The getFPGATimerCount function gets the latest FPGA timer millisecond count. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none * @return last FPGA millisecond timer count *************************************************************************/ U16 getFPGATimerCount( void ) { return fpgaSensorReadings.counterTimer1ms; } /*********************************************************************//** * @brief * The execFPGAClockSpeedTest function verifies the processor clock speed * against the FPGA clock. * @details \b Alarm: ALARM_ID_RO_FPGA_CLOCK_SPEED_CHECK_FAILURE if test fails. * @details \b Inputs: fpgaSensorReadings.fpgaTimerCount_ms, msTimerCount, * currentFPGATimerCount_ms, currentTimerCount_ms * @details \b Outputs: currentFPGATimerCount_ms, currentTimerCount_ms * @return none *************************************************************************/ void execFPGAClockSpeedTest( void ) { // DEBUG WARNING // It may be necessary to comment out the following // code to prevent the alarm from occurring while // debugging. U16 newFPGATimerCount_ms = getFPGATimerCount(); U32 newTimerCount_ms = getMSTimerCount(); U32 diffFPGATimerCount = (U32)u16DiffWithWrap( currentFPGATimerCount_ms, newFPGATimerCount_ms ); U32 diffTimerCount = u32DiffWithWrap( currentTimerCount_ms, newTimerCount_ms ); if ( getCurrentOperationMode() != RO_MODE_INIT ) { if ( abs( diffFPGATimerCount - diffTimerCount ) > PROCESSOR_FPGA_CLOCK_DIFF_TOLERANCE ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_CLOCK_SPEED_ERROR ) ) { // TODO uncomment // SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_CLOCK_SPEED_CHECK_FAILURE, diffFPGATimerCount, diffTimerCount ); } } } currentFPGATimerCount_ms = newFPGATimerCount_ms; currentTimerCount_ms = newTimerCount_ms; } /*********************************************************************//** * @brief * The getFPGAVersions function gets the fpga version numbers. * @details \b Inputs: fpgaHeader * @details \b Outputs: Given version reference variables are populated. * @return none *************************************************************************/ void getFPGAVersions( U08 *Id, U08 *Maj, U08 *Min, U08 *Lab ) { *Id = fpgaHeader.fpgaId; *Min = fpgaHeader.fpgaRev; *Maj = fpgaHeader.fpgaRevMajor; *Lab = fpgaHeader.fpgaRevLab; } /*********************************************************************//** * @brief * The checkFPGACommFailure function increments the FPGA comm failure * windowed timer and returns whether or not the number of failures in * the window have been reached. * @details \b Inputs: none * @details \b Outputs: none * @return TRUE if windowed count exceeded, else false. *************************************************************************/ void checkFPGACommFailure( void ) { if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) { // TODO uncomment // SET_ALARM_WITH_2_U32_DATA( ALARM_ID_RO_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.errorCountProcessor ) } } } /*********************************************************************//** * @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 * the window have been reached. * @details \b Inputs: none * @details \b Outputs: none * @details \b Alarm: ALARM_ID_DD_FPGA_COMM_TIMEOUT when FPGA communication is * lost with the processor. * @return TRUE if windowed count exceeded, else false. *************************************************************************/ BOOL checkFPGAFEOEFailure( void ) { BOOL status = FALSE; BOOL FPGAFEOEError = getSci2FEOEError(); if ( TRUE == FPGAFEOEError) { if ( getMSTimerCount() > MIN_POWER_ON_TIME_FOR_COMM_FAILS ) { if ( TRUE == incTimeWindowedCount( TIME_WINDOWED_COUNT_FPGA_COMM_FAILURES ) ) { // TODO uncomment //SET_ALARM_WITH_2_U32_DATA( ALARM_ID_DD_FPGA_COMM_TIMEOUT, MAX_FPGA_COMM_FAILURES, (U32)fpgaSensorReadings.fpgaIOErrorCntProcessor ) status = TRUE; } } } return status; } /*********************************************************************//** * @brief * The setFPGAValveStates function sets the RO valve states with an 8-bit * mask of states - one bit per valve, with a 1 meaning "energized" and a 0 * meaning "de-energized". The bit positions for these bit states are as follows: * 0 - VWi.\n * 1 - VFb.\n * 2 - VFf.\n * 3 - VPi.\n * 4 - VCr.\n * 5 - VCb.\n * 6 - VCd.\n * 7 - VROd.\n * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.valveControl * @param valveStates bit mask for requested valve states * @return none *************************************************************************/ void setFPGAValveStates( U16 valveStates ) { fpgaActuatorSetPoints.valveControl = valveStates; } /*********************************************************************//** * @brief * The getFPGAValveStates function gets the RO valve commanded states with * an 8-bit mask representing the set of states with a 1 meaning "energized" * and a 0 meaning "de-energized". * @details \b Inputs: none * @details \b Outputs: fpgaSensorReadings.valveControlReadback * @return none *************************************************************************/ U16 getFPGAValveStates( void ) { return fpgaSensorReadings.valveControlReadback; } /*********************************************************************//** * @brief * The setROPumpEnable function enables or disables the RO pump. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.roPumpControl * @param enable flag indicating whether to enable or disable the RO pump. * @return none *************************************************************************/ void setROPumpEnable( BOOL enable ) { fpgaActuatorSetPoints.roPumpControl = ( TRUE == enable ? 0x1 : 0x0 ); } /*********************************************************************//** * @brief * The setROPumpPWMPct function sets the RO pump PWM duty cycle. * The higher the PWM duty cycle (0..500), the faster the pump will go. * @details \b Inputs: none * @details \b Outputs: fpgaActuatorSetPoints.roPumpPWMDutyCyclePct * @param pwm PWM duty cycle magnitude * @return none *************************************************************************/ void setROPumpPWMPct( U16 pwm ) { fpgaActuatorSetPoints.roPumpPWMDutyCyclePct = pwm; } /*********************************************************************//** * @brief * The getROPumpPWMPct function gets a read back from FPGA of RO pump PWM * duty cycle. * @details \b Inputs: fpgaSensorReadings.roPumpPWMReadback * @details \b Outputs: none * @return measured speed (RPM) of the RO pump *************************************************************************/ U16 getROPumpPWMPct( void ) { return fpgaSensorReadings.roPumpPWMReadback; } /*********************************************************************//** * @brief * The getROPumpTachCount function gets the running 16-bit tachometer count * from the RO pump hall sensor. * @details \b Inputs: fpgaSensorReadings.roPumpTachCount * @details \b Outputs: none * @return RO pump tachometer count *************************************************************************/ U16 getROPumpTachCount( void ) { return fpgaSensorReadings.roPumpTachCount; } /*********************************************************************//** * @brief * The getFPGAPRiRawPressure function gets the PRi pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePri * @details \b Outputs: none * @return PRi pressure *************************************************************************/ S16 getFPGAPRiRawPressure( void ) { return fpgaSensorReadings.pressurePri; } /*********************************************************************//** * @brief * The getFPGAPRiRawTemperature function gets the PRi sensor temperature reading. * @details \b Inputs: fpgaSensorReadings.temperaturePri * @details \b Outputs: none * @return PRi sensor temperature *************************************************************************/ S16 getFPGAPRiRawTemperature( void ) { return fpgaSensorReadings.temperaturePri; } /*********************************************************************//** * @brief * The getFPGAPRiReadCount function gets the PRi sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPri * @details \b Outputs: none * @return PRi sensor read count *************************************************************************/ U08 getFPGAPRiReadCount( void ) { return fpgaSensorReadings.readCountPri; } /*********************************************************************//** * @brief * The getFPGAPRiErrorCount function gets the PRi sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPri * @details \b Outputs: none * @return PRi sensor error count *************************************************************************/ U08 getFPGAPRiErrorCount( void ) { return fpgaSensorReadings.errorCountPri; } /*********************************************************************//** * @brief * The getFPGAPRoRawPressure function gets the PRo pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePro * @details \b Outputs: none * @return PRo pressure *************************************************************************/ S16 getFPGAPRoRawPressure( void ) { return fpgaSensorReadings.pressurePro; } /*********************************************************************//** * @brief * The getFPGAPRoRawTemperature function gets the PRo sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperaturePro * @details \b Outputs: none * @return PRo sensor temperature *************************************************************************/ S16 getFPGAPRoRawTemperature( void ) { return fpgaSensorReadings.temperaturePro; } /*********************************************************************//** * @brief * The getFPGAPRoReadCount function gets the PRo sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPro * @details \b Outputs: none * @return PRo sensor read count *************************************************************************/ U08 getFPGAPRoReadCount( void ) { return fpgaSensorReadings.readCountPro; } /*********************************************************************//** * @brief * The getFPGAPRoErrorCount function gets the PRo sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPro * @details \b Outputs: none * @return PRo sensor error count *************************************************************************/ U08 getFPGAPRoErrorCount( void ) { return fpgaSensorReadings.errorCountPro; } /*********************************************************************//** * @brief * The getFPGAPC2oRawPressure function gets the PC2o pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePc2o * @details \b Outputs: none * @return PC2o pressure *************************************************************************/ S16 getFPGAPC2oRawPressure( void ) { return fpgaSensorReadings.pressurePc2o; } /*********************************************************************//** * @brief * The getFPGAPC2oRawTemperature function gets the PC2o sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperaturePc2o * @details \b Outputs: none * @return PC2o sensor temperature *************************************************************************/ S16 getFPGAPC2oRawTemperature( void ) { return fpgaSensorReadings.temperaturePc2o; } /*********************************************************************//** * @brief * The getFPGAPC2oReadCount function gets the PC2o sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPc2o * @details \b Outputs: none * @return PC2o sensor read count *************************************************************************/ U08 getFPGAPC2oReadCount( void ) { return fpgaSensorReadings.readCountPc2o; } /*********************************************************************//** * @brief * The getFPGAPC2oErrorCount function gets the PC2o sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPc2o * @details \b Outputs: none * @return PC2o sensor error count *************************************************************************/ U08 getFPGAPC2oErrorCount( void ) { return fpgaSensorReadings.errorCountPc2o; } /*********************************************************************//** * @brief * The getFPGAPPoRawPressure function gets the PPo pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePpo * @details \b Outputs: none * @return PPo pressure *************************************************************************/ S16 getFPGAPPoRawPressure( void ) { return fpgaSensorReadings.pressurePpo; } /*********************************************************************//** * @brief * The getFPGAPPoRawTemperature function gets the PPo sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperaturePpo * @details \b Outputs: none * @return PPo sensor temperature *************************************************************************/ S16 getFPGAPPoRawTemperature( void ) { return fpgaSensorReadings.temperaturePpo; } /*********************************************************************//** * @brief * The getFPGAPPoReadCount function gets the PPo sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPpo * @details \b Outputs: none * @return PPo sensor read count *************************************************************************/ U08 getFPGAPPoReadCount( void ) { return fpgaSensorReadings.readCountPpo; } /*********************************************************************//** * @brief * The getFPGAPPoErrorCount function gets the PPo sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPpo * @details \b Outputs: none * @return PPo sensor error count *************************************************************************/ U08 getFPGAPPoErrorCount( void ) { return fpgaSensorReadings.errorCountPpo; } /*********************************************************************//** * @brief * The getFPGAPMpRawPressure function gets the PMp pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePmp * @details \b Outputs: none * @return PMp pressure *************************************************************************/ S16 getFPGAPMpRawPressure( void ) { return fpgaSensorReadings.pressurePmp; } /*********************************************************************//** * @brief * The getFPGAPMpRawTemperature function gets the PMp sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperaturePmp * @details \b Outputs: none * @return PMp sensor temperature *************************************************************************/ S16 getFPGAPMpRawTemperature( void ) { return fpgaSensorReadings.temperaturePmp; } /*********************************************************************//** * @brief * The getFPGAPMpReadCount function gets the PMp sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPmp * @details \b Outputs: none * @return PMp sensor read count *************************************************************************/ U08 getFPGAPMpReadCount( void ) { return fpgaSensorReadings.readCountPmp; } /*********************************************************************//** * @brief * The getFPGAPMpErrorCount function gets the PMp sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPmp * @details \b Outputs: none * @return PMp sensor error count *************************************************************************/ U08 getFPGAPMpErrorCount( void ) { return fpgaSensorReadings.errorCountPmp; } /*********************************************************************//** * @brief * The getFPGAPPiRawPressure function gets the PPi pressure reading. * @details \b Inputs: fpgaSensorReadings.pressurePpi * @details \b Outputs: none * @return PPi pressure *************************************************************************/ S16 getFPGAPPiRawPressure( void ) { return fpgaSensorReadings.pressurePpi; } /*********************************************************************//** * @brief * The getFPGAPPiRawTemperature function gets the PPi sensor temperature. * @details \b Inputs: fpgaSensorReadings.temperaturePpi * @details \b Outputs: none * @return PPi sensor temperature *************************************************************************/ S16 getFPGAPPiRawTemperature( void ) { return fpgaSensorReadings.temperaturePpi; } /*********************************************************************//** * @brief * The getFPGAPPiReadCount function gets the PPi sensor read count. * @details \b Inputs: fpgaSensorReadings.readCountPpi * @details \b Outputs: none * @return PPi sensor read count *************************************************************************/ U08 getFPGAPPiReadCount( void ) { return fpgaSensorReadings.readCountPpi; } /*********************************************************************//** * @brief * The getFPGAPPiErrorCount function gets the PPi sensor error count. * @details \b Inputs: fpgaSensorReadings.errorCountPpi * @details \b Outputs: none * @return PPi sensor error count *************************************************************************/ U08 getFPGAPPiErrorCount( void ) { return fpgaSensorReadings.errorCountPpi; } /*********************************************************************//** * @brief * The getFPGAFloaterState function gets the floater level state. * @details \b Inputs: fpgaSensorReadings.levelSwitch * @details \b Outputs: none * @return floater level state *************************************************************************/ U08 getFPGAFloaterState( void ) { return fpgaSensorReadings.levelSwitch; } /*********************************************************************//** * @brief * The getFPGAFlowFMP function gets the FMP flow rate (in mL/min). * @details \b Inputs: fpgaSensorReadings.flowRateFmp * @details \b Outputs: none * @return FMP flow rate (in mL/min) *************************************************************************/ U16 getFPGAFlowFMP( void ) { return fpgaSensorReadings.flowRateFmp; } /*********************************************************************//** * @brief * The getFPGAFlowFMPTemp function gets the FMP flow sensor temperature, the * temperature of the fluid flowing through the sensor. * @details \b Inputs: fpgaSensorReadings.flowTempFmp * @details \b Outputs: none * @return FMP fluid temperature *************************************************************************/ U16 getFPGAFlowFMPTemp( void ) { return fpgaSensorReadings.flowTempFmp; } /*********************************************************************//** * @brief * The getFPGAFlowFMS function gets the FMS flow rate (in mL/min). * @details \b Inputs: fpgaSensorReadings.flowRateFms * @details \b Outputs: none * @return FMS flow rate (in mL/min) *************************************************************************/ U16 getFPGAFlowFMS( void ) { //return fpgaSensorReadings.flowRateFms; return 0; } /*********************************************************************//** * @brief * The getFPGAFlowFMSTemp function gets the FMS flow sensor temperature, the * temperature of the fluid flowing through the sensor. * @details \b Inputs: fpgaSensorReadings.flowTempFms * @details \b Outputs: none * @return FMS fluid temperature *************************************************************************/ U16 getFPGAFlowFMSTemp( void ) { //return fpgaSensorReadings.flowTempFms; return 0; } /*********************************************************************//** * @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; } /**@}*/