Re: Replying to: [PATCH] iio pressure: bmp280: Fix BMP580 temperature reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2024-05-02 at 13:15 -0500, Adam Rizkalla wrote:
> On Thu, May 02, 2024 at 07:16:16PM +0200, Vasileios Amoiridis wrote:
> > Hi Angel!
> > 
> > Indeed the datasheet says that the pressure is a signed value. But this
> > comes
> > in contrast with 2 things:
> > 
> > 1) The BMP58x sensor does not have a compensation function so the value from
> > the
> > sensor is a pressure value just in different unit from the one reported by
> > IIO.
> > And the sensor is able to report in between 30-125kPa according to the
> > datasheet which are both positive values so it makes more sense to be an
> > unsigned value.
> > 
> > 2) According to the BMP5 sensor API [1] provided by Bosch, the pressure is
> > declared as an unsigned value.
> > 
> > So, what should we trust?
> > 
> > [1]:
> > https://github.com/boschsensortec/BMP5_SensorAPI/blob/master/bmp5_defs.h#L895
> 
> The pressure sensor reading cannot be negative, as the pressure range of the
> sensor
> is 300 - 1250 hPa,so this change does not need to be applied for
> bmp580_read_press().
> Also, the overflow issue does not happen with the pressure reading since the
> value
> read back from the device is scaled up only by 2^6 for pressure vs 2^16 for
> temperature,
> so multiplying by 1000 even for the maximum value would still fit in a 32-bit
> signed
> integer. Temperature ranges above ~32.767C, however, will overflow a 32-bit
> signed
> integer when multiplied by 2^16 * 1000 which is why this change is necessary
> only for
> temperature readings.
> 
> Hope this helps clarify.
> 
> Best,
> Adam

Crystal clear. Thanks to both of you for the clarifications :)

Acked-by: Angel Iglesias <ang.iglesiasg@xxxxxxxxx>

Kind regards,
Angel





[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux