Commit 4c73b809 authored by Richard Lai's avatar Richard Lai Committed by Jonathan Cameron

iio: chemical: ccs811: Renamed resistance member in ccs811_reading struct

The resistance member in ccs811_reading struct is an unsigned 16-bit
integer variable used to store RAW_DATA register bytes read from CCS811.
It is kind of misleading to name this struct member as resistance.

About the RAW_DATA register bytes, the CCS811 datasheet states that:
-----
Two byte read only register which contains the latest readings from the
sense resistor.

The most significant 6 bits of the Byte 0 contain the value of the current
through the sensor (0μA to 63μA).

The lower 10 bits contain (as computed from the ADC) the readings of the
voltage across the sensor with the selected current (1023 = 1.65V)"
-----

Hence, the RAW_DATA register byte contains information about electric
current and voltage of the CCS811 sensor. Calling this struct member
'resistance' is kind of misleading, although both electric current and
voltage are needed to calculate the electrical resistance of the sensor
using Ohm's law, V = I x R, in which a new channel type of IIO_RESISTANCE
may be added to the driver in the future.
Signed-off-by: default avatarRichard Lai <richard@richardman.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 721dfe41
...@@ -69,7 +69,7 @@ struct ccs811_reading { ...@@ -69,7 +69,7 @@ struct ccs811_reading {
__be16 voc; __be16 voc;
u8 status; u8 status;
u8 error; u8 error;
__be16 resistance; __be16 raw_data;
} __attribute__((__packed__)); } __attribute__((__packed__));
struct ccs811_data { struct ccs811_data {
...@@ -210,12 +210,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev, ...@@ -210,12 +210,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,
switch (chan->type) { switch (chan->type) {
case IIO_VOLTAGE: case IIO_VOLTAGE:
*val = be16_to_cpu(data->buffer.resistance) & *val = be16_to_cpu(data->buffer.raw_data) &
CCS811_VOLTAGE_MASK; CCS811_VOLTAGE_MASK;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case IIO_CURRENT: case IIO_CURRENT:
*val = be16_to_cpu(data->buffer.resistance) >> 10; *val = be16_to_cpu(data->buffer.raw_data) >> 10;
ret = IIO_VAL_INT; ret = IIO_VAL_INT;
break; break;
case IIO_CONCENTRATION: case IIO_CONCENTRATION:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment