mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #12586 from aabadie/pr/drivers/tmp00x_scan_build
drivers/tmp00x: cleanup return codes and fix potential use of uninitialized parameter
This commit is contained in:
commit
8836f225e6
@ -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…
Reference in New Issue
Block a user