/** * \file * * * \brief MPXX6115A Pressure Sensor convert formula. * * This module convert read voltage value from MPXX6115A * pressure sensor into hPascal value unit. * * \author Daniele Basile * * $WIZ$ module_name = "mpxx6115a" * $WIZ$ module_depends = "adc" * $WIZ$ module_configuration = "" * $WIZ$ module_hw = "" */ #ifndef DRV_MPXX6115A_H #define DRV_MPXX6115A_H #include #define MPXX6115A_DIV_CONST 0.009f #define MPXX6115A_ADD_CONST 0.095f /** * Convert read voltage from MPXX6115A Pressure Sensor in hPascal value. * * The conversion formula may be consulted on constructor datasheet * (see Freescale Semiconductor MP3H6115A, MPXAZ6115A). * * \param vout output voltage read from pin sensor. * \param vref reference voltage that supplies the MPXX6115A sensor. * * \return integer value that represent measured pressure in hPascal. * * \note: To compute the pressure we use the Vout/Vref ratio, so * these two values can be expressed in any unit, even ADC levels. * */ INLINE int16_t mpxx6115a_press(adcread_t vout, adcread_t vref) { float tmp; tmp = (float)vout/(float)vref + MPXX6115A_ADD_CONST; // To return hpascal we should multiply by 10 because the ratio is in kpascal return (int16_t)(tmp / MPXX6115A_DIV_CONST * 10); } #endif /* DRV_MPXX6115A_H */