Tool/software:
Hi,
Does USB2Any support multibyte I2C transactions?
Example:
Working Case : I2C Write (Slave Addr, Reg Addr, Data (1byte))
Expected Case : I2C Write (Slave Addr, Reg Addr, Data (n-bytes))
Thanks,
Katie
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
Hi,
Does USB2Any support multibyte I2C transactions?
Example:
Working Case : I2C Write (Slave Addr, Reg Addr, Data (1byte))
Expected Case : I2C Write (Slave Addr, Reg Addr, Data (n-bytes))
Thanks,
Katie
Revision History:
Does USB2Any support multibyte I2C transactions?
It does, provided you use the multibyte variants of the I2C APIs.
USB2ANY includes several API variants that have subtly different I2C transaction signatures. Refer to the legend and diagrams below.
int u2aI2C_RawRead(U2A_HANDLE handle, UInt16 I2C_Address, Byte nBytes, Byte *Data)
:
nBytes
bytes of data, controller ACKs each byte, controller STOPsnBytes
must be <= 51 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 3 bytes are API arguments in the payload for the u2aI2C_RawRead
API)int u2aI2C_RawWrite(U2A_HANDLE handle, UInt16 I2C_Address, Byte nBytes, Byte *Data)
:
I2C_Address
, target ACKsnBytes
bytes of *Data
, target ACKs each byte, controller STOPsnBytes
must be <= 51 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 3 bytes are API arguments in the payload for the u2aI2C_RawWrite
API)int u2aI2C_RegisterRead(U2A_HANDLE handle, UInt16 I2C_Address, Byte RegisterAddress)
:
I2C_Address
, target ACKsRegisterAddress
, target ACKs, controller STOPsI2C_Address
, target ACKsint
on success, or a negative error code on failureint u2aI2C_RegisterWrite(U2A_HANDLE handle, UInt16 I2C_Address, Byte RegisterAddress, Byte Value)
:
I2C_Address
, target ACKsRegisterAddress
, target ACKsValue
, target ACKs, controller STOPsint u2aI2C_MultiRegisterRead(U2A_HANDLE handle, UInt16 I2C_Address, Byte StartingRegisterAddress, Byte nBytes, Byte *Data)
:
I2C_Address
, target ACKsStartingRegisterAddress
, target ACKs, controller STOPsI2C_Address
, target ACKsnBytes
bytes of *Data
, controller ACKs each byte, controller STOPsnBytes
must be <= 50 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 4 bytes are API arguments in the payload for the u2aI2C_MultiRegisterRead
API)int u2aI2C_MultiRegisterWrite(U2A_HANDLE handle, UInt16 I2C_Address, Byte StartingRegisterAddress, Byte nBytes, Byte *Data)
:
I2C_Address
, target ACKsStartingRegisterAddress
, target ACKsnBytes
bytes of *Data
, target ACKs each byte, controller STOPsnBytes
must be <= 50 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 4 bytes are API arguments in the payload for the u2aI2C_MultiRegisterWrite
API)int u2aI2C_InternalRead(U2A_HANDLE handle, UInt16 I2C_Address, UInt16 InternalAddress, Byte IntAddrSize, UInt16 nBytes, Byte *Data)
:
I2C_Address
, target ACKsIntAddrSize
== 0:
IntAddrSize
== 1:
InternalAddress
, target ACKsIntAddrSize
== 2:
InternalAddress
(as big-endian), target ACKs each bytenBytes
bytes of *Data
, controller ACKs each byte, controller STOPsnBytes
must be <= 47 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 7 bytes are API arguments in the payload for the u2aI2C_InternalRead
API)nBytes
in InternalRead/InternalWrite arguments are UInt16, even though the value can never be greater than 47. I think at one point the API was supposed to handle a much-larger buffer using on-board memory and an alternative, non-HID channel, but this is just speculation on my part.int u2aI2C_InternalWrite(U2A_HANDLE handle, UInt16 I2C_Address, UInt16 InternalAddress, Byte IntAddrSize, UInt16 nBytes, Byte *Data)
:
I2C_Address
, target ACKsIntAddrSize
== 0:
nBytes
bytes of *Data
, target ACKs each byte, controller STOPsIntAddrSize
== 1:
InternalAddress
, target ACKsnBytes
bytes of *Data
, target ACKs each byte, controller STOPsIntAddrSize
== 2:
InternalAddress
(as big-endian), target ACKs each bytenBytes
bytes of *Data
, target ACKs each byte, controller STOPsnBytes
must be <= 47 (USB2ANY uses 64-byte HID packets, of which 10 bytes are header, and 7 bytes are API arguments in the payload for the u2aI2C_InternalWrite
API)nBytes
in InternalRead/InternalWrite arguments are UInt16, even though the value can never be greater than 47. I think at one point the API was supposed to handle a much-larger buffer using on-board memory and an alternative, non-HID channel, but this is just speculation on my part.int u2aI2C_BlockWriteBlockRead(U2A_HANDLE handle, UInt16 I2C_Address, Byte nWriteBytes, Byte *WriteData, Byte nReadBytes, Byte *ReadData)
:
I2C_Address
, target ACKsnWriteBytes
bytes of *WriteData
, target ACKs each byteI2C_Address
, target ACKsnReadBytes
bytes of *ReadData
, controller ACKs each byte, controller STOPs