Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/modules/sht3xtemp Driver for the Sensirion SHT30/SHT31/S...
details: https://anonhg.NetBSD.org/src/rev/14d180f07fb7
branches: trunk
changeset: 1024811:14d180f07fb7
user: brad <brad%NetBSD.org@localhost>
date: Sat Nov 06 13:34:39 2021 +0000
description:
Driver for the Sensirion SHT30/SHT31/SHT35 temperature and humidity
sensor such as:
https://www.adafruit.com/product/2857
This is a higher priced sensor with a lot of features, including the
ability to do sub-second periodic updates. The driver supports
everything about the sensor except for the alert pin.
diffstat:
distrib/sets/lists/debug/module.mi | 4 +-
distrib/sets/lists/man/mi | 5 +-
distrib/sets/lists/modules/mi | 4 +-
etc/MAKEDEV.tmpl | 13 +-
share/man/man4/Makefile | 8 +-
share/man/man4/sht3xtemp.4 | 119 +
sys/conf/majors | 3 +-
sys/dev/i2c/files.i2c | 7 +-
sys/dev/i2c/sht3x.c | 2111 ++++++++++++++++++++++++++++++++
sys/dev/i2c/sht3xreg.h | 103 +
sys/dev/i2c/sht3xvar.h | 92 +
sys/modules/Makefile | 3 +-
sys/modules/sht3xtemp/Makefile | 11 +
sys/modules/sht3xtemp/sht3xtemp.ioconf | 8 +
14 files changed, 2480 insertions(+), 11 deletions(-)
diffs (truncated from 2660 to 300 lines):
diff -r c6e88f4e8740 -r 14d180f07fb7 distrib/sets/lists/debug/module.mi
--- a/distrib/sets/lists/debug/module.mi Sat Nov 06 06:52:48 2021 +0000
+++ b/distrib/sets/lists/debug/module.mi Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: module.mi,v 1.14 2021/10/14 13:54:46 brad Exp $
+# $NetBSD: module.mi,v 1.15 2021/11/06 13:34:40 brad Exp $
./usr/libdata/debug/@MODULEDIR@ modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/accf_dataready modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/accf_dataready/accf_dataready.kmod.debug modules-base-kernel kmod,debug
@@ -334,6 +334,8 @@
./usr/libdata/debug/@MODULEDIR@/sequencer/sequencer.kmod.debug modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/sgp40mox modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/sgp40mox/sgp40mox.kmod.debug modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/sht3xtemp modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/sht3xtemp/sht3xtemp.kmod.debug modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/sht4xtemp modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/sht4xtemp/sht4xtemp.kmod.debug modules-base-kernel kmod,debug
./usr/libdata/debug/@MODULEDIR@/si70xxtemp modules-base-kernel kmod,debug
diff -r c6e88f4e8740 -r 14d180f07fb7 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sat Nov 06 06:52:48 2021 +0000
+++ b/distrib/sets/lists/man/mi Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1728 2021/10/14 13:54:46 brad Exp $
+# $NetBSD: mi,v 1.1729 2021/11/06 13:34:40 brad Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1725,6 +1725,7 @@
./usr/share/man/cat4/shb.0 man-sys-catman .cat
./usr/share/man/cat4/shmif.0 man-sys-catman .cat
./usr/share/man/cat4/shpcic.0 man-sys-catman .cat
+./usr/share/man/cat4/sht3xtemp.0 man-sys-catman .cat
./usr/share/man/cat4/sht4xtemp.0 man-sys-catman .cat
./usr/share/man/cat4/si.0 man-sys-catman .cat
./usr/share/man/cat4/si70xxtemp.0 man-sys-catman .cat
@@ -4901,6 +4902,7 @@
./usr/share/man/html4/shb.html man-sys-htmlman html
./usr/share/man/html4/shmif.html man-sys-htmlman html
./usr/share/man/html4/shpcic.html man-sys-htmlman html
+./usr/share/man/html4/sht3xtemp.html man-sys-htmlman html
./usr/share/man/html4/sht4xtemp.html man-sys-htmlman html
./usr/share/man/html4/si.html man-sys-htmlman html
./usr/share/man/html4/si70xxtemp.html man-sys-htmlman html
@@ -7983,6 +7985,7 @@
./usr/share/man/man4/shb.4 man-sys-man .man
./usr/share/man/man4/shmif.4 man-sys-man .man
./usr/share/man/man4/shpcic.4 man-sys-man .man
+./usr/share/man/man4/sht3xtemp.4 man-sys-man .man
./usr/share/man/man4/sht4xtemp.4 man-sys-man .man
./usr/share/man/man4/si.4 man-sys-man .man
./usr/share/man/man4/si70xxtemp.4 man-sys-man .man
diff -r c6e88f4e8740 -r 14d180f07fb7 distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi Sat Nov 06 06:52:48 2021 +0000
+++ b/distrib/sets/lists/modules/mi Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.148 2021/10/14 13:54:46 brad Exp $
+# $NetBSD: mi,v 1.149 2021/11/06 13:34:40 brad Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -399,6 +399,8 @@
./@MODULEDIR@/sequencer/sequencer.kmod modules-base-kernel kmod
./@MODULEDIR@/sgp40mox modules-base-kernel kmod
./@MODULEDIR@/sgp40mox/sgp40mox.kmod modules-base-kernel kmod
+./@MODULEDIR@/sht3xtemp modules-base-kernel kmod
+./@MODULEDIR@/sht3xtemp/sht3xtemp.kmod modules-base-kernel kmod
./@MODULEDIR@/sht4xtemp modules-base-kernel kmod
./@MODULEDIR@/sht4xtemp/sht4xtemp.kmod modules-base-kernel kmod
./@MODULEDIR@/si70xxtemp modules-base-kernel kmod
diff -r c6e88f4e8740 -r 14d180f07fb7 etc/MAKEDEV.tmpl
--- a/etc/MAKEDEV.tmpl Sat Nov 06 06:52:48 2021 +0000
+++ b/etc/MAKEDEV.tmpl Sat Nov 06 13:34:39 2021 +0000
@@ -1,5 +1,5 @@
#!/bin/sh -
-# $NetBSD: MAKEDEV.tmpl,v 1.226 2021/10/12 17:19:20 christos Exp $
+# $NetBSD: MAKEDEV.tmpl,v 1.227 2021/11/06 13:34:40 brad Exp $
#
# Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -270,6 +270,7 @@
# scsibus* SCSI busses
# se* SCSI Ethernet
# ses* SES/SAF-TE SCSI Devices
+# sht3xtemp* Sensirion SHT3X temperature and humidity device driver
# speaker PC speaker (XXX - installed)
# spi* SPI bus device
# sram battery backuped memory (x68k)
@@ -845,6 +846,7 @@
makedev fw0 fw1 fw2 fw3
makedev ipmi0
makedev qemufwcfg
+ makedev sht3xtemp0
makedev local # do this last
;;
@@ -913,6 +915,10 @@
makedev floppy md0
;;
+sht3xtemp)
+ makedev sht3xtemp0
+ ;;
+
usbs)
makedev usb usb0 usb1 usb2 usb3 usb4 usb5 usb6 usb7
makedev usb8 usb9 usb10 usb11 usb12 usb13 usb14 usb15
@@ -2250,6 +2256,11 @@
mkdev efi c %efi_chr% 0 660
;;
+sht3xtemp[0-9]*)
+ unit=${i#sht3xtemp}
+ mkdev sht3xtemp$unit c %sht3xtemp_chr% $unit 664
+ ;;
+
midevend)
%MI_DEVICES_END%
local)
diff -r c6e88f4e8740 -r 14d180f07fb7 share/man/man4/Makefile
--- a/share/man/man4/Makefile Sat Nov 06 06:52:48 2021 +0000
+++ b/share/man/man4/Makefile Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.718 2021/10/14 13:54:45 brad Exp $
+# $NetBSD: Makefile,v 1.719 2021/11/06 13:34:39 brad Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -56,9 +56,9 @@
rnd.4 route.4 rs5c372rtc.4 rtk.4 rtsx.4 rtw.4 rtwn.4 rum.4 run.4 \
s390rtc.4 satalink.4 sbus.4 schide.4 \
scsi.4 sctp.4 sd.4 se.4 seeprom.4 sem.4 \
- ses.4 sf.4 sfb.4 sgp40mox.4 sgsmix.4 shb.4 shmif.4 shpcic.4 sht4xtemp.4 \
- si70xxtemp.4 siisata.4 siop.4 sip.4 siside.4 sk.4 sl.4 slide.4 \
- sm.4 smscphy.4 smsh.4 sn.4 sony.4 spc.4 speaker.4 spif.4 sqphy.4 \
+ ses.4 sf.4 sfb.4 sgp40mox.4 sgsmix.4 shb.4 shmif.4 shpcic.4 sht3xtemp.4 \
+ sht4xtemp.4 si70xxtemp.4 siisata.4 siop.4 sip.4 siside.4 sk.4 sl.4 \
+ slide.4 sm.4 smscphy.4 smsh.4 sn.4 sony.4 spc.4 speaker.4 spif.4 sqphy.4 \
srt.4 ss.4 \
ssdfb.4 st.4 ste.4 stge.4 sti.4 stpcide.4 sv.4 \
svwsata.4 swsensor.4 swwdog.4 sysmon.4 \
diff -r c6e88f4e8740 -r 14d180f07fb7 share/man/man4/sht3xtemp.4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/share/man/man4/sht3xtemp.4 Sat Nov 06 13:34:39 2021 +0000
@@ -0,0 +1,119 @@
+.\" $NetBSD: sht3xtemp.4,v 1.1 2021/11/06 13:34:39 brad Exp $
+.\"
+.\" Copyright (c) 2021 Brad Spencer <brad%anduin.eldar.org@localhost>
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd October 31, 2021
+.Dt SHT3XTEMP 4
+.Os
+.Sh NAME
+.Nm sht3xtemp
+.Nd Driver for Sensirion SHT30/SHT31/SHT35 sensor chip via I2C bus
+.Sh SYNOPSIS
+.Cd "sht3xtemp* at iic? addr 0x44"
+.Cd "sht3xtemp* at iic? addr 0x45"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides measurements from the SHT30/SHT31/SHT35 humidity/temperature
+sensors via the
+.Xr envsys 4
+framework.
+The
+.Nm
+.Ar addr
+argument selects the address at the
+.Xr iic 4
+bus.
+The mode of operation, repeatability, heater controls, periodic update rate
+and crc validity can be changed through
+.Xr sysctl 8
+nodes.
+.Sh SYSCTL VARIABLES
+The following
+.Xr sysctl 3
+variables are provided:
+.Bl -tag -width indent
+.It Li hw.sht3xtemp0.modes
+Lists the modes supported by the driver and chip.
+.It Li hw.sht3xtemp0.mode
+Set the operation mode of the chip. The SHT3X chip can run in a
+single-shot measurement mode or a periodic update mode.
+Use one of the strings listed in
+.Li hw.sht3xtemp.modes .
+.It Li hw.sht3xtemp0.rates
+List the periodic update rates supported by the driver and chip.
+.It Li hw.sht3xtemp0.rate
+Set the periodic update rate when the mode of operation is set to
+periodic. The unit for this is measurements per second, or ART
+which is a mode that operates at an update rate of 4Hz higher
+response time.
+Use one of the strings listed in
+.Li hw.sht3xtemp.rates .
+.Pp
+Since it is possible to have subsecond periodic updates from the
+chip if so desired a device file is provided that can be used to
+get the raw temperature and humidity values outside of the
+.Xr envsys 4
+framework.
+The structure of this output is the raw temperature plus an 8-bit CRC
+followed by the raw humidity plus an 8-bit CRC.
+.It Li hw.sht3xtemp0.repeatabilities
+List the valid values for the repeatability used for a measurement.
+.It Li hw.sht3xtemp0.repeatability
+Set the repeatability for the measurement. The higher the repeatability
+the longer the measurement will take and the more power used.
+Use one of the strings listed in
+.Li hw.sht3xtemp.repeatabilities .
+.It Li hw.sht3xtemp0.ignorecrc
+If set, the crc calculation for %RH and temperature in the measurement phrase
+will be ignored.
+.It Li hw.sht3xtemp0.heateron
+Turn the heater on and off.
+.It Li hw.sht3xtemp0.debug
+If the driver is compiled with
+.Dv SHT3X_DEBUG ,
+this node will appear and can be used to set the debugging level.
+.It Li hw.sht3xtemp0.readattempts
+To read %RH or temperature the chip requires that the command be sent,
+then a delay must be observed before a read can be done to get the values
+back.
+The delays are documented in the datasheet for the chip.
+The driver will attempt to read back the values readattempts number of
+times.
+The default is 10 which should be more than enough for most purposes.
+.El
+.Sh FILES
+.Bl -tag -width "/dev/sht3xtempu" -compact
+.It /dev/sht3xtemp Ns Ar u
+SHT3X device unit
+.Ar u
+file.
+.El
+.Sh SEE ALSO
+.Xr envsys 4 ,
+.Xr iic 4 ,
+.Xr envstat 8 ,
+.Xr sysctl 8
+.Sh HISTORY
+The
+.Nm
+driver first appeared in
+.Nx 10.0 .
+.Sh AUTHORS
+.An -nosplit
+The
+.Nm
+driver was written by
+.An Brad Spencer Aq Mt brad%anduin.eldar.org@localhost .
diff -r c6e88f4e8740 -r 14d180f07fb7 sys/conf/majors
--- a/sys/conf/majors Sat Nov 06 06:52:48 2021 +0000
+++ b/sys/conf/majors Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: majors,v 1.99 2021/10/10 13:03:09 jmcneill Exp $
+# $NetBSD: majors,v 1.100 2021/11/06 13:34:39 brad Exp $
#
# Device majors for Machine-Independent drivers.
#
@@ -93,3 +93,4 @@
device-major acpi char 359 acpi
device-major smbios char 360 smbios
device-major efi char 361 efi
+device-major sht3xtemp char 362 sht3xtemp
diff -r c6e88f4e8740 -r 14d180f07fb7 sys/dev/i2c/files.i2c
--- a/sys/dev/i2c/files.i2c Sat Nov 06 06:52:48 2021 +0000
+++ b/sys/dev/i2c/files.i2c Sat Nov 06 13:34:39 2021 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.i2c,v 1.118 2021/10/14 13:54:46 brad Exp $
+# $NetBSD: files.i2c,v 1.119 2021/11/06 13:34:40 brad Exp $
obsolete defflag opt_i2cbus.h I2C_SCAN
define i2cbus { }
@@ -395,6 +395,11 @@
attach cwfg at iic
file dev/i2c/cwfg.c cwfg
+# Sensirion SHT30/SHT31/SHT35 Temperature and Humidity sensor
+device sht3xtemp
+attach sht3xtemp at iic
+file dev/i2c/sht3x.c sht3xtemp
+
# Sensirion SHT40/SHT41/SHT45 Temperature and Humidity sensor
device sht4xtemp
attach sht4xtemp at iic
diff -r c6e88f4e8740 -r 14d180f07fb7 sys/dev/i2c/sht3x.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
Home |
Main Index |
Thread Index |
Old Index