mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-30 10:31:02 +00:00
1) Use floating-point more freely, since it's on all the time now, and the old fixed-point code no longer compiled. 2) Sensitivity and Bn values are now in a RAM-based struct in preparation for setting them at runtime. No changes from current values. 3) If a sensor fails to read good data, is initialized, or loses power, its die temperature history will be set to the next good temperature, rather than persisting an arbitrary start value or old state. This fixes reading wildly inaccurate object temperatures for the first few seconds following boot/resume. 4) If a sensor loses power, wait for the sensor to report data-ready before reading temperature/voltage. Otherwise, those read as 0, which again throws off the first few seconds of data. BUG=chrome-os-partner:14955 BRANCH=link TEST=Boot system and set at login screen for a minute to reach thermal equilibrium. Then reboot system, type 'temps' repeatedly. Data from TMP006's should initially be Error; after a second or so it should be good, and shouldn't change more than a few degrees. Change-Id: Id0b42b9b18e94978ba7d3a1ee33194e44b1904bc Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/35188
39 lines
1011 B
C
39 lines
1011 B
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* TMP006 temperature sensor module for Chrome EC */
|
|
|
|
#ifndef __CROS_EC_TMP006_H
|
|
#define __CROS_EC_TMP006_H
|
|
|
|
#define TMP006_ADDR(PORT,REG) ((PORT << 16) + REG)
|
|
#define TMP006_PORT(ADDR) (ADDR >> 16)
|
|
#define TMP006_REG(ADDR) (ADDR & 0xffff)
|
|
|
|
struct tmp006_t {
|
|
const char* name;
|
|
int addr; /* I2C address formed by TMP006_ADDR macro. */
|
|
float S0; /* Sensitivity factor */
|
|
};
|
|
|
|
/**
|
|
* Poll all TMP006 sensors.
|
|
*
|
|
* @return 0 if successful, non-zero if error. */
|
|
int tmp006_poll(void);
|
|
|
|
/**
|
|
* Get the last polled value of a sensor.
|
|
*
|
|
* @param idx Index to read. The low bit in idx indicates whether
|
|
* to read die temperature or object temperature. The
|
|
* other bits serve as internal index to tmp006 module.
|
|
*
|
|
* @return Temperature in K.
|
|
*/
|
|
int tmp006_get_val(int idx);
|
|
|
|
#endif /* __CROS_EC_TMP006_H */
|