From: asterix Date: Thu, 8 Oct 2009 11:59:17 +0000 (+0000) Subject: Add driver for mpxx6115a pressure sensor. X-Git-Tag: 2.3.0~39 X-Git-Url: https://codewiz.org/gitweb?a=commitdiff_plain;h=417b8fedf88928360b27cae2d72c036b5bdec9f1;p=bertos.git Add driver for mpxx6115a pressure sensor. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@3044 38d2e660-2303-0410-9eaa-f027e97ec537 --- diff --git a/bertos/drv/mpxx6115a.h b/bertos/drv/mpxx6115a.h new file mode 100644 index 00000000..9e3178a2 --- /dev/null +++ b/bertos/drv/mpxx6115a.h @@ -0,0 +1,71 @@ +/** + * \file + * + * + * \brief Covert read voltage from MPXX6115A Pressure Sensor in hPascal value. + * + * \author Daniele Basile + * + */ + +#ifndef DRV_MPXX6115A_H +#define DRV_MPXX6115A_H + +#define MPXX6115A_DIV_CONST 0.009f +#define MPXX6115A_ADD_CONST 0.095f + + +/** + * Covert read voltage from MPXX6115A Pressure Sensor in hPascal value. + * + * The convertion formula may be consulted on costructor datasheet + * (see Freescale Semiconductor MP3H6115A, MPXAZ6115A). + * + * \param vout output voltage read from pin sensor. + * \param vref reference voltage that supplies the MPXX6115A sensor. + * + * \return interger 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 */