|
@@ -77,14 +77,15 @@ static inline unsigned int IN_FROM_REG(u8 reg, int n)
|
|
|
|
|
|
static inline u8 IN_TO_REG(unsigned long val, int n)
|
|
|
{
|
|
|
- return clamp_val(SCALE(val, 192, nom_mv[n]), 0, 255);
|
|
|
+ val = clamp_val(val, 0, nom_mv[n] * 255 / 192);
|
|
|
+ return SCALE(val, 192, nom_mv[n]);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* TEMP: 0.001 degC units (-128C to +127C)
|
|
|
* REG: 1C/bit, two's complement
|
|
|
*/
|
|
|
-static inline s8 TEMP_TO_REG(int val)
|
|
|
+static inline s8 TEMP_TO_REG(long val)
|
|
|
{
|
|
|
return SCALE(clamp_val(val, -128000, 127000), 1, 1000);
|
|
|
}
|