Index: firmware/App/Services/FpgaDD.c =================================================================== diff -u -r8e93771bd0894bf1308747d1e520d620d7821fab -r901d84db197c6d828e4bc58c557ec5ebbd1c557b --- firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 8e93771bd0894bf1308747d1e520d620d7821fab) +++ firmware/App/Services/FpgaDD.c (.../FpgaDD.c) (revision 901d84db197c6d828e4bc58c557ec5ebbd1c557b) @@ -25,6 +25,7 @@ #include "Comm.h" #include "Compatible.h" #include "FPGA.h" +#include "FpgaDD.h" #include "Messaging.h" #include "OperationModes.h" #include "PersistentAlarm.h" @@ -133,6 +134,9 @@ #define FPGA_D42_BLOOD_LEAK_STATUS_MASK 0x04 ///< Bit mask for blood leak detector. #define FPGA_D42_BLOOD_LEAK_ST_BIT_INDEX 2 ///< Bit index for the blood leak self test status bit. +#define GPIO_AC_SWITCH_MASK 0x10U ///< AC switch status bit mask. +#define FPGA_GPIO_LEAK_SENSOR_MASK 0x02U ///< GPIO_Status Bit 1 per HDD. + #define MAX_PUMP_SPEED 3000.0F ///< Maxon controller pump maximum speed #define PUMP_SPEED_OFFSET 168.7F ///< Speed Scale adjustment intercept factor #define PUMP_SPEED_FULL_SCALE 3187.0F ///< Speed scale adjustment slope factor @@ -147,7 +151,7 @@ U08 fpgaRevLab; ///< Reg 3. FPGA revision (lab) being reported } FPGA_HEADER_T; // read only on FPGA -// Remove when Beta 1.9 is obsolete +// TODO: Remove when Beta 1.9 is obsolete /// FPGA sensor readings struct. typedef struct { @@ -354,7 +358,7 @@ U16 fpgaAvailableRegister5; ///< Reg 614. Available register 5 U16 fpgaD76PumpStepCountStatus; ///< Reg 616. UF pump revolution down count status U08 fpgaD76PumpFault; ///< Reg 618: UF pump fault - U08 fpgaHallSensorStatus; ///< reg 619: Hall sensor status + U08 fpgaHallSensorStatus; ///< Reg 619: HDF Hall sensor status S16 pressureP46; ///< Reg 620. P46 pressure data. U16 temperatureP46; ///< Reg 622. P46 temperature data. @@ -455,7 +459,7 @@ U08 fpgaP18CalMemCounter; ///< Reg 820. TBD } DD_FPGA_SENSORS_T; -// Remove when Beta 1.9 is obsolete +// TODO: Remove when Beta 1.9 is obsolete typedef struct { U16 fpgaValveControl; ///< Reg 04. Valve control register @@ -616,7 +620,7 @@ U08 fpgaConSensD43Control; ///< Reg 118. Conductivity/Temperature Sensors D43 Control registers U16 fpgaConSensD43_Addrs; ///< Reg 119. D43 Initialization Address register U32 fpgaConSensD43_Data_In; ///< Reg 121. D43 Initialization data register - U08 unsuedRegister; ///< Reg 125. Unused register. + U08 unusedRegister3; ///< Reg 125. Unused register 3 U32 fpgaD11PumpSpeed; ///< Reg 126. Acid Concentrate Pump Speed/RPM Control U32 fpgaD10PumpSpeed; ///< Reg 130. BiCarb Concentrate Pump Speed/RPM Control U32 fpgaD76PumpSpeed; ///< Reg 134. UF Pump Speed/RPM Control @@ -666,7 +670,7 @@ fpgaActuatorSetPoints.fpgaDDSpareValvePWMControl = FPGA_ENABLE_UF_VALVES_PWM; fpgaActuatorSetPoints.fpgaADCControl = FPGA_ADC_AUTO_READ_ENABLE; -#if 1 // Remove when Beta 1.9 is obsolete +#if 1 // TODO: Remove when Beta 1.9 is obsolete // Set the valve control mode and default state of valve for Beta 1.9 HW fpgaBeta19ActuatorSetPoints.fpgaValveControl = FPGA_ENABLE_VALVES_CONTROL; fpgaBeta19ActuatorSetPoints.fpgaValvePWMEnable = FPGA_ENABLE_VALVES_PWM; @@ -784,21 +788,22 @@ * The setFPGADDValveStates function sets the DD valve states with a 16-bit * set 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 - D53Valve.\n + * 0 - D14Valve.\n * 1 - D52Valve.\n * 2 - D8Valve.\n * 3 - D54Valve.\n - * 4 - D14Valve.\n - * 5 - D65Valve.\n + * 4 - Unused.\n + * 5 - D34Valve.\n * 6 - D64Valve.\n * 7 - D31Valve.\n - * 8 - D34Valve.\n + * 8 - D65Valve.\n * 9 - D35Valve.\n * 10 - D40Valve.\n * 11 - D47Valve.\n * 12 - D3Valve.\n - * 13 - M4Valve.\n - * 14..15 - reserved or unused. + * 13 - D80Valve.\n + * 14 - D81Valve.\n + * 15 - D85Valve.\n * @details \b Inputs: none * @details \b Outputs: fpgaValveControl * @param valveStates bit mask for the various valve states @@ -836,12 +841,15 @@ * @brief * The setFPGASpareValveStates function sets the DD spare valve states with a * 8-bit set 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 - Not used.\n - * 1 - Not used.\n - * 2 - Not used.\n - * 3 - Not used.\n - * 4..7 - Unused or reserved.\n + * meaning "de-energized". Bit positions per HDD (2.0 valves - beta 1/1.9 to be deprecated): + * 0 - D88 valve.\n + * 1 - D83 valve.\n + * 2 - D91 valve.\n + * 3 - D104 valve.\n + * 4 - D95 valve.\n + * 5 - Spare valve 5.\n + * 6 - D100 valve.\n + * 7 - Spare valve 7.\n * @details \b Inputs: none * @details \b Outputs: fpgaDDSpareValveControl * @param valveStates bit mask for the spare valve states @@ -1076,7 +1084,7 @@ *************************************************************************/ void setFPGAD48PumpSpeed( U16 speed ) { -#ifdef __MAXON_SPEED_UPDATE__ +#ifdef __MAXON_SPEED_UPDATE__ //TODO: Enable for Beat 1/1.9 with Diener silencer 2000 pump. { U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); SET_FPGA_ACTUATOR_FIELD( fpgaD48PumpSpeed, currentSpeed ); @@ -1099,7 +1107,7 @@ *************************************************************************/ void setFPGAD12PumpSpeed( U16 speed ) { -#ifdef __MAXON_SPEED_UPDATE__ +#ifdef __MAXON_SPEED_UPDATE__ /* Enable for B1.0/B1.9 with Diener Silencer 2000 pumps */ { U16 currentSpeed =(U16)( ( ( speed + PUMP_SPEED_OFFSET ) / PUMP_SPEED_FULL_SCALE ) * MAX_PUMP_SPEED ); SET_FPGA_ACTUATOR_FIELD( fpgaD12PumpSpeed, currentSpeed ); @@ -3080,7 +3088,8 @@ *************************************************************************/ U16 getFPGAD63LevelSensor( void ) { - U08 result; + U16 result; + #if 1 // Remove when Beta 1.9 is obsolete if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) == TRUE ) { @@ -3107,7 +3116,8 @@ *************************************************************************/ U16 getFPGAD98LevelSensor( void ) { - U08 result; + U16 result; + #if 1 // Remove when Beta 1.9 is obsolete if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) == TRUE ) { @@ -3134,7 +3144,8 @@ *************************************************************************/ U16 getFPGAD46LevelSensor( void ) { - U08 result; + U16 result; + #if 1 // Remove when Beta 1.9 is obsolete if ( getTestConfigStatus( TEST_CONFIG_DD_FP_ENABLE_BETA_2_0_HW ) == TRUE ) { @@ -3371,6 +3382,52 @@ /*********************************************************************//** * @brief + * The getGPIOStatusFromFPGA function returns the latest GPIO status register + * value reported by the DD FPGA. + * @details \b Inputs: fpgaSensorReadings.fpgaGPIOStatus (via FpgaDD service) + * @details \b Outputs: none + * @return GPIO status register value (bit-mapped per HDD definition) + *************************************************************************/ +U08 getGPIOStatusFromFPGA( void ) +{ + return getFPGAGPIOStatus(); +} + +/*********************************************************************//** + * @brief + * The getACSwitchStatus function returns the AC switch (concentrate cap + * switch) status from the FPGA GPIO register. + * @details \b Inputs: fpgaSensorReadings.fpgaGPIOStatus (via getGPIOStatusFromFPGA) + * @details \b Outputs: none + * @return TRUE if AC switch is asserted, FALSE otherwise + *************************************************************************/ +BOOL getACSwitchStatus( void ) +{ + U08 gpioStatus = getGPIOStatusFromFPGA(); + BOOL isAsserted = ( ( gpioStatus & GPIO_AC_SWITCH_MASK ) == 0U ) ? TRUE : FALSE; + + return isAsserted; +} + +/*********************************************************************//** + * @brief + * The getFPGALeakSensorStatus function returns the leak sensor status from + * the FPGA GPIO_Status register (Bit 1 per HDD). Application should trigger + * an alarm when LEAK_SENSOR_DETECTED is returned. + * @details \b Inputs: fpgaSensorReadings.fpgaGPIOStatus + * @details \b Outputs: none + * @return FPGA_GPIO_LEAK_SENSOR_NOT_DETECTED or FPGA_GPIO_LEAK_SENSOR_DETECTED + *************************************************************************/ +FPGA_GPIO_LEAK_SENSOR_STATUS_T getFPGALeakSensorStatus( void ) +{ + U08 gpioStatus = getFPGAGPIOStatus(); + FPGA_GPIO_LEAK_SENSOR_STATUS_T status = ( ( gpioStatus & FPGA_GPIO_LEAK_SENSOR_MASK ) != 0U ) ? FPGA_GPIO_LEAK_SENSOR_NOT_DETECTED : FPGA_GPIO_LEAK_SENSOR_DETECTED; + + return status; +} + +/*********************************************************************//** + * @brief * The getFPGATempTax1 function gets the Tax1 temperature sensor reading. * @details \b Inputs: fpgaSensorReadings * @details \b Outputs: none