3 * Ricado Ribalda-Universidad Autonoma de Madrid, ricardo.ribalda@uam.es
4 * This work has been supported by: QTechnology http://qtec.com/
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #define ADT7460_ADDRESS 0x2c
23 #define ADT7460_INVALID 128
24 #define ADT7460_CONFIG 0x40
25 #define ADT7460_REM1_TEMP 0x25
26 #define ADT7460_LOCAL_TEMP 0x26
27 #define ADT7460_REM2_TEMP 0x27
29 int dtt_read(int sensor, int reg)
34 if (i2c_read(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
36 if (data == ADT7460_INVALID)
42 int dtt_write(int sensor, int reg, int val)
47 if (i2c_write(ADT7460_ADDRESS, dir, 1, &data, 1) == -1)
53 int dtt_init_one(int sensor)
55 printf("ADT7460 at I2C address 0x%2x\n", ADT7460_ADDRESS);
57 if (dtt_write(0, ADT7460_CONFIG, 1) == -1) {
58 puts("Error initialiting ADT7460\n");
65 int dtt_get_temp(int sensor)
69 { ADT7460_REM1_TEMP, ADT7460_LOCAL_TEMP, ADT7460_REM2_TEMP };
72 puts("DTT sensor does not exist\n");
76 aux = dtt_read(0, table[sensor]);
78 puts("DTT temperature read failed\n");