diff options
author | JuenKit Yip <JuenKit_Yip@hotmail.com> | 2023-06-17 00:00:15 +0800 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2023-06-17 08:56:42 -0700 |
commit | 3d2c211c0d2b5955b4ec9a1af7d59e8bed00c7fe (patch) | |
tree | ce0ff41b881c50a952af0a2f1f22ead01c97c568 /drivers/hwmon | |
parent | 7d6d53ba3bccc5497e5bda5da4868c410f3eaa02 (diff) |
hwmon: (sht3x) add medium repeatability support
Add support for medium repeatability.
Per datasheet:
The stated repeatability is 3 times the standard deviation (3σ)
of multiple consecutive measurements at the stated repeatability
and at constant ambient conditions. It is a measure for the noise
on the physical sensor output. Different measurement modes allow
for high/medium/low repeatability.
For the humidity sensor, repeatability is documented as
0.25% RH for low repeatability, 0.15% RH for medium repeatability,
and 0.10% RH for high repeatability. Support all three modes.
Signed-off-by: JuenKit Yip <JuenKit_Yip@hotmail.com>
Link: https://lore.kernel.org/r/DB4PR10MB6261A70CD0444248ADDCC3219258A@DB4PR10MB6261.EURPRD10.PROD.OUTLOOK.COM
[groeck: Added details to description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/sht3x.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/hwmon/sht3x.c b/drivers/hwmon/sht3x.c index fff92e96a6b3..111b86d9adb5 100644 --- a/drivers/hwmon/sht3x.c +++ b/drivers/hwmon/sht3x.c @@ -24,6 +24,9 @@ /* commands (high repeatability mode) */ static const unsigned char sht3x_cmd_measure_single_hpm[] = { 0x24, 0x00 }; +/* commands (medium repeatability mode) */ +static const unsigned char sht3x_cmd_measure_single_mpm[] = { 0x24, 0x0b }; + /* commands (low repeatability mode) */ static const unsigned char sht3x_cmd_measure_single_lpm[] = { 0x24, 0x16 }; @@ -41,6 +44,7 @@ static const unsigned char sht3x_cmd_clear_status_reg[] = { 0x30, 0x41 }; /* delays for single-shot mode i2c commands, both in us */ #define SHT3X_SINGLE_WAIT_TIME_HPM 15000 +#define SHT3X_SINGLE_WAIT_TIME_MPM 6000 #define SHT3X_SINGLE_WAIT_TIME_LPM 4000 #define SHT3X_WORD_LEN 2 @@ -68,6 +72,7 @@ enum sht3x_limits { enum sht3x_repeatability { low_repeatability, + medium_repeatability, high_repeatability, }; @@ -87,6 +92,20 @@ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = { {0x27, 0x37}, }; +/* periodic measure commands (medium repeatability) */ +static const char periodic_measure_commands_mpm[][SHT3X_CMD_LENGTH] = { + /* 0.5 measurements per second */ + {0x20, 0x24}, + /* 1 measurements per second */ + {0x21, 0x26}, + /* 2 measurements per second */ + {0x22, 0x20}, + /* 4 measurements per second */ + {0x23, 0x22}, + /* 10 measurements per second */ + {0x27, 0x21}, +}; + /* periodic measure commands (low repeatability mode) */ static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = { /* 0.5 measurements per second */ @@ -444,6 +463,9 @@ static void sht3x_select_command(struct sht3x_data *data) if (data->repeatability == high_repeatability) { data->command = sht3x_cmd_measure_single_hpm; data->wait_time = SHT3X_SINGLE_WAIT_TIME_HPM; + } else if (data->repeatability == medium_repeatability) { + data->command = sht3x_cmd_measure_single_mpm; + data->wait_time = SHT3X_SINGLE_WAIT_TIME_MPM; } else { data->command = sht3x_cmd_measure_single_lpm; data->wait_time = SHT3X_SINGLE_WAIT_TIME_LPM; @@ -591,6 +613,8 @@ static ssize_t update_interval_store(struct device *dev, if (mode > 0) { if (data->repeatability == high_repeatability) command = periodic_measure_commands_hpm[mode - 1]; + else if (data->repeatability == medium_repeatability) + command = periodic_measure_commands_mpm[mode - 1]; else command = periodic_measure_commands_lpm[mode - 1]; |