Add support for continuous conversion mode
authorNathael Pajani <nathael.pajani@ed3l.fr>
Sat, 1 Dec 2018 13:19:47 +0000 (14:19 +0100)
committerNathael Pajani <nathael.pajani@ed3l.fr>
Tue, 8 Nov 2022 16:03:05 +0000 (17:03 +0100)
extdrv/tmp101_temp_sensor.c
include/extdrv/tmp101_temp_sensor.h

index 8677947..7a85a1f 100644 (file)
@@ -178,4 +178,23 @@ int tmp101_sensor_start_conversion(struct tmp101_sensor_config* conf)
        return 0; /* Conversion start success */
 }
 
+/* Place the sensor in continuous convertion mode */
+int tmp101_sensor_set_continuous_conversion(struct tmp101_sensor_config* conf)
+{
+       int ret = 0;
+       char cmd[CONF_BUF_SIZE] = { conf->addr, TMP_REG_CONFIG, };
+
+       if (tmp101_probe_sensor(conf) != 1) {
+               return -ENODEV;
+       }
+
+       cmd[2] = (TMP_THERMOSTAT_INTERRUPT_MODE | (conf->resolution & (0x03 << 5)));
+       ret = i2c_write(conf->bus_num, cmd, 3, NULL);
+       conf->last_accessed_register = TMP_REG_CONFIG;
+       if (ret != 3) {
+               conf->probe_ok = 0;
+               return ret;
+       }
+       return 0; /* Configuration change success */
+}
 
index 0eab9e7..d267e03 100644 (file)
@@ -108,6 +108,10 @@ int tmp101_sensor_config(struct tmp101_sensor_config* conf);
  */
 int tmp101_sensor_start_conversion(struct tmp101_sensor_config* conf);
 
+/* Place the sensor in continuous convertion mode.
+ * conf: the sensor configuration structure.
+ */
+int tmp101_sensor_set_continuous_conversion(struct tmp101_sensor_config* conf);
 
 #endif /* EXTDRV_TEMP_H */