diff options
Diffstat (limited to 'testhal/STM32/I2C/tmp75.c')
-rw-r--r-- | testhal/STM32/I2C/tmp75.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/testhal/STM32/I2C/tmp75.c b/testhal/STM32/I2C/tmp75.c index 6276e7c8e..72e634527 100644 --- a/testhal/STM32/I2C/tmp75.c +++ b/testhal/STM32/I2C/tmp75.c @@ -14,6 +14,7 @@ /* input buffer */
static i2cblock_t tmp75_rx_data[TMP75_RX_DEPTH];
+
/* temperature value */
static int16_t temperature = 0;
@@ -30,7 +31,6 @@ static void i2c_tmp75_cb(I2CDriver *i2cp, const I2CSlaveConfig *i2cscfg){ (void)*i2cp;
(void)*i2cscfg;
/* store temperature value */
- temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1];
}
/* Fill TMP75 config. */
@@ -43,12 +43,10 @@ static const I2CSlaveConfig tmp75 = { /* This is main function. */
void request_temperature(void){
-#define TXBYTES 0 /* set to zero because we need only reading */
-#define RXBYTES 2 /* we need to read 2 bytes */
-
i2cAcquireBus(&I2CD2);
- i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, RXBYTES);
+ i2cMasterReceive(&I2CD2, &tmp75, tmp75_addr, tmp75_rx_data, 2);
i2cReleaseBus(&I2CD2);
+ temperature = (tmp75_rx_data[0] << 8) + tmp75_rx_data[1];
}
|