Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r927dfd6e109af46160e5aef687f1b7c286d24703 -r3f325a9fe7cbfb660a3ddf274d471d635266c586 --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 927dfd6e109af46160e5aef687f1b7c286d24703) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 3f325a9fe7cbfb660a3ddf274d471d635266c586) @@ -8,7 +8,7 @@ * @file FpgaTD.c * * @author (last) Varshini Nagabooshanam -* @date (last) 15-Jun-2026 +* @date (last) 05-Aug-2026 * * @author (original) Sean Nash * @date (original) 01-Aug-2024 @@ -46,9 +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_DIR_FORWARD_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction. +#define FPGA_H4_DIRECTION_A_BIT_MASK 0x02 ///< Bit mask for setting the blood pump direction A setting. +#define FPGA_H4_DIRECTION_B_BIT_MASK 0x04 ///< Bit mask for setting the blood pump direction B setting. #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. @@ -71,6 +71,9 @@ #define FPGA_H18_BUBBLE_STATUS_MASK 0x0002 ///< Bit mask for venous air bubble detector input status. #define FPGA_H18_BUBBLE_SELF_TEST_CMD 0x08 ///< Bit for venous air bubble detector self-test command. +#define FPGA_NIBP_CMD_MASK 0x0F ///< Bit mask for NIBP command bits +#define FPGA_NIBP_CMD_RDY 0x10 ///< NIBP command ready pulse bit + /// Control bits to run syringe pump in reverse direction // TODO - move to syringe pump controller unit when implemented. static const U08 SYRINGE_PUMP_CONTROL_RUN_REVERSE = SYRINGE_PUMP_CONTROL_SLEEP_OFF | SYRINGE_PUMP_CONTROL_NOT_RESET | @@ -165,6 +168,18 @@ U32 baroTemperature; ///< Reg 372. Baro temperature value in counts. U08 baroReadCount; ///< Reg 376. Baro read count. U08 baroErrorCount; ///< Reg 377. Baro error count. + U08 notUsed; ///< Reg 378. Not used + U08 h10DacRdByte2; ///< Reg 379. H10 Syringe pump DAC Read Byte 2. + U08 h10DacRdByte3; ///< Reg 380. H10 Syringe pump DAC Read Byte 3. + U08 h10DacRdByte4; ///< Reg 381. H10 Syringe pump DAC Read Byte 4. + U08 h10DacRdByte5; ///< Reg 382. H10 Syringe pump DAC Read Byte 5. + U08 h10DacRdByte6; ///< Reg 383. H10 Syringe pump DAC Read Byte 6. + U08 nibpCtlStatus; ///< Reg 384. NIBP control status register. + U08 nibpStatusResp; ///< Reg 385. NIBP response status register. + S16 cuffPressure; ///< Reg 386. NIBP cuff pressure in mmHg. + U16 bpSystolic; ///< Reg 388. Systolic BP in mmHg. + U16 bpDiastolic; ///< Reg 390. Diastolic BP in mmHg. + U16 bpHr; ///< Reg 392. Heart rate in BPM. } FPGA_SENSORS_T; /// Record structure for FPGA continuous priority writes. @@ -197,7 +212,9 @@ U08 h10Control; ///< Reg 33. H10 Syringe pump control register. U32 h10Speed; ///< Reg 34. H10 Syringe pump time between step toggle (1/2 step period). U16 h10DACData; ///< Reg 38. H10 Syringe pump DAC data (12 bits). - U16 h10DACControl; ///< Reg 40. H10 Syringe pump ADC and DAC control register. + U08 h10DACControl; ///< Reg 40. H10 Syringe pump ADC and DAC control register. + U16 nibpCtl; ///< Reg 41. NIBP control register. + U16 nibpInflate; ///< Reg 42. NIBP inflate pressure register. U32 h5SetSpeed; ///< Reg 44. H5 ejector motor set speed. } FPGA_ACTUATORS_T; @@ -487,23 +504,28 @@ * 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 and 2 of BP control register). - * 0 - CW (forward) - * 1 - CCW (reverse) + * @details \b Outputs: Blood pump motor direction is set + * (bit 1 (A) and 2 (B) of BP control register). + * AB + * 00 - Power stage enabled + * 01 - CCW (reverse) + * 10 - CW (forward) + * 11 - Braking and holding torque * @param dir the desired direction for the blood pump motor (fwd or rev) * @return none *************************************************************************/ void setH4Direction( MOTOR_DIR_T dir ) { + // This clears bit 2 for both forward and reverse directions if ( MOTOR_DIR_FORWARD == dir ) { - // 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; + fpgaActuatorSetPoints.h4Control &= ~FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_A_BIT_MASK; } else { - fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIR_FORWARD_BIT_MASK); + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control &= ~((U08)FPGA_H4_DIRECTION_A_BIT_MASK); } } @@ -519,6 +541,12 @@ void setH4SetSpeed( U16 rpm ) { fpgaActuatorSetPoints.h4SetSpeed = rpm; + // if commanded speed is zero, apply brake + if ( 0 == rpm ) + { + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_B_BIT_MASK; + fpgaActuatorSetPoints.h4Control |= FPGA_H4_DIRECTION_A_BIT_MASK; + } } /*********************************************************************//** @@ -954,21 +982,6 @@ /*********************************************************************//** * @brief - * The setH12AirPumpMotorPWMCntTime function sets the air pump motor PWM count - * time in increments of 10 nS. The PWM period will then be 255 x given - * value x 10 nS. - * @details \b Inputs: fpgaActuatorSetPoints.h12Period - * @details \b Outputs: fpgaActuatorSetPoints.h12Period - * @param tenNS The time associated with each PWM count in power level setting. - * @return none - *************************************************************************/ -void setH12AirPumpMotorPWMCntTime( U16 tenNS ) -{ - fpgaActuatorSetPoints.h12Period = tenNS; -} - -/*********************************************************************//** - * @brief * The H18BubbleDetected function determines whether H18 bubble detector * sensor is currently detecting a bubble. * @details \b Inputs: fpgaSensorReadings @@ -1567,4 +1580,116 @@ return fpgaSensorReadings.h10DACEEProm; } +/*********************************************************************//** +* @brief +* The setNIBPCommand function sets the FPGA NIBP command bits and pulses +* the command ready bit to notify the FPGA that a new NIBP command is +* available. +* @details \b Inputs: none +* @details \b Outputs: fpgaActuatorSetPoints +* @param command Blood pressure command to send to the FPGA. +* @return none +*************************************************************************/ +void setNIBPCommand( U08 command ) +{ + fpgaActuatorSetPoints.nibpCtl &= ~FPGA_NIBP_CMD_MASK; + fpgaActuatorSetPoints.nibpCtl |= ( (U16)command & FPGA_NIBP_CMD_MASK ); + if ( 0 == command ) + { + fpgaActuatorSetPoints.nibpCtl &= ~FPGA_NIBP_CMD_RDY; + } + else + { + fpgaActuatorSetPoints.nibpCtl |= FPGA_NIBP_CMD_RDY; + } +} + +/*********************************************************************//** +* @brief +* The setNIBPInflatePressure function sets the initial NIBP cuff inflate +* pressure register. +* @details \b Inputs: none +* @details \b Outputs: fpgaActuatorSetPoints.nibpInflate +* @param pressure Initial cuff inflation pressure in mmHg. +* @return none +*************************************************************************/ +void setNIBPInflatePressure( U16 pressure ) +{ + fpgaActuatorSetPoints.nibpInflate = pressure; +} + +/********************************************************************//** + * @brief + * The getNIBPControlStatus function returns the FPGA NIBP control status. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return FPGA NIBP control status register. + ***************************************************************************/ +U08 getNIBPControlStatus( void ) +{ + return fpgaSensorReadings.nibpCtlStatus; +} + +/*********************************************************************//** + * @brief + * The getNIBPStatusResponse function returns the FPGA NIBP response status. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return FPGA NIBP response status register. + ***************************************************************************/ +U08 getNIBPStatusResponse( void ) +{ + return fpgaSensorReadings.nibpStatusResp; +} + +/*********************************************************************//** +* @brief +* The getNIBPCuffPressure function returns the FPGA NIBP cuff pressure. +* @details \b Inputs: fpgaSensorReadings +* @details \b Outputs: none +* @return NIBP cuff pressure in mmHg. +*************************************************************************/ +S16 getNIBPCuffPressure( void ) +{ + return fpgaSensorReadings.cuffPressure; +} + +/*********************************************************************//** +* @brief +* The getNIBPSystolicPressure function returns the FPGA systolic blood +* pressure measurement. +* @details \b Inputs: fpgaSensorReadings +* @details \b Outputs: none +* @return Systolic blood pressure in mmHg. +*************************************************************************/ +U16 getNIBPSystolicPressure( void ) +{ + return fpgaSensorReadings.bpSystolic; +} + +/*********************************************************************//** +* @brief +* The getNIBPDiastolicPressure function returns the FPGA diastolic blood +* pressure measurement. +* @details \b Inputs: fpgaSensorReadings +* @details \b Outputs: none +* @return Diastolic blood pressure in mmHg. +*************************************************************************/ +U16 getNIBPDiastolicPressure( void ) +{ + return fpgaSensorReadings.bpDiastolic; +} + +/*********************************************************************//** +* @brief +* The getNIBPHeartRate function returns the FPGA heart rate measurement. +* @details \b Inputs: fpgaSensorReadings +* @details \b Outputs: none +* @return Heart rate in BPM. +*************************************************************************/ +U16 getNIBPHeartRate( void ) +{ + return fpgaSensorReadings.bpHr; +} + /**@}*/