iio: chemical: ccs811: Renamed resistance member in ccs811_reading struct
PATCH 1/1 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.
--- drivers/iio/chemical/ccs811.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/iio/chemical/ccs811.c +3 -3
@@ -66,7 +66,7 @@ struct ccs811_reading {__be16 voc;u8 status;u8 error; -__be16 resistance; +__be16 raw_data; } __attribute__((__packed__));struct ccs811_data {
@@ -202,12 +202,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : - *val =be16_to_cpu (data->buffer.resistance) & + *val =be16_to_cpu (data->buffer.raw_data) &CCS811_VOLTAGE_MASK ; ret =IIO_VAL_INT ;break ;case IIO_CURRENT : - *val =be16_to_cpu (data->buffer.resistance) >>10 ; + *val =be16_to_cpu (data->buffer.raw_data) >>10 ; ret =IIO_VAL_INT ;break ;case IIO_CONCENTRATION :
Signature · 1 line
2.7.4
Jonathan Cameron
maintainerQuoted 16 lines · On Wed, 14 Feb 2018 01:08:35 +0000 Richard Lai <[email protected]> wrote:
The resistance member in
ccs811_readingstruct is an unsigned 16-bit integer variable used to storeRAW_DATAregister bytes read from CCS811. It is kind of misleading to name this struct member as resistance.About the
RAW_DATAregister 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)"
-----
Quoted 8 lines
Hence, the
RAW_DATAregister 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 ofIIO_RESISTANCEmay be added to the driver in the future.Signed-off-by Richard Lai <[email protected]>
This seems logical to me, but I'd just like to let it sit for a few more days to let Narcisa have time to respond.
Feel free to give me a poke if it looks like I have forgotten this in a week or so.
Thanks,
Jonathan
Quoted 32 lines
--- drivers/iio/chemical/ccs811.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/chemical/ccs811.c +3
-3@@ -66,7 +66,7 @@ struct ccs811_reading {__be16 voc;u8 status;u8 error; -__be16 resistance; +__be16 raw_data; } __attribute__((__packed__));struct ccs811_data {@@ -202,12 +202,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : - *val =be16_to_cpu (data->buffer.resistance) & + *val =be16_to_cpu (data->buffer.raw_data) &CCS811_VOLTAGE_MASK ; ret =IIO_VAL_INT ;break ;case IIO_CURRENT : - *val =be16_to_cpu (data->buffer.resistance) >>10 ; + *val =be16_to_cpu (data->buffer.raw_data) >>10 ; ret =IIO_VAL_INT ;break ;case IIO_CONCENTRATION :
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Wed, 14 Feb 2018 01:08:35 +0000 Richard Lai <[email protected]> wrote:
The resistance member in
ccs811_readingstruct is an unsigned 16-bit integer variable used to storeRAW_DATAregister bytes read from CCS811. It is kind of misleading to name this struct member as resistance.About the
RAW_DATAregister bytes, the CCS811 datasheet states that:
-----
Two byte read only register which contains the latest readings from the sense resistor.
Quoted 7 lines
Quoted 7 lines
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)"
-----
True.
Quoted 9 lines
Quoted 7 lines
Hence, the
RAW_DATAregister 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 ofIIO_RESISTANCEmay be added to the driver in the future.
Quoted 4 lines
Quoted 1 line
Signed-off-by Richard Lai <[email protected]>This seems logical to me, but I'd just like to let it sit for a few more days to let Narcisa have time to respond.
I agree, Richard's suggestion is a better fit as a name for this register.
Quoted 40 lines
Feel free to give me a poke if it looks like I have forgotten this in a week or so.
Thanks,
Jonathan
Quoted 32 lines
--- drivers/iio/chemical/ccs811.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/chemical/ccs811.c +3
-3@@ -66,7 +66,7 @@ struct ccs811_reading {__be16 voc;u8 status;u8 error; -__be16 resistance; +__be16 raw_data; } __attribute__((__packed__));struct ccs811_data {@@ -202,12 +202,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : - *val =be16_to_cpu (data->buffer.resistance) & + *val =be16_to_cpu (data->buffer.raw_data) &CCS811_VOLTAGE_MASK ; ret =IIO_VAL_INT ;break ;case IIO_CURRENT : - *val =be16_to_cpu (data->buffer.resistance) >>10 ; + *val =be16_to_cpu (data->buffer.raw_data) >>10 ; ret =IIO_VAL_INT ;break ;case IIO_CONCENTRATION :
Jonathan Cameron
maintainerQuoted 31 lines · On Tue, 20 Feb 2018 22:24:50 +0200 Narcisa Ana Maria Vasile…
Quoted 12 lines · Jonathan Cameron
Quoted 9 lines · On Wed, 14 Feb 2018 01:08:35 +0000 Richard Lai <[email protected]> wrote:
The resistance member in
ccs811_readingstruct is an unsigned 16-bit integer variable used to storeRAW_DATAregister bytes read from CCS811. It is kind of misleading to name this struct member as resistance.About the
RAW_DATAregister bytes, the CCS811 datasheet states that:
-----
Two byte read only register which contains the latest readings from the sense resistor.Quoted 7 lines
Quoted 7 lines
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)"
-----True.
Quoted 7 lines
Quoted 7 lines
Hence, the
RAW_DATAregister 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 ofIIO_RESISTANCEmay be added to the driver in the future.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Richard Lai <[email protected]>This seems logical to me, but I'd just like to let it sit for a few more days to let Narcisa have time to respond.
I agree, Richard's suggestion is a better fit as a name for this register.
Cool. Ideally please give a formal
Acked-by: as then it is recorded in the record rather than deep in an email archive.
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 40 lines
Quoted 40 lines
Feel free to give me a poke if it looks like I have forgotten this in a week or so.
Thanks,
Jonathan
Quoted 32 lines
--- drivers/iio/chemical/ccs811.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/iio/chemical/ccs811.c +3
-3@@ -66,7 +66,7 @@ struct ccs811_reading {__be16 voc;u8 status;u8 error; -__be16 resistance; +__be16 raw_data; } __attribute__((__packed__));struct ccs811_data {@@ -202,12 +202,12 @@ static int ccs811_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : - *val =be16_to_cpu (data->buffer.resistance) & + *val =be16_to_cpu (data->buffer.raw_data) &CCS811_VOLTAGE_MASK ; ret =IIO_VAL_INT ;break ;case IIO_CURRENT : - *val =be16_to_cpu (data->buffer.resistance) >>10 ; + *val =be16_to_cpu (data->buffer.raw_data) >>10 ; ret =IIO_VAL_INT ;break ;case IIO_CONCENTRATION :