drivers/tmp00x: cleanup return codes
This also fixes a scan-build warning about a potential use of uninitialized parameter to the call of tmp0xx_read function
This commit is contained in:
parent
e4f1b67612
commit
c062d74b84
@ -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[in] dev device descriptor of sensor
|
||||||
* @param[out] ta converted ambient temperature
|
* @param[out] ta converted ambient temperature
|
||||||
* @param[out] to converted object 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);
|
int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to);
|
||||||
|
|
||||||
|
|||||||
@ -214,18 +214,30 @@ int tmp00x_read_temperature(const tmp00x_t *dev, int16_t *ta, int16_t *to)
|
|||||||
xtimer_usleep(TMP00X_CONVERSION_TIME);
|
xtimer_usleep(TMP00X_CONVERSION_TIME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int ret;
|
||||||
#if TMP00X_USE_RAW_VALUES
|
#if TMP00X_USE_RAW_VALUES
|
||||||
tmp00x_read(dev, to, ta, &drdy);
|
if ((ret = tmp00x_read(dev, to, ta, &drdy)) < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (!drdy) {
|
if (!drdy) {
|
||||||
return TMP00X_ERROR;
|
#if TMP00X_USE_LOW_POWER
|
||||||
|
tmp00x_set_standby(dev);
|
||||||
|
#endif
|
||||||
|
return -TMP00X_ERROR;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
tmp00x_read(dev, &rawvolt, &rawtemp, &drdy);
|
if ((ret = tmp00x_read(dev, &rawvolt, &rawtemp, &drdy)) < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
if (!drdy) {
|
if (!drdy) {
|
||||||
return TMP00X_ERROR;
|
#if TMP00X_USE_LOW_POWER
|
||||||
|
tmp00x_set_standby(dev);
|
||||||
|
#endif
|
||||||
|
return -TMP00X_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj);
|
tmp00x_convert(rawvolt, rawtemp, &tamb, &tobj);
|
||||||
*ta = (int16_t)(tamb*100);
|
*ta = (int16_t)(tamb*100);
|
||||||
*to = (int16_t)(tobj*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_USE_LOW_POWER
|
||||||
if (tmp00x_set_standby(dev)) {
|
if (tmp00x_set_standby(dev)) {
|
||||||
return TMP00X_ERROR;
|
return -TMP00X_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user