Reading I2C bits with STM32F4Discovery
Hello. I have the following scheme for reading the output of humidity sensor that communicates via I2C:
How would I execute this sequence with STM32CubeMX IDE and HAL libraries? The output of the sensor is as follows:

All I have now is this code:
uint8_t buf[2]; // 2 bytes? how to get 14 bits?
while (1)
{
if (HAL_I2C_IsDeviceReady(&hi2c1, 78, 5, 10) == HAL_OK){
res = HAL_I2C_Master_Transmit(&hi2c1, 78, 0, 2, 5); // start the writing cycle with bit 0;
if (res == HAL_OK){
res = HAL_I2C_Master_Receive(&hi2c1, 78, buf, 2, 10);
if (res == HAL_OK){
val = ((int16_t)buf[0] << 4) | (buf[1] >> 4); // how to combine these bytes?
if ( val > 0x7FF ) {
val |= 0xF000;
}
}
}
}
HAL_Delay(100);
}
