-
Stephan Gerhold authored
It is quite strange that BMA222 and BMA222E have very close, yet subtly different values in their scale tables. Comparing the datasheets this is simply because the "Resolution" for the different measurement ranges are documented with different precision. For example, for +-2g the BMA222 datasheet [1] suggests a resolution of 15.6 mg/LSB, while the BMA222E datasheet [2] suggests 15.63 mg/LSB. Actually, there is no need to rely on the resolution given by the Bosch datasheets. The resolution and scale can be calculated more consistently and accurately using the range (e.g. +-2g) and the channel size (e.g. 8 bits). Distributing 4g (-2g to 2g) over 8 bits results in an exact resolution of (4g / 2^8) = 15.625 mg/LSB which is the same value as in both datasheets, just slightly more accurate. Multiplying g = 9.80665 m/s^2 we get a more accurate value for the IIO scale table. Generalizing this we can calculate the scale tables more accurately using (range / 2^bits) * g * 10^6 (because of IIO_VAL_INT_PLUS_MICRO). Document this and make the scale tables more consistent and accurate for all the variants using that formula. Now the scale tables for BMA222 and BMA222E are consistent and probably slightly more accurate. [1]: https://media.digikey.com/pdf/Data%20Sheets/Bosch/BMA222.pdf [2]: https://www.mouser.com/datasheet/2/783/BST-BMA222E-DS004-06-1021076.pdfReviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Reviewed-by: Andy Shevchenko <andy.shevchenko@gnail.com> Link: https://lore.kernel.org/r/20210611182442.1971-1-stephan@gerhold.netSigned-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
e2a73c4e