U2C-11 USB-I2C/SPI/GPIO Interface Adapter

 
Main Page   Modules   Compound List   File List   Compound Members   File Members  

I2C low level routines


Functions

U2C_RESULT U2C_Start (HANDLE hDevice)
 Generate I2C Start. More...

U2C_RESULT U2C_RepeatedStart (HANDLE hDevice)
 Generate repeated Start. More...

U2C_RESULT U2C_Stop (HANDLE hDevice)
 Generate Stop condition. More...

U2C_RESULT U2C_PutByte (HANDLE hDevice, BYTE Data)
 Shift out byte. More...

U2C_RESULT U2C_GetByte (HANDLE hDevice, BYTE *pData)
 Shift in byte. More...

U2C_RESULT U2C_PutByteWithAck (HANDLE hDevice, BYTE Data)
 Shift out byte and get ACK. More...

U2C_RESULT U2C_GetByteWithAck (HANDLE hDevice, BYTE *pData, BOOL bAck)
 Shift in byte and generate ACK/NAK. More...

U2C_RESULT U2C_PutAck (HANDLE hDevice, BOOL bAck)
 Generate ACK/NAK. More...

U2C_RESULT U2C_GetAck (HANDLE hDevice)
 Get ACK from Slave. More...


Function Documentation

U2C_RESULT _stdcall U2C_GetAck ( HANDLE hDevice )
 

Get ACK from Slave.

The U2C_GetAck function checks for acknowledge from I2C slave device. This function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
Returns:
  • U2C_SUCCESS - I2C slave device provided acknowledge
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found U2C_NO_ACK I2C slave device did not provide acknowledge

U2C_RESULT _stdcall U2C_GetByte ( HANDLE hDevice,
BYTE * pData )
 

Shift in byte.

The U2C_GetByte function shifts in (reads) a single byte from the I2C bus. It assumes that the bus is available, the Start Condition has been previously generated and the slave device has been properly addressed. This function doesn't generate acknowledge, so you must call the U2C_PutAck function or use U2C_GetByteWithAck instead of U2C_GetByte function. This function can be called several times to implement custom I2C like protocol. The function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
pData   A pointer to byte to be filled with data read from the I2C bus
Returns:
  • U2C_SUCCESS - Byte was successfully read from the I2C bus.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_GetByteWithAck ( HANDLE hDevice,
BYTE * pData,
BOOL bAck )
 

Shift in byte and generate ACK/NAK.

The U2C_GetByteWithAck function shifts in (reads) a single byte from the I2C bus and then generates acknowledge or not-acknowledge condition according to the value passed in bAck parameter. It assumes that the bus is available, the Start Condition has been previously generated and the slave device has been properly addressed. This function can be called several times to implement custom I2C like protocol. The function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
pData   A pointer to byte to be filled with data read from the I2C bus
bAck   This parameter determines if acknowledge should be generated after the byte is transmitted. If bAck is TRUE - acknowledge will be generated, if bAck is FALSE - non-acknowledge will be generated
Returns:
  • U2C_SUCCESS - Byte was successfully read from I2C bus.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_PutAck ( HANDLE hDevice,
BOOL bAck )
 

Generate ACK/NAK.

The U2C_PutAck function generates acknowledge or not-acknowledge condition according to the value passed in bAck parameter. This function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
bAck   This parameter determines whether acknowledge or non-acknowledge should be generated. If bAck is TRUE - acknowledge will be generated, if bAck is FALSE - non-acknowledge will be generated
Returns:
  • U2C_SUCCESS - Acknowledge / non-acknowledge condition was successfully generated.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_PutByte ( HANDLE hDevice,
BYTE Data )
 

Shift out byte.

The U2C_PutByte function shifts out (transmits) a single byte to the I2C bus. It assumes that the bus is available and the Start Condition has been generated first. This function doesn't check acknowledge from the I2C slave device, so you must call U2C_GetAck to check acknowledge or to use U2C_PutByteWithAck instead of U2C_PutByte function. This function can be called several times to implement custom I2C like protocol. The function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
Data   Byte to be transmitted to the I2C bus
Returns:
  • U2C_SUCCESS - Byte was successfully transmitted to the I2C bus.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_PutByteWithAck ( HANDLE hDevice,
BYTE Data )
 

Shift out byte and get ACK.

The U2C_PutByteWithAck function shifts out (transmits) a single byte to the I2C bus and checks for acknowledge from I2C slave device. It assumes that the bus is available and the Start Condition has been generated first. This function can be called several times to implement custom I2C like protocol. The function does not finish the I2C bus transaction after transmission, so at the end of I2C transaction U2C_Stop function has to be called

Parameters:
hDevice   Handle to the I2CBridge device
Data   Byte to be transmitted to the I2C bus
Returns:
  • U2C_SUCCESS - Byte was successfully transmitted to the I2C bus and I2C slave device provided acknowledge
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
  • U2C_NO_ACK - I2C slave device did not acknowledge the transmitted byte

U2C_RESULT _stdcall U2C_RepeatedStart ( HANDLE hDevice )
 

Generate repeated Start.

The U2C_RepeatedStart function generates the repeated start condition on the I2C bus.

Parameters:
hDevice   Handle to the I2CBridge device
Returns:
  • U2C_SUCCESS - Repeated start condition was successfully generated.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_Start ( HANDLE hDevice )
 

Generate I2C Start.

The U2C_Start function generates the start condition on the I2C bus.

Parameters:
hDevice   Handle to the I2CBridge device
Returns:
  • U2C_SUCCESS - Start condition was successfully generated.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

U2C_RESULT _stdcall U2C_Stop ( HANDLE hDevice )
 

Generate Stop condition.

The U2C_Stop function generates the stop condition on the I2C bus. It can be also used for the generation of the repeated stop condition

Parameters:
hDevice   Handle to the I2CBridge device
Returns:
  • U2C_SUCCESS - Stop condition was successfully generated.
  • U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found

Copyright DiMAX 2002-2004