Skip to content

Commit 3d2c211

Browse files
Hunterteaegggroeck
authored andcommitted
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>
1 parent 7d6d53b commit 3d2c211

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

drivers/hwmon/sht3x.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
/* commands (high repeatability mode) */
2525
static const unsigned char sht3x_cmd_measure_single_hpm[] = { 0x24, 0x00 };
2626

27+
/* commands (medium repeatability mode) */
28+
static const unsigned char sht3x_cmd_measure_single_mpm[] = { 0x24, 0x0b };
29+
2730
/* commands (low repeatability mode) */
2831
static const unsigned char sht3x_cmd_measure_single_lpm[] = { 0x24, 0x16 };
2932

@@ -41,6 +44,7 @@ static const unsigned char sht3x_cmd_clear_status_reg[] = { 0x30, 0x41 };
4144

4245
/* delays for single-shot mode i2c commands, both in us */
4346
#define SHT3X_SINGLE_WAIT_TIME_HPM 15000
47+
#define SHT3X_SINGLE_WAIT_TIME_MPM 6000
4448
#define SHT3X_SINGLE_WAIT_TIME_LPM 4000
4549

4650
#define SHT3X_WORD_LEN 2
@@ -68,6 +72,7 @@ enum sht3x_limits {
6872

6973
enum sht3x_repeatability {
7074
low_repeatability,
75+
medium_repeatability,
7176
high_repeatability,
7277
};
7378

@@ -87,6 +92,20 @@ static const char periodic_measure_commands_hpm[][SHT3X_CMD_LENGTH] = {
8792
{0x27, 0x37},
8893
};
8994

95+
/* periodic measure commands (medium repeatability) */
96+
static const char periodic_measure_commands_mpm[][SHT3X_CMD_LENGTH] = {
97+
/* 0.5 measurements per second */
98+
{0x20, 0x24},
99+
/* 1 measurements per second */
100+
{0x21, 0x26},
101+
/* 2 measurements per second */
102+
{0x22, 0x20},
103+
/* 4 measurements per second */
104+
{0x23, 0x22},
105+
/* 10 measurements per second */
106+
{0x27, 0x21},
107+
};
108+
90109
/* periodic measure commands (low repeatability mode) */
91110
static const char periodic_measure_commands_lpm[][SHT3X_CMD_LENGTH] = {
92111
/* 0.5 measurements per second */
@@ -444,6 +463,9 @@ static void sht3x_select_command(struct sht3x_data *data)
444463
if (data->repeatability == high_repeatability) {
445464
data->command = sht3x_cmd_measure_single_hpm;
446465
data->wait_time = SHT3X_SINGLE_WAIT_TIME_HPM;
466+
} else if (data->repeatability == medium_repeatability) {
467+
data->command = sht3x_cmd_measure_single_mpm;
468+
data->wait_time = SHT3X_SINGLE_WAIT_TIME_MPM;
447469
} else {
448470
data->command = sht3x_cmd_measure_single_lpm;
449471
data->wait_time = SHT3X_SINGLE_WAIT_TIME_LPM;
@@ -591,6 +613,8 @@ static ssize_t update_interval_store(struct device *dev,
591613
if (mode > 0) {
592614
if (data->repeatability == high_repeatability)
593615
command = periodic_measure_commands_hpm[mode - 1];
616+
else if (data->repeatability == medium_repeatability)
617+
command = periodic_measure_commands_mpm[mode - 1];
594618
else
595619
command = periodic_measure_commands_lpm[mode - 1];
596620

0 commit comments

Comments
 (0)