From 21e43055a75f1d75becbc44dcfe70ee1e8a9df8b Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 22 Jul 2013 17:22:01 +0200 Subject: [PATCH] make temp conversion to decimal much more simple ! --- drivers/temp.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/temp.c b/drivers/temp.c index 7a1e7fe..1e89cd5 100644 --- a/drivers/temp.c +++ b/drivers/temp.c @@ -84,19 +84,12 @@ int probe_sensor(void) /* Convert raw temperature data (expressed as signed value of 16 times the * actual temperature in the twelve higher bits of a sixteen bits wide value) - * into a decimal interger value of ten times the actual temperature. + * into a decimal integer value of ten times the actual temperature. * The value returned is thus in tenth of degrees centigrade. */ int convert_to_deci_degrees(uint16_t raw) { - uint16_t val = ((raw >> 4) & 0x07FF); - int sign = 1; - - if (raw & 0x8000) { - sign = -1; - val = ~(val) + 1; - } - return (sign * (((int)val * 10) / 16)); + return (((int)raw * 10) >> 8); } /* Temp Read -- 2.43.0