47 #include "lib/sensors.h"
51 #define PRINTF(...) printf(__VA_ARGS__)
56 static uint8_t enabled;
62 TMP102_PWR_DIR |= TMP102_PWR_PIN;
63 TMP102_PWR_SEL &= ~TMP102_PWR_SEL;
64 TMP102_PWR_SEL2 &= ~TMP102_PWR_SEL;
65 TMP102_PWR_REN &= ~TMP102_PWR_SEL;
66 TMP102_PWR_OUT |= TMP102_PWR_PIN;
78 TMP102_PWR_OUT &= ~TMP102_PWR_PIN;
83 tmp102_write_reg(uint8_t reg, uint16_t val)
85 uint8_t tx_buf[] = { reg, 0x00, 0x00 };
87 tx_buf[1] = (uint8_t)(val >> 8);
88 tx_buf[2] = (uint8_t)(val & 0x00FF);
92 PRINTF(
"I2C Ready to TX\n");
94 i2c_transmit_n(3, tx_buf);
96 PRINTF(
"WRITE_REG 0x%04X @ reg 0x%02X\n", val, reg);
100 tmp102_read_reg(uint8_t reg)
102 uint8_t buf[] = { 0x00, 0x00 };
105 PRINTF(
"READ_REG 0x%02X\n", reg);
110 i2c_transmit_n(1, &rtx);
116 i2c_receive_n(2, &buf[0]);
119 retVal = (uint16_t)(buf[0] << 8 | (buf[1]));
125 tmp102_read_temp_raw(
void)
133 tmp102_read_temp_x100(
void)
137 int16_t abstemp, temp_int;
141 abstemp = (raw ^ 0xFFFF) + 1;
148 temp_int = (abstemp >> 8) * sign * 100;
149 temp_int += ((abstemp & 0xff) * 100) / 0x100;
154 tmp102_read_temp_simple(
void)
157 return tmp102_read_temp_x100() / 100;
161 configure(
int type,
int value)
163 if(type != SENSORS_ACTIVE) {
172 return TMP102_SUCCESS;
183 return TMP102_SUCCESS;
189 return (
int)tmp102_read_temp_x100();
192 SENSORS_SENSOR(tmp102, TMP102_SENSOR, value, configure, status);
#define TMP102_ADDR
TMP102 slave address.
#define TMP102_TEMP
TMP102 temperature data register.
void i2c_enable(void)
Configure serial controller in I2C mode and set I2C speed.
I2C communication device driver header file for Zolertia Z1 sensor node.
Device drivers header file for tmp102 temperature sensor in Zolertia Z1 WSN Platform...
void tmp102_init(void)
Initialiser for the TMP102 sensor driver.