Skip to content

Commit

Permalink
Merge pull request RIOT-OS#13288 from catcombo/fix-ds18-temperature-c…
Browse files Browse the repository at this point in the history
…onversion

Fix ds18 temperature conversion
  • Loading branch information
benpicco authored Feb 7, 2020
2 parents dfcf155 + 234313a commit 5a4d39e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/ds18/ds18.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ int ds18_read(const ds18_t *dev, int16_t *temperature)

DEBUG("[DS18] Received byte: 0x%02x\n", b2);

int32_t measurement = ((int16_t)(b2 << 8 | b1) * 625);
*temperature = (int16_t)(measurement / 100);
int32_t measurement = (int16_t)(b2 << 8 | b1);
*temperature = (int16_t)((100 * measurement) >> 4);

return DS18_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/driver_ds18/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ../Makefile.tests_common

BOARD_WHITELIST := sensebox_samd21 samr21-xpro nucleo-l152re nucleo-l432kc nucleo-l073rz b-l072z-lrwan
BOARD_WHITELIST := sensebox_samd21 samr21-xpro nucleo-l152re nucleo-l432kc nucleo-l073rz b-l072z-lrwan arduino-nano

USEMODULE += ds18
USEMODULE += xtimer
Expand Down

0 comments on commit 5a4d39e

Please sign in to comment.