50 enum TMP102_STATUSTYPES
62 static enum TMP102_STATUSTYPES _TMP102_STATUS = 0x00;
75 if (!(_TMP102_STATUS & INITED))
77 PRINTFDEBUG (
"TMP102 init\n");
78 _TMP102_STATUS |= INITED;
80 TMP102_PWR_DIR |= TMP102_PWR_PIN;
81 TMP102_PWR_SEL &= ~TMP102_PWR_SEL;
82 TMP102_PWR_SEL2 &= ~TMP102_PWR_SEL;
83 TMP102_PWR_REN &= ~TMP102_PWR_SEL;
84 TMP102_PWR_OUT |= TMP102_PWR_PIN;
100 tmp102_write_reg (u8_t reg, u16_t val)
102 u8_t tx_buf[] = { reg, 0x00, 0x00 };
104 tx_buf[1] = (
u8_t) (val >> 8);
105 tx_buf[2] = (
u8_t) (val & 0x00FF);
107 i2c_transmitinit (TMP102_ADDR);
109 PRINTFDEBUG (
"I2C Ready to TX\n");
111 i2c_transmit_n (3, tx_buf);
113 PRINTFDEBUG (
"WRITE_REG 0x%04X @ reg 0x%02X\n", val, reg);
124 tmp102_read_reg (u8_t reg)
126 u8_t buf[] = { 0x00, 0x00 };
129 PRINTFDEBUG (
"READ_REG 0x%02X\n", reg);
132 i2c_transmitinit (TMP102_ADDR);
134 i2c_transmit_n (1, &rtx);
138 i2c_receiveinit (TMP102_ADDR);
140 i2c_receive_n (2, &buf[0]);
143 retVal = (
u16_t) (buf[0] << 8 | (buf[1]));
154 tmp102_read_temp_raw (
void)
158 rd = tmp102_read_reg (TMP102_TEMP);
169 tmp102_read_temp_simple (
void)
174 int16_t abstemp, temp_int;
176 raw = (int16_t) tmp102_read_reg (TMP102_TEMP);
178 abstemp = (raw ^ 0xFFFF) + 1;
185 temp_int = (abstemp >> 8) * sign;
194 rd = (int8_t) (temp_int);