Browse Source

Bugfix: hashfast: Use signed type for manipulating raw temperature data, in case it is below 0 C

Luke Dashjr 12 years ago
parent
commit
051909d984
1 changed files with 1 additions and 1 deletions
  1. 1 1
      driver-hashfast.c

+ 1 - 1
driver-hashfast.c

@@ -75,7 +75,7 @@ static inline
 float hashfast_temperature_conv(const uint8_t * const data)
 {
 	// Temperature is 12-bit fraction ranging between -61.5 C and ~178.5 C
-	uint32_t tempdata = ((uint32_t)data[1] << 8) | data[0];
+	int32_t tempdata = ((uint32_t)data[1] << 8) | data[0];
 	tempdata &= 0xfff;
 	tempdata *= 240;
 	tempdata -= 251904;  // 61.5 * 4096