[riot-notifications] [RIOT-OS/RIOT] drivers: add support for SHT2x (I2C temp and humidity sensor) (#10750)

Peter Kietzmann notifications at github.com
Mon Feb 4 21:41:41 CET 2019


PeterKietzmann commented on this pull request.

@keestux looks good! Thanks for addressing my comments. Will test (with the correct application :/ ) tomorrow. Besides the minor comment about `sht2x_type_t` I guess you can already squash 

> +    SHT2X_ERR_I2C_READ  = -4,           /**< I2C read error */
+    SHT2X_ERR_TIMEDOUT  = -5,           /**< timed out */
+    SHT2X_ERR_CRC       = -6,           /**< CRC error */
+    SHT2X_ERR_USERREG   = -7,           /**< cannot write User Reg */
+    SHT2X_ERR_RES       = -8,           /**< invalid resolution */
+    SHT2X_ERR_OTHER     = -999,         /**< fatal error */
+};
+
+/**
+ * @brief       Devices supported by this driver
+ */
+typedef enum {
+    SHT2X_TYPE_SHT20    = 0x01,         /**< SHT20 */
+    SHT2X_TYPE_SHT21    = 0x02,         /**< SHT21 */
+    SHT2X_TYPE_SHT25    = 0x03,         /**< SHT25 */
+} sht2x_type_t;

This isn't used anywhere, should we remove it?

> +    }
+
+    i2c_acquire(BUS);
+    res = i2c_read_regs(BUS, ADDR,
+                        second_mem_addr, data2, sizeof(data2), I2C_REG16);
+    i2c_release(BUS);
+    if (res < 0) {
+        return -1;
+    }
+    DEBUG("[SHT2x] ident (2): %02x %02x %02x\n", data2[0], data2[1], data2[2]);
+    DEBUG("[SHT2x] ident (2): %02x %02x %02x\n", data2[3], data2[4], data2[5]);
+    for (size_t ix = 0; ix < sizeof(data2); ix += 3) {
+        if (sht2x_checkcrc(&data2[ix], 2, data2[ix + 2]) != 0) {
+            DEBUG("[SHT2x] checksum error, second (ix=%d)\n", ix);
+        }
+    }

Makes sense.

> + */
+static sht2x_t sht2x_devs[SHT2X_NUMOF];
+
+/**
+ * @brief   Reference the driver structs.
+ * @{
+ */
+extern const saul_driver_t sht2x_temperature_saul_driver;
+extern const saul_driver_t sht2x_relative_humidity_saul_driver;
+/** @} */
+
+/**
+ * @brief   Memory for the SAUL registry entries
+ */
+#define SENSORS_NUMOF 2
+static saul_reg_t saul_entries[SHT2X_NUMOF * SENSORS_NUMOF];

Of course, my bad.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10750#pullrequestreview-199794290
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190204/22d87970/attachment-0001.html>


More information about the notifications mailing list