cancel
Showing results for 
Search instead for 
Did you mean: 

Help with a simple SMBus Read Word().

RCooke88
Senior

I need to preform a simple SMBus read command but I'm not understanding how to set it up. I can do a I2C read() but I can't find any examples of how to do a simple SMBus read word(). Are there any simple examples?

Thanks,

Richard

3 REPLIES 3
Pavel A.
Evangelist III

See here what this API should do.

It looks like HAL_I2C_Mem_Read with one-byte address and two bytes of data.

The data is a 16-bit value in little-endian order.

RCooke88
Senior

I guess what I should have asked is:

Is the HAL_I2C_Mem_read() equal to the SMBus Read Word?

The SMBus read word sends the device address twice with two start bits. It looks like the HAL_I2C_Mem_Read() might be equivalent but now that I'm looking at the HAL doc it looks like it will send the second address as a uint16_t where the SMBus Read Word needs the second address an 8 bit value.

Does this make sense?

Thanks again,

Richard

> it looks like it will send the second address as a uint16_t

It cannot send anything as uint16, the bus understands only bytes.

All it does is swapping the bytes of the "register address" to big-endian form (because many devices expect this), only if this value is 16 bits. If it is 8 bits, obviously it is sent as is.

The smbus API defines only 8-bit "command", so it is a special case of HAL_I2C_Mem_Read with I2C_MEMADD_SIZE_8BIT.