iio: pressure: ms5611: add support for MS5803 temperature and pressure sensor
PATCH 1/1 iio: pressure: ms5611: add support for MS5803 temperature and pressure sensor
MS5803 is factory calibrated temperature and pressure sensor capable of providing precise 24bit measurements. Sensor supports both I2C and SPI and uses the same command protocol as MS5611/MS5607.
Signed-off-by Tomasz Duszynski <[email protected]>
--- drivers/iio/pressure/Kconfig | 2 +- drivers/iio/pressure/ms5611.h | 1 + drivers/iio/pressure/ms5611_core.c | 43 ++++++++++++++++++++++++++++++++++++++ drivers/iio/pressure/ms5611_i2c.c | 1 + drivers/iio/pressure/ms5611_spi.c | 1 + 5 files changed, 47 insertions(+), 1 deletion(-)
drivers/iio/pressure/Kconfig +1 -1
@@ -56,7 +56,7 @@ config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" help Say Y here to build support for the Measurement Specialties - MS5611, MS5607 pressure and temperature sensors. + MS5611, MS5607, MS5803 pressure and temperature sensors. To compile this driver as a module, choose M here: the module will be called ms5611_core.
drivers/iio/pressure/ms5611.h +1 -0
@@ -30,6 +30,7 @@enum {MS5611 ,MS5607 , +MS5803 };struct ms5611_chip_info {
drivers/iio/pressure/ms5611_core.c +43 -0
61 lines not on this page · raw message
drivers/iio/pressure/ms5611_i2c.c +1 -0
@@ -110,6 +110,7 @@ static int ms5611_i2c_probe(struct i2c_client *client,static const struct i2c_device_id ms5611_id[] = { {"ms5611" ,MS5611 }, {"ms5607" ,MS5607 }, + {"ms5803" ,MS5803 }, { } };MODULE_DEVICE_TABLE (i2c, ms5611_id);
drivers/iio/pressure/ms5611_spi.c +1 -0
@@ -110,6 +110,7 @@ static int ms5611_spi_probe(struct spi_device *spi)static const struct spi_device_id ms5611_id[] = { {"ms5611" ,MS5611 }, {"ms5607" ,MS5607 }, + {"ms5803" ,MS5803 }, { } };MODULE_DEVICE_TABLE (spi, ms5611_id);
Signature · 1 line
2.4.5
Quoted 131 lines · Tomasz Duszynski
MS5803 is factory calibrated temperature and pressure sensor capable of providing precise 24bit measurements. Sensor supports both I2C and SPI and uses the same command protocol as MS5611/MS5607.
Signed-off-by Tomasz Duszynski <[email protected]>--- drivers/iio/pressure/Kconfig | 2 +- drivers/iio/pressure/ms5611.h | 1 + drivers/iio/pressure/ms5611_core.c | 43 ++++++++++++++++++++++++++++++++++++++ drivers/iio/pressure/ms5611_i2c.c | 1 + drivers/iio/pressure/ms5611_spi.c | 1 + 5 files changed, 47 insertions(+), 1 deletion(-)drivers/iio/pressure/Kconfig +1
-1@@ -56,7 +56,7 @@ config MS5611 tristate "Measurement Specialties MS5611 pressure sensor driver" help Say Y here to build support for the Measurement Specialties - MS5611, MS5607 pressure and temperature sensors. + MS5611, MS5607, MS5803 pressure and temperature sensors. To compile this driver as a module, choose M here: the module will be called ms5611_core.drivers/iio/pressure/ms5611.h +1
-0@@ -30,6 +30,7 @@enum {MS5611 ,MS5607 , +MS5803 };struct ms5611_chip_info {drivers/iio/pressure/ms5611_core.c +43
-0@@ -10,6 +10,7 @@* Data sheet: * http://www.meas-spec.com/downloads/MS5611-01BA03.pdf * http://www.meas-spec.com/downloads/MS5607-02BA03.pdf +* http://www.meas-spec.com/downloads/MS5803-01BA.pdf * */ @@ -157,6 +158,45 @@ static int ms5607_temp_and_pressure_compensate(struct ms5611_chip_info *chip_infreturn 0 ; } +static int ms5803_temp_and_pressure_compensate (struct ms5611_chip_info *chip_info, +s32 *temp,s32 *pressure) +{ +s32 t = *temp, p = *pressure; +s64 off, sens, dt, off2, sens2, t2; + + dt = t - (chip_info->prom[5 ] <<8 ); + off = ((s64 )chip_info->prom[2 ] <<16 ) + ((chip_info->prom[4 ] * dt) >>7 ); + sens = ((s64 )chip_info->prom[1 ] <<15 ) + ((chip_info->prom[3 ] * dt) >>8 ); + + t =2000 + ((chip_info->prom[6 ] * dt) >>23 ); +if (t <2000 ) { +s64 tmp = (t -2000 ) * (t -2000 ); + + t2 = (dt * dt) >>31 ; + off2 =3 * tmp; + sens2 = (7 * tmp) >>3 ; + +if (t <-1500 ) + sens2 +=2 * (t +1500 ) * (t +1500 ); + }else { + t2 =0 ; + off2 =0 ; + sens2 =0 ; + +if (t >=4500 ) + sens2 -= ((t -4500 ) * (t -4500 )) >>3 ; + } + + t -= t2; + off -= off2; + sens -= sens2; + + *temp = t; + *pressure = (((p * sens) >>21 ) - off) >>15 ; + +return 0 ; +} +static int ms5611_reset (struct iio_dev *indio_dev) {int ret;@@ -212,6 +252,9 @@ static struct ms5611_chip_info chip_info_tbl[] = { }, [MS5607 ] = { .temp_and_pressure_compensate = ms5607_temp_and_pressure_compensate, + }, + [MS5803 ] = { + .temp_and_pressure_compensate = ms5803_temp_and_pressure_compensate, } };drivers/iio/pressure/ms5611_i2c.c +1
-0@@ -110,6 +110,7 @@ static int ms5611_i2c_probe(struct i2c_client *client,static const struct i2c_device_id ms5611_id[] = { {"ms5611" ,MS5611 }, {"ms5607" ,MS5607 }, + {"ms5803" ,MS5803 }, { } };MODULE_DEVICE_TABLE (i2c, ms5611_id);drivers/iio/pressure/ms5611_spi.c +1
-1@@ -110,6 +110,7 @@ static int ms5611_spi_probe(struct spi_device *spi)static const struct spi_device_id ms5611_id[] = { {"ms5611" ,MS5611 }, {"ms5607" ,MS5607 }, + {"ms5803" ,MS5803 }, { } };MODULE_DEVICE_TABLE (spi, ms5611_id); --
Quoted 2 lines
2.4.5
Hi,
Hold on with reviewing this patch. I'll repost it shortly. Thanks!