diff --git a/drivers/include/tmp00x.h b/drivers/include/tmp00x.h index edc3a06057..bdc336474d 100644 --- a/drivers/include/tmp00x.h +++ b/drivers/include/tmp00x.h @@ -257,6 +257,10 @@ void tmp00x_convert(int16_t rawv, int16_t rawt, float *tamb, float *tobj); * @param[in] dev device descriptor of sensor * @param[out] ta converted ambient temperature * @param[out] to converted object temperature + * + * @return TMP00X_OK on success + * @return -TMP00X_ERROR if data read not ready + * @return -TMP00X_ERROR_BUS on I2C error */ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to); diff --git a/drivers/tmp00x/tmp00x.c b/drivers/tmp00x/tmp00x.c index 6872f9e7af..d97e0291b8 100644 --- a/drivers/tmp00x/tmp00x.c +++ b/drivers/tmp00x/tmp00x.c @@ -214,18 +214,30 @@ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to) xtimer_usleep(TMP00X_CONVERSION_TIME); #endif +int ret; #if TMP00X_USE_RAW_VALUES - tmp00x_read(dev, to, ta, &drdy); + if ((ret = tmp00x_read(dev, to, ta, &drdy)) < 0) { + return ret; + } if (!drdy) { - return TMP00X_ERROR; +#if TMP00X_USE_LOW_POWER + tmp00x_set_standby(dev); +#endif + return -TMP00X_ERROR; } #else - tmp00x_read(dev, &rawvolt, &rawtemp, &drdy); + if ((ret = tmp00x_read(dev, &rawvolt, &rawtemp, &drdy)) < 0) { + return ret; + } if (!drdy) { - return TMP00X_ERROR; +#if TMP00X_USE_LOW_POWER + tmp00x_set_standby(dev); +#endif + return -TMP00X_ERROR; } + tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj); *ta = (int16_t)(tamb*100); *to = (int16_t)(tobj*100); @@ -233,7 +245,7 @@ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to) #if TMP00X_USE_LOW_POWER if (tmp00x_set_standby(dev)) { - return TMP00X_ERROR; + return -TMP00X_ERROR; } #endif