Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r37294a71c0b3e3ca67ccb10b85536d124d3ef028 -r0eb4b76d5209ff2adf583a9ab6ec8f87a5aa011b --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 37294a71c0b3e3ca67ccb10b85536d124d3ef028) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 0eb4b76d5209ff2adf583a9ab6ec8f87a5aa011b) @@ -46,7 +46,9 @@ #define MIN_POWER_ON_TIME_FOR_COMM_FAILS ( 1 * MS_PER_SECOND ) ///< Allow FPGA comm errors for first second after power-up #define FPGA_H4_ENABLE_BIT_MASK 0x01 ///< Bit mask for enabling the blood pump. -#define FPGA_H4_DIRECTION_REV_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction. +#define FPGA_H4_DIR_FORWARD_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction. +#define FPGA_H4_BRAKE_AND_HOLD_TORQUE 0x06 ///< Bit mask for braking the blood pump while holding the torque of the pump. +#define FPGA_H4_BIT_2_INDEX 2 ///< Blood pump bit 2 index. #define FPGA_H13_OPEN_BIT_MASK 0x01 ///< Bit mask for setting H13 valve position to open. #define FPGA_H20_OPEN_BIT_MASK 0x02 ///< Bit mask for setting H20 valve position to open. @@ -148,7 +150,20 @@ S16 h4RotorHallCount; ///< Reg 344. H4 rotor count from hall sensor. U08 h6RotorStatus; ///< Reg 346. H6 rotor status. U08 reserved5; ///< - U16 h12Speed; ///< Reg 348. H12 speed (in RPM). + U16 h12Speed; ///< Reg 348. H12 speed (air pump in RPM). + U16 rotorRevsCounter; ///< Reg 350. Rotor revs counter + U16 baroManufactInfo; ///< Reg 352. Baro sensor manufacturing information. + U16 baroPresSensitivity; ///< Reg 354. Baro sensor prom coefficient 1. + U16 baroPresOffset; ///< Reg 356. Baro sensor prom coefficient 2. + U16 baroTempCoeffOfPresSense; ///< Reg 358. Baro sensor prom coefficient 3. + U16 baroTempCoeffPresOffset; ///< Reg 360. Baro sensor prom coefficient 4. + U16 baroRefTemp; ///< Reg 362. Baro sensor prom coefficient 5. + U16 baroTempCoeffOfTemp; ///< Reg 364. Baro sensor prom coefficient 6. + U16 baroPromCRC; ///< Reg 366. Baro prom CRC. + U32 baroPressure; ///< Reg 368. Baro pressure value in counts. + U32 baroTemperature; ///< Reg 372. Baro temperature value in counts. + U08 baroReadCount; ///< Reg 376. Baro read count. + U08 baroErrorCount; ///< Reg 377. Baro error count. } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -467,21 +482,23 @@ * The setH4Direction function sets the direction for the blood pump * motor to the given direction. * @details \b Inputs: none - * @details \b Outputs: Blood pump motor direction is set (bit 1 of BP control register). + * @details \b Outputs: Blood pump motor direction is set (bit 1 and 2 of BP control register). * 0 - CW (forward) * 1 - CCW (reverse) * @param dir the desired direction for the blood pump motor (fwd or rev) * @return none *************************************************************************/ void setH4Direction( MOTOR_DIR_T dir ) { - if ( MOTOR_DIR_REVERSE == dir ) + if ( MOTOR_DIR_FORWARD == dir ) { - fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_REV_BIT_MASK; + // First clear bit 2 if it is on otherwise the pump can be kept on brake + fpgaActuatorSetPoints.h4Control &= ~( 1 << FPGA_H4_BIT_2_INDEX ); + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIR_FORWARD_BIT_MASK; } else { - fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIRECTION_REV_BIT_MASK); + fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIR_FORWARD_BIT_MASK); } } @@ -514,6 +531,19 @@ /*********************************************************************//** * @brief + * The setH4BrakeAndHoldTorque function brakes the pump while holding the torque. + * The pump will not coast. + * @details \b Inputs: none + * @details \b Outputs: Blood pump motor control register + * @return none + *************************************************************************/ +void setH4BrakeAndHoldTorque( void ) +{ + fpgaActuatorSetPoints.h4Control |= FPGA_H4_BRAKE_AND_HOLD_TORQUE; +} + +/*********************************************************************//** + * @brief * The getH6Status function gets the latest blood pump hall sensor status. * Bit 0: 1=Magnet is detected (used for homing in forward direction) * Bit 1: 0=Reverse pump direction detected, 1=Forward pump direction detected @@ -559,6 +589,20 @@ /*********************************************************************//** * @brief + * The getH4TorqueCount function gets the latest blood pump + * torque count. Count is the period in 10 uS resolution. Firmware converts + * the period to frequency and 1kHz = 10mN.m. + * @details \b Inputs: fpgaSensorReadings.h4Torque + * @details \b Outputs: none + * @return Latest blood pump torque sensor count reading. + *************************************************************************/ +S16 getH4TorqueCount( void ) +{ + return fpgaSensorReadings.h4Torque; +} + +/*********************************************************************//** + * @brief * The setH5ControlFlags function sets the control flags for the H5 ejector * stepper motor. * @note Bit 0 - MS1 (bit 1 of microstepping configuration setting) @@ -715,6 +759,81 @@ /*********************************************************************//** * @brief + * The getH23MfgCoeffs function updates the baro sensor's manufacturing + * information into the provided buffer. + * @details \b Inputs: fpgaSensorReadings.baroManufactInfo, + * fpgaSensorReadings.baroPromCoeff1, fpgaSensorReadings.baroPromCoeff2, + * fpgaSensorReadings.baroPromCoeff3, fpgaSensorReadings.baroPromCoeff4, + * fpgaSensorReadings.baroPromCoeff5, fpgaSensorReadings.baroPromCoeff6, + * fpgaSensorReadings.baroPromCRC + * @details \b Outputs: none + * @param baroMfgCoeffs The baro sensor mfg info buffer. + * @return none + *************************************************************************/ +void getH23MfgCoeffs( BARO_PRES_SENSOR_MFG_T* baroMfgCoeffs ) +{ + baroMfgCoeffs->baroManufactInfo = fpgaSensorReadings.baroManufactInfo; + baroMfgCoeffs->baroPresSensitivity = fpgaSensorReadings.baroPresSensitivity; + baroMfgCoeffs->baroPresOffset = fpgaSensorReadings.baroPresOffset; + baroMfgCoeffs->baroTempCoeffOfPresSense = fpgaSensorReadings.baroTempCoeffOfPresSense; + baroMfgCoeffs->baroTempCoeffPresOffset = fpgaSensorReadings.baroTempCoeffPresOffset; + baroMfgCoeffs->baroRefTemp = fpgaSensorReadings.baroRefTemp; + baroMfgCoeffs->baroTempCoeffOfTemp = fpgaSensorReadings.baroTempCoeffOfTemp; + baroMfgCoeffs->baroPromCRC = fpgaSensorReadings.baroPromCRC; +} + +/*********************************************************************//** + * @brief + * The getH23Pressure function reads the baro sensor pressure. + * @details \b Inputs: fpgaSensorReadings.baroPressure + * @details \b Outputs: none + * @return Latest baro sensor pressure. + *************************************************************************/ +U32 getH23Pressure( void ) +{ + return ( fpgaSensorReadings.baroPressure & MASK_OFF_U32_MSB ); +} + +/*********************************************************************//** + * @brief + * The getH23Temperature function reads the baro sensor temperature. + * @details \b Inputs: fpgaSensorReadings.baroTemperature + * @details \b Outputs: none + * @return Latest baro sensor temperature. + *************************************************************************/ +U32 getH23Temperature( void ) +{ + return ( fpgaSensorReadings.baroTemperature & MASK_OFF_U32_MSB ); +} + +/*********************************************************************//** + * @brief + * The getH23ReadCounter function gets the latest baro pressure + * sensor read counter. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest baro pressure sensor read counter + *************************************************************************/ +U08 getH23ReadCounter( void ) +{ + return fpgaSensorReadings.baroReadCount; +} + +/*********************************************************************//** + * @brief + * The getH23ErrorCounter function gets the latest baro pressure + * sensor error counter. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return latest baro pressure sensor error counter + *************************************************************************/ +U08 getH23ErrorCounter( void ) +{ + return fpgaSensorReadings.baroErrorCount; +} + +/*********************************************************************//** + * @brief * The getFPGABackupAlarmAudioCurrent function gets the latest piezo alarm * audio current reading. * @details \b Inputs: fpgaSensorReadings