AnsweredAssumed Answered

STM32F4: I2C with re-starts

Question asked by denehan.joe on Feb 27, 2015
Just wondering if it's possible to send/receive I2C data using re-starts instead of Stop/Start.

So I transmit data with:

if( HAL_I2C_Master_Transmit(&hi2c2, ADDR_DS, i2c_data, 5, 1000) == HAL_OK )
      if( HAL_I2C_Master_Receive(&hi2c2, ADDR_DS, i2c_readbuf, 1, 1000) == HAL_OK )
               // do something

This will transmit in write mode, STOP, then START in receive mode. Stopping releases the bus so another device could access so I'd rather Transmit (no-stop) then RE-START in receive mode.

Is this possible with current HAL drivers.

I guess the function would look something like this:
HAL_I2C_Master_Transmit_Receive(&hi2c2, ADDR_DS, i2c_data, 5, i2c_readbuf, 1, 1000)

I have tested function HAL_I2C_Mem_Read and can accomplish re-starts if only transmitting 1 byte, which is probably the most common use anyway.