From: Nathael Pajani Date: Sat, 1 Dec 2018 13:19:47 +0000 (+0100) Subject: Add support for continuous conversion mode X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=90cd93a0236b8470c26135f66c81155fcbb51908;p=soft%2Flpc122x%2Fcore Add support for continuous conversion mode --- diff --git a/extdrv/tmp101_temp_sensor.c b/extdrv/tmp101_temp_sensor.c index 8677947..7a85a1f 100644 --- a/extdrv/tmp101_temp_sensor.c +++ b/extdrv/tmp101_temp_sensor.c @@ -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 */ +} diff --git a/include/extdrv/tmp101_temp_sensor.h b/include/extdrv/tmp101_temp_sensor.h index 0eab9e7..d267e03 100644 --- a/include/extdrv/tmp101_temp_sensor.h +++ b/include/extdrv/tmp101_temp_sensor.h @@ -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 */