[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240203145401.GC3727@debian>
Date: Sat, 3 Feb 2024 15:54:01 +0100
From: Dimitri Fedrau <dima.fedrau@...il.com>
To: Javier Carrasco <javier.carrasco.cruz@...il.com>
Cc: Christophe JAILLET <christophe.jaillet@...adoo.fr>, 579lpy@...il.com,
jic23@...nel.org, lars@...afoo.de, linux-iio@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] iio: humidity: hdc3020: add threshold events support
Am Sat, Feb 03, 2024 at 11:06:02AM +0100 schrieb Javier Carrasco:
> On 03.02.24 10:58, Christophe JAILLET wrote:
> > Le 03/02/2024 à 10:05, Dimitri Fedrau a écrit :
> >> [...]
> >> drivers/iio/humidity/hdc3020.c | 339 +++++++++++++++++++++++++++++++++
> >> 1 file changed, 339 insertions(+)
>
> ...
>
> >> + guard(mutex)(&data->lock);
> >> + switch (chan->type) {
> >> + case IIO_TEMP:
> >> + /*
> >> + * Store truncated temperature threshold into 9 LSBs while
> >> + * keeping the old humidity threshold in the 7 MSBs.
> >> + */
> >> + val = (((val + 45) * 65535 / 175) >> HDC3020_THRESH_TEMP_SHIFT);
> >
> > Why 175?
> > If the span is -40/+120, I guess it should be 160 and if it is -45/+120,
> > 165. No?
> >
> > Maybe something like:
> > #define MIN_TEMP -45 (or -40)
> > #define MAX_TEMP 120
> > in order to avoid hard coded constant?
> >
>
> the 45 and 175 values come from the conversion formula provided in the
> datasheet (page 13), even though the sensor range is from –40°C to 125°C.
>
Will add following constants:
#define MIN_TEMP -40
#define MAX_TEMP 125
It's the supported temperature range by the chip as Javier already
explained. Thanks for finding this.
> >> [...]
Best regards,
Dimitri
Powered by blists - more mailing lists