2023-01-23 12:09 PM
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
2023-01-23 12:32 PM
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.
2023-01-23 01:53 PM
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
2023-01-24 08:29 PM
> 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.