Module Name: src Committed By: brad Date: Thu Nov 7 20:06:22 UTC 2024
Modified Files: src/sys/dev/i2c: sht3x.c Log Message: The SHT3X_READ_SERIAL_NUMBER command on the SHT3x sensors is undocumented, but used in a lot of other drivers. When I wrote the driver it didn't seem like it needed any sort of delay, and that was true if the I2C bus is short. However, when the I2C bus is extended out to a great length using active terminators, or some such, you won't get any data back from the SHT3X_READ_SERIAL_NUMBER command as you will try to read from the bus before the data is there. The SHT3X device works this way.. you can't start reading back data too soon after issuing a command to the device. So, add a delay like the other commands. The amount of delay was estimated based upon field observation. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/dev/i2c/sht3x.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/i2c/sht3x.c diff -u src/sys/dev/i2c/sht3x.c:1.7 src/sys/dev/i2c/sht3x.c:1.8 --- src/sys/dev/i2c/sht3x.c:1.7 Wed Apr 27 23:11:25 2022 +++ src/sys/dev/i2c/sht3x.c Thu Nov 7 20:06:21 2024 @@ -1,5 +1,5 @@ -/* $NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $ */ +/* $NetBSD: sht3x.c,v 1.8 2024/11/07 20:06:21 brad Exp $ */ /* * Copyright (c) 2021 Brad Spencer <b...@anduin.eldar.org> @@ -18,7 +18,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.8 2024/11/07 20:06:21 brad Exp $"); /* Driver for the Sensirion SHT30/SHT31/SHT35 @@ -171,6 +171,10 @@ static struct sht3x_timing sht3x_timings { .cmd = SHT3X_WRITE_LOW_ALERT_CLEAR, .typicaldelay = 5000, + }, + { + .cmd = SHT3X_READ_SERIAL_NUMBER, + .typicaldelay = 500, } };