mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
Added api for reading out tmp100 x100 temps
This commit is contained in:
parent
65163a9b57
commit
0ea95c21b3
@ -160,13 +160,8 @@ tmp102_read_temp_raw (void)
|
|||||||
return rd;
|
return rd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
int16_t
|
||||||
/* Simple Read temperature. Return is an integer with temperature in 1deg. precision
|
tmp102_read_temp_x100(void)
|
||||||
Return value is a signed 8 bit integer.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int8_t
|
|
||||||
tmp102_read_temp_simple (void)
|
|
||||||
{
|
{
|
||||||
int16_t raw = 0;
|
int16_t raw = 0;
|
||||||
int8_t rd = 0;
|
int8_t rd = 0;
|
||||||
@ -181,8 +176,9 @@ tmp102_read_temp_simple (void)
|
|||||||
abstemp = raw;
|
abstemp = raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integer part of the temperature value */
|
/* Integer part of the temperature value and percents*/
|
||||||
temp_int = (abstemp >> 8) * sign;
|
temp_int = (abstemp >> 8) * sign * 100;
|
||||||
|
temp_int += ((abstemp & 0xff) * 100) / 0x100;
|
||||||
|
|
||||||
/* See test-tmp102.c on how to print values of temperature with decimals
|
/* See test-tmp102.c on how to print values of temperature with decimals
|
||||||
fractional part in 1/10000 of degree
|
fractional part in 1/10000 of degree
|
||||||
@ -191,6 +187,16 @@ tmp102_read_temp_simple (void)
|
|||||||
Data could be multiplied by 64 (<< 6) to trade-off precision for speed
|
Data could be multiplied by 64 (<< 6) to trade-off precision for speed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rd = (int8_t) (temp_int);
|
return temp_int;
|
||||||
return rd;
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
/* Simple Read temperature. Return is an integer with temperature in 1deg. precision
|
||||||
|
Return value is a signed 8 bit integer.
|
||||||
|
*/
|
||||||
|
|
||||||
|
int8_t
|
||||||
|
tmp102_read_temp_simple (void)
|
||||||
|
{
|
||||||
|
return (int8_t) tmp102_read_temp_x100() / 100;
|
||||||
}
|
}
|
||||||
|
@ -72,6 +72,11 @@ u16_t tmp102_read_temp_raw();
|
|||||||
*/
|
*/
|
||||||
int8_t tmp102_read_temp_simple();
|
int8_t tmp102_read_temp_simple();
|
||||||
|
|
||||||
|
/* Read only integer part of the temperature in 1deg. precision.
|
||||||
|
no args needed
|
||||||
|
*/
|
||||||
|
int16_t tmp102_read_temp_x100();
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
/* Reference definitions */
|
/* Reference definitions */
|
||||||
/* TMP102 slave address */
|
/* TMP102 slave address */
|
||||||
|
Loading…
Reference in New Issue
Block a user