How to properly use HAL I2C functions
Hey,
I'm working with TMP175AQDGKRQ1 (temperature sensor) which communicates over I2C.
I've managed to read the temperature register by doing this
static void Read_Temperature(unsigned char *buffer[2])
{
HAL_I2C_Master_Transmit(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR, /*0x00*/TEMPERATURE_REGISTER, 1, 100);
HAL_Delay(20);
HAL_I2C_Master_Receive(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR, buffer, 2, 100);
}Now I'm trying to write a register and then check if the register was actually written by doing this
bufferTx[0] = 0x00;
bufferTx[1] = 0x02;
HAL_I2C_Master_Transmit(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR, /*0x03*/THIGH_REGISTER , 1, 100);
HAL_Delay(20);
HAL_I2C_Master_Transmit(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR, bufferTx , 2, 100);
HAL_Delay(20);
HAL_I2C_Master_Transmit(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR | 0x01, /*0x03*/THIGH_REGISTER , 1, 100);
HAL_Delay(20);
HAL_I2C_Master_Receive(&hi2c1, /*0x4B<<1*/TEMP_SENSOR_ADDR, bufferRx, 2, 100);But it doesn't seem to work.. either I'm writing wrong, reading wrong or both.
To my understanding it should look like this (From the DS):

but i'm not sure how to control the R/W bit with the "HAL_I2C_Master_Transmit" and "HAL_I2C_Master_Receive" functions.
I would appreciate your help with that.
Rony.
