From: Nathael Pajani Date: Mon, 22 Jul 2013 15:22:01 +0000 (+0200) Subject: make temp conversion to decimal much more simple ! X-Git-Url: http://git.techno-innov.fr/?a=commitdiff_plain;h=21e43055a75f1d75becbc44dcfe70ee1e8a9df8b;p=soft%2Flpc122x%2Fcore make temp conversion to decimal much more simple ! --- 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