Index: firmware/App/Controllers/PresOccl.c =================================================================== diff -u -re963db266989fd82b8b6023bb1a139afcb45c091 -rc9e1a93ccd8cfbdc9737c8ffc9e6a3dbe9ba7c44 --- firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision e963db266989fd82b8b6023bb1a139afcb45c091) +++ firmware/App/Controllers/PresOccl.c (.../PresOccl.c) (revision c9e1a93ccd8cfbdc9737c8ffc9e6a3dbe9ba7c44) @@ -39,8 +39,8 @@ #define VENOUS_PRESSURE_OFFSET ( 1638 ) ///< Offset for 14-bit venous pressure sensor reading. #define VENOUS_PRESSURE_SCALE ( 14745 - VENOUS_PRESSURE_OFFSET ) ///< Scale for venous pressure sensor. -#define VENOUS_PRESSURE_MIN ( 30.0 ) ///< Minimum of scale for venous pressure sensor reading (in TBD u/m). -#define VENOUS_PRESSURE_MAX ( 90.0 ) ///< Maximum of scale for venous pressure sensor reading (in TBD u/m). +#define VENOUS_PRESSURE_MIN ( -30.0 ) ///< Minimum of scale for venous pressure sensor reading (in PSI). +#define VENOUS_PRESSURE_MAX ( 30.0 ) ///< Maximum of scale for venous pressure sensor reading (in PSI). #define PSI_TO_MMHG ( 51.7149 ) ///< Conversion factor for converting PSI to mmHg. @@ -196,23 +196,28 @@ { PRESSURE_STATE_T result = PRESSURE_CONTINUOUS_READ_STATE; - S32 artPres = getFPGAArterialPressure(); - U16 venPres = getFPGAVenousPressure(); + U32 fpgaArtPres = getFPGAArterialPressure(); + S32 artPres = (S32)( fpgaArtPres & MASK_OFF_U32_MSB ) - 0x800000; // subtract 2^23 from low 24 bits to get signed reading + U08 artPresAlarm = (U08)( fpgaArtPres >> 24 ); // high byte is alarm code for arterial pressure + U16 fpgaVenPres = getFPGAVenousPressure(); + U16 venPres = fpgaVenPres & 0x3FFF; // 14-bit data + U08 venPresStatus = (U08)( fpgaVenPres >> 14 ); // high 2 bits is status code for venous pressure + F32 venPresPSI = ( (F32)(venPres - VENOUS_PRESSURE_OFFSET) * (VENOUS_PRESSURE_MAX - VENOUS_PRESSURE_MIN) / (F32)VENOUS_PRESSURE_SCALE ) - VENOUS_PRESSURE_MIN; U16 bldOccl = getFPGABloodPumpOcclusion(); U16 dliOccl = getFPGADialInPumpOcclusion(); U16 dloOccl = getFPGADialOutPumpOcclusion(); - F32 venPresPSI; - - // TODO - convert ADC counts to mmHg for each sensor - arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY * ARTERIAL_PRESSURE_V_BIAS ) ); - venPresPSI = ( (F32)(venPres - VENOUS_PRESSURE_OFFSET) * (VENOUS_PRESSURE_MAX - VENOUS_PRESSURE_MIN) / (F32)VENOUS_PRESSURE_SCALE ) - VENOUS_PRESSURE_MIN; + + // TODO - any filtering required??? + + // convert arterial pressure to mmHg + arterialPressure.data = ARTERIAL_PRESSURE_V_PER_BIT * ( (F32)(artPres) / ( ARTERIAL_PRESSURE_SENSITIVITY * ARTERIAL_PRESSURE_V_BIAS ) ); + // convert venous pressure from PSI to mmHg venousPressure.data = venPresPSI * PSI_TO_MMHG; + // occlusion sensor values have no unit - take as is bloodPumpOcclusion.data = (F32)bldOccl; dialInPumpOcclusion.data = (F32)dliOccl; dialOutPumpOcclusion.data = (F32)dloOccl; - // TODO - any filtering required??? - // check for occlusions checkOcclusions();