Index: firmware/App/Services/FpgaTD.c =================================================================== diff -u -r291d652fcd09b461728962a547d3b08163737d76 -r4f7855d894ddf2b62e7225050b5137d01862dd4b --- firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 291d652fcd09b461728962a547d3b08163737d76) +++ firmware/App/Services/FpgaTD.c (.../FpgaTD.c) (revision 4f7855d894ddf2b62e7225050b5137d01862dd4b) @@ -7,8 +7,8 @@ * * @file FpgaTD.c * -* @author (last) Jashwant Gantyada -* @date (last) 13-Mar-2026 +* @author (last) Varshini Nagabooshanam +* @date (last) 15-Jun-2026 * * @author (original) Sean Nash * @date (original) 01-Aug-2024 @@ -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 | @@ -102,10 +105,10 @@ U16 fpgaGenWrRd; ///< Reg 256. FPGA general read-back register (mirrored from a general write register in write page at addr 4). U08 errorCountProcessor; ///< Reg 258. Error count for processor communications. U08 errorCountPC; ///< Reg 259. Error count for TBD. - U08 sPumpDACRdStatus; ///< Reg 260. Syringe pump DAC read status. + U08 h10DACRdStatus; ///< Reg 260. H10 Syringe pump DAC read status. U08 h6HallStatus; ///< Reg 261. H6 hall sensor status. - U16 sPumpDACSet; ///< Reg 262. Syringe pump DAC setting. - U16 sPumpDACEEProm; ///< Reg 264. Syringe pump DAC EEProm data. + U16 h10DACSetting; ///< Reg 262. H10 Syringe pump DAC setting. + U16 h10DACEEProm; ///< Reg 264. H10 Syringe pump DAC EEProm data. U16 h14Pressure; ///< Reg 266. H14 raw pressure data. S16 h14Temperature; ///< Reg 268. H14 raw temperature data. U08 h14ReadCount; ///< Reg 270. H14 read count. @@ -126,15 +129,15 @@ S16 h19EncPosition; ///< Reg 298. H19 encoder position (1000 steps/rev). S16 h19MaxEncPosition; ///< Reg 300. H19 max encoder position. U16 GPIOReg; ///< Reg 302. GPIO register. - U08 HEPStatus; ///< Reg 304. HEP status register. - U08 HEPAdcReadCount; ///< Reg 305. HEP ADC read counter. - U08 HEPAdcDacStatus; ///< Reg 306. HEP ADC/DAC status register. - U08 HEPEncStatus; ///< Reg 307. HEP encoder status register. - S32 HEPEncPosition; ///< Reg 308. HEP encoder position. - U16 HEPAdcCh0; ///< Reg 312. HEP ADC channel 0 reading. - U16 HEPAdcCh1; ///< Reg 314. HEP ADC channel 1 reading. - U16 HEPAdcCh2; ///< Reg 316. HEP ADC channel 2 reading. - U16 HEPAdcCh3; ///< Reg 318. HEP ADC channel 3 reading. + U08 h10Status; ///< Reg 304. H10 Syringe pump status register. + U08 h10AdcReadCount; ///< Reg 305. H10 Syringe pump ADC read counter. + U08 h10AdcDacStatus; ///< Reg 306. H10 Syringe pump ADC/DAC status register. + U08 h10EncStatus; ///< Reg 307. H10 Syringe pump encoder status register. + S32 h10EncPosition; ///< Reg 308. H10 Syringe pump encoder position. + U16 h10AdcCh0; ///< Reg 312. H10 Syringe pump ADC channel 0 reading. + U16 h10AdcCh1; ///< Reg 314. H10 Syringe pump ADC channel 1 reading. + U16 h10AdcCh2; ///< Reg 316. H10 Syringe pump ADC channel 2 reading. + U16 h10AdcCh3; ///< Reg 318. H10 Syringe pump ADC channel 3 reading. U16 fpgaAdcTemperature; ///< Reg 320. FPGA ADC temperature. U16 fpga1msTimerCounter; ///< Reg 322. FPGA 1 millisecond timer counter. U16 alarmBuzzerCurrentAdc; ///< Reg 324. Alarm buzzer current ADC reading. @@ -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. + U08 sPumpDacRdByte2; ///< Reg 379. + U08 sPumpDacRdByte3; ///< Reg 380. + U08 sPumpDacRdByte4; ///< Reg 381. + U08 sPumpDacRdByte5; ///< Reg 382. + U08 sPumpDacRdByte6; ///< Reg 383. + 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. @@ -189,11 +204,12 @@ U08 h1Control; ///< Reg 30. H1 control register. U08 h1h19ValveEncoderControl; ///< Reg 31. H1/H19 valve encoder control register. U08 alarmControl; ///< Reg 32. Alarm audio control register. - U08 syrPumpControl; ///< Reg 33. Syringe pump control register. - U32 syrPumpSpeed; ///< Reg 34. Syringe pump time between step toggle (1/2 step period). - U16 syrPumpDACData; ///< Reg 38. Syringe pump DAC data (12 bits). - U16 syrPumpDACControl; ///< Reg 40. Syringe pump ADC and DAC control register. - U16 h12Period; ///< Reg 42. H12 Air pump time period for each count in PWM register. + 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). + 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; @@ -950,21 +966,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 @@ -1341,4 +1342,337 @@ } } +/*********************************************************************//** + * @brief + * The setFPGASyringePumpControlFlags function sets the syringe pump control + * register per given bit flags. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param bitFlags control bit settings for syringe pump + * @return none + *************************************************************************/ +void setFPGASyringePumpControlFlags( U08 bitFlags ) +{ + return fpgaActuatorSetPoints.h10Control = bitFlags; +} +/*********************************************************************//** + * @brief + * The setFPGASyringePumpADCandDACControlFlags function sets the syringe pump + * ADC/DAC control register per given bit flags. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param bitFlags ADC/DAC control bit settings for syringe pump + * @return none + *************************************************************************/ +void setFPGASyringePumpADCandDACControlFlags( U08 bitFlags ) +{ + fpgaActuatorSetPoints.h10DACControl = bitFlags; +} + +/*********************************************************************//** + * @brief + * The setFPGASyringePumpDACOutputLevel function sets the syringe pump force + * sensor DAC output level register to a given value. + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param counts level to set syringe pump force sensor DAC to + * @return none + *************************************************************************/ +void setFPGASyringePumpDACOutputLevel( U16 counts ) +{ + fpgaActuatorSetPoints.h10DACData = counts; +} + +/*********************************************************************//** + * @brief + * The setFPGASyringePumpStepToggleTime function sets the syringe pump stepper + * toggle time register to a given period (in uSec). + * @details \b Inputs: none + * @details \b Outputs: fpgaActuatorSetPoints + * @param microSeconds toggle the stepper motor at this time interval to set pump speed + * @return none + *************************************************************************/ +void setFPGASyringePumpStepToggleTime( U32 microSeconds ) +{ + fpgaActuatorSetPoints.h10Speed = microSeconds; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpStatus function gets the latest syringe pump status + * register reading. Bit 0 indicates a fault. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump status reading + *************************************************************************/ +U08 getFPGASyringePumpStatus( void ) +{ + return fpgaSensorReadings.h10Status; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCReadCounter function gets the latest syringe pump + * ADC read counter. Counter is 8-bit and rolls over when exceeding 255. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC read counter + *************************************************************************/ +U08 getFPGASyringePumpADCReadCounter( void ) +{ + return fpgaSensorReadings.h10AdcReadCount; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCandDACStatus function gets the latest syringe pump + * ADC/DAC status register reading. + * Bit 7 = DAC write and read-back done + * Bit 6 = I2C error on DAC data transfer + * Bit 0..5 = count of I2C errors, rolls over after 63 + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC/DAC status reading + *************************************************************************/ +U08 getFPGASyringePumpADCandDACStatus( void ) +{ + return fpgaSensorReadings.h10AdcDacStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpEncoderStatus function gets the latest syringe pump + * encoder status register reading. + * Bit 7 = direction (0=fwd, 1=rev) + * Bit 0..5 = direction error count (# of errors after power up, rolls over after 63) + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump encoder status reading + *************************************************************************/ +U08 getFPGASyringePumpEncoderStatus( void ) +{ + return fpgaSensorReadings.h10EncStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpEncoderPosition function gets the latest syringe pump + * encoder position reading. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump encoder position reading + *************************************************************************/ +U32 getFPGASyringePumpEncoderPosition( void ) +{ + return fpgaSensorReadings.h10EncPosition; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel0 function gets the latest syringe pump ADC + * channel 0 register reading (syringe pump force sensor). + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC channel 0 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel0( void ) +{ + return fpgaSensorReadings.h10AdcCh0; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel1 function gets the latest syringe pump ADC + * channel 1 register reading (syringe detection switch). + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC channel 1 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel1( void ) +{ + return fpgaSensorReadings.h10AdcCh1; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel2 function gets the latest syringe pump ADC + * channel 2 register reading (syringe pump home position sensor). + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC channel 2 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel2( void ) +{ + return fpgaSensorReadings.h10AdcCh2; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpADCChannel3 function gets the latest syringe pump ADC + * channel 3 register reading. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump ADC channel 3 reading + *************************************************************************/ +U16 getFPGASyringePumpADCChannel3( void ) +{ + return fpgaSensorReadings.h10AdcCh3; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpDACStatus function gets the latest syringe pump + * DAC status. + * Bit 0: PD0 + * Bit 1: PD1 + * Bit 2: POR + * Bit 3: Ready (not busy) + * Bits 4..7: N/A + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump DAC status reading + *************************************************************************/ +U08 getFPGASyringePumpDACStatus( void ) +{ + return fpgaSensorReadings.h10DACRdStatus; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpDACSetting function gets the latest syringe pump + * DAC setting. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump DAC setting + *************************************************************************/ +U16 getFPGASyringePumpDACSetting( void ) +{ + return fpgaSensorReadings.h10DACSetting; +} + +/*********************************************************************//** + * @brief + * The getFPGASyringePumpDACStoredSetting function gets the latest syringe + * pump DAC setting stored in sensor's EEPROM. + * @details \b Inputs: fpgaSensorReadings + * @details \b Outputs: none + * @return last syringe pump DAC setting stored in EEPROM + *************************************************************************/ +U16 getFPGASyringePumpDACStoredSetting( void ) +{ + 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: fpgaActuatorSetPoints +* @details \b Outputs: none +* @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: none + * @details \b Outputs: fpgaSensorReadings + * @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: none + * @details \b Outputs: fpgaSensorReadings + * @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: none +* @details \b Outputs: fpgaSensorReadings +* @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: none +* @details \b Outputs: fpgaSensorReadings +* @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: none +* @details \b Outputs: fpgaSensorReadings +* @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: none +* @details \b Outputs: fpgaSensorReadings +* @return Heart rate in BPM. +*************************************************************************/ +U16 getNIBPHeartRate( void ) +{ + return fpgaSensorReadings.bpHr; +} + /**@}*/