/************************************************************************** * * Copyright (c) 2024-2024 Diality Inc. - All Rights Reserved. * * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * @file PressureCommon.c * * @author (last) Vinayakam Mani * @date (last) 13-Sep-2024 * * @author (original) Sean * @date (original) 22-Aug-2024 * ***************************************************************************/ #include "PressureCommon.h" /** * @addtogroup PressureCommon * @{ */ // ********** private definitions ********** #define BAR_TO_MMHG ( 750.062F ) ///< Conversion factor for converting bar to mmHg. #define PRESSURE_FS ( 14746.0F ) ///< Pressure sensor full scale output. #define PRESSURE_ZERO ( 1638.0F ) ///< Pressure sensor zero value. #define PRESSURE_FS_MINUS_ZERO ( 13108.0F ) ///< Pressure sensor fullscale and zero difference. #define PRESSURE_TEMP_RESOLUTION ( 2047.0F ) ///< Pressure sensor temperature resoultion 2^11 bit equals to 2047. #define PRESSURE_TEMP_MULTIPLIER ( 200.0F ) ///< Pressure sensor multiplier #define PRESSURE_TEMP_OFFSET ( 50.0F ) ///< Pressure sensor temperature offset. // ********** private data ********** // ********** private function prototypes ********** /*********************************************************************//** * @brief * The convertPressureReading2mmHg function converts a raw pressure ADC * reading from a pressure sensor to mmHg. * @details \b Inputs: none * @details \b Outputs: none * @return Pressure reading in mmHg *************************************************************************/ F32 convertPressureReading2mmHg( S16 counts ) { F32 pressure_bar, mmHg; // Convert raw pressure counts to bar and then to mmHg pressure_bar = PRESSURE_FS_MINUS_ZERO * ( ( (F32)counts - PRESSURE_ZERO ) / PRESSURE_FS_MINUS_ZERO ) + PRESSURE_ZERO; mmHg = pressure_bar * BAR_TO_MMHG; return mmHg; } /*********************************************************************//** * @brief * The convertPressureTempReading2DegC function converts a raw temperature * ADC reading from a pressure sensor to Celsius. * @details \b Inputs: none * @details \b Outputs: none * @return Temperature reading in Celsius *************************************************************************/ F32 convertPressureTempReading2DegC( S16 counts ) { F32 degC; // Convert raw pressure sensor temperatures to deg C degC = ( ( (F32)counts / PRESSURE_TEMP_RESOLUTION ) * PRESSURE_TEMP_MULTIPLIER ) - PRESSURE_TEMP_OFFSET; return degC; } /**@}*/