drivers: sensor: sgp40: fix temperature formula
Fix the formula that computes T/ticks according to the details found on Table 9 of the datasheet. This patch fixes coverity issue 238343. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
parent
50a2cdd75a
commit
9dab2b3c5c
1 changed files with 1 additions and 1 deletions
|
@ -71,7 +71,7 @@ static int sgp40_attr_set(const struct device *dev,
|
||||||
int32_t tmp;
|
int32_t tmp;
|
||||||
|
|
||||||
tmp = CLAMP(val->val1, SGP40_COMP_MIN_T, SGP40_COMP_MAX_T);
|
tmp = CLAMP(val->val1, SGP40_COMP_MIN_T, SGP40_COMP_MAX_T);
|
||||||
t_ticks = ((tmp + 45U) * 0xFFFF / 175U) + 0.5;
|
t_ticks = ((tmp + 45) * 65535) / 175;
|
||||||
sys_put_be16(t_ticks, data->t_param);
|
sys_put_be16(t_ticks, data->t_param);
|
||||||
data->t_param[2] = sgp40_compute_crc(t_ticks);
|
data->t_param[2] = sgp40_compute_crc(t_ticks);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue