cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_SMBUS_xxx wrong documentation suggests shifiting DevAddress

siquus
Associate

In the comment to the functions it says (stm32f4xx_hal_smbus.c)

 

* @PAram  DevAddress Target device address The device 7 bits address value
  *         in datasheet must be shifted to the left before calling the interface

 

I suspect this was copy & pasted from the I2C driver. When not shifting the address the driver works.

4 REPLIES 4
Pavel A.
Evangelist III

For the ST HAL I2C drivers, the address should not be shifted. The R/W flag in LSB is OR'ed.

Maybe this comment relates to device data sheets that follow the Linux i2c convention.

siquus
Associate

Hi,

Thanks! Then it would be nice to elaborate in that comment please. It took me quite some time until I by accident forgot to shift the address (as supplied in Texas Instruments Datasheet) and suddenly it worked 🙂

JRAUL.1
ST Employee

Dear,

This message is correct in the driver. No issue copy/paste.

In fact this message have been added as some "old" I2C slave document shared the address of their device in real 7bits definition. So it will be necessary to shift it to the left to put it in 8bits word.

Now, if your device already declare the address in 8bits in its appropriate datasheet, no need to shift it. Our recommendation is only for datasheet which share the device address in real 7bits.

HAL driver not support the internal shifting, to prevent the disparity of the datasheet owner definition of the I2C address.

Hope that clear now

Regards

For the ST HAL I2C drivers, the address should not be shifted. The R/W flag in LSB is OR'ed.


Which means exactly the opposite - the address should be shifted left by 1 bit. I2C addresses are 7-bit, not 8-bit in size. 😉