summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Sperling <stsp@cvs.openbsd.org>2017-10-05 17:29:01 +0000
committerStefan Sperling <stsp@cvs.openbsd.org>2017-10-05 17:29:01 +0000
commit0c70cec1a47676a6f6b6c62137461c2906751df6 (patch)
treeedd9b61afd6f7a2580cb6a9199836051086539e5
parent43fdbe86b3faef5f812203086c30818bf77386b6 (diff)
Add support for the "TEMPer1F_H1V1.5F" USB temperature and humidity
sensor to the ugold(4) driver. Patch by Jan Klemkow Tested by Remi Locherer ok mpi@ patrick@
-rw-r--r--share/man/man4/ugold.45
-rw-r--r--sys/dev/usb/ugold.c15
2 files changed, 16 insertions, 4 deletions
diff --git a/share/man/man4/ugold.4 b/share/man/man4/ugold.4
index 2f56b361bd7..47832d622bd 100644
--- a/share/man/man4/ugold.4
+++ b/share/man/man4/ugold.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: ugold.4,v 1.3 2015/08/11 13:41:06 jung Exp $
+.\" $OpenBSD: ugold.4,v 1.4 2017/10/05 17:29:00 stsp Exp $
.\"
.\" Copyright (c) 2013 Takayoshi SASANO <sasano@openbsd.org>
.\" Copyright (c) 2013 Martin Pieuchot <mpi@openbsd.org>
@@ -16,7 +16,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: August 11 2015 $
+.Dd $Mdocdate: October 5 2017 $
.Dt UGOLD 4
.Os
.Sh NAME
@@ -37,6 +37,7 @@ driver:
.It Li "RDing TEMPerV1.4" Ta "1 Temperature"
.It Li "RDing TEMPerHUM1V1.0" Ta "1 Temperature and 1 Humidity"
.It Li "RDing TEMPerHUM1V1.2" Ta "1 Temperature and 1 Humidity"
+.It Li "RDing TEMPer1F_H1V1.5F Ta "1 Temperature and 1 Humidity"
.El
.Pp
The driver possesses a collection of sensor values which are
diff --git a/sys/dev/usb/ugold.c b/sys/dev/usb/ugold.c
index f8f232d5cec..78a38b14ad3 100644
--- a/sys/dev/usb/ugold.c
+++ b/sys/dev/usb/ugold.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ugold.c,v 1.13 2017/01/09 14:44:28 mpi Exp $ */
+/* $OpenBSD: ugold.c,v 1.14 2017/10/05 17:29:00 stsp Exp $ */
/*
* Copyright (c) 2013 Takayoshi SASANO <uaa@openbsd.org>
@@ -46,6 +46,7 @@
#define UGOLD_TYPE_SI7005 1
#define UGOLD_TYPE_SI7006 2
+#define UGOLD_TYPE_SHT1X 3
/*
* This driver uses three known commands for the TEMPer and TEMPerHUM
@@ -303,6 +304,9 @@ ugold_si700x_temp(int type, uint8_t msb, uint8_t lsb)
case UGOLD_TYPE_SI7006: /* 14bit and status bit */
temp = (((temp & ~3) * 21965) / 8192) - 46850;
break;
+ case UGOLD_TYPE_SHT1X:
+ temp = (temp * 1000) / 256;
+ break;
default:
temp = 0;
}
@@ -325,6 +329,9 @@ ugold_si700x_rhum(int type, uint8_t msb, uint8_t lsb, int temp)
case UGOLD_TYPE_SI7006: /* 14bit and status bit */
rhum = (((rhum & ~3) * 15625) / 8192) - 6000;
break;
+ case UGOLD_TYPE_SHT1X: /* 16 bit */
+ rhum = rhum * 32;
+ break;
default:
rhum = 0;
}
@@ -340,7 +347,8 @@ ugold_si700x_rhum(int type, uint8_t msb, uint8_t lsb, int temp)
static void
ugold_si700x_type(struct ugold_softc *sc, uint8_t *buf, u_int len)
{
- if (memcmp(buf, "TEMPerHu", len) == 0)
+ if (memcmp(buf, "TEMPerHu", len) == 0 ||
+ memcmp(buf, "TEMPer1F", len) == 0)
return; /* skip equal first half of the answer */
printf("%s: %d sensor%s type ", sc->sc_hdev.sc_dev.dv_xname,
@@ -352,6 +360,9 @@ ugold_si700x_type(struct ugold_softc *sc, uint8_t *buf, u_int len)
} else if (memcmp(buf, "mM12V1.2", len) == 0) {
sc->sc_type = UGOLD_TYPE_SI7006;
printf("si7006 (temperature and humidity)\n");
+ } else if (memcmp(buf, "_H1V1.5F", len) == 0) {
+ sc->sc_type = UGOLD_TYPE_SHT1X;
+ printf("sht1x (temperature and humidity)\n");
} else {
sc->sc_type = -1;
printf("unknown\n");