Main Page Modules Compound List File List Compound Members File Members
I2C high level and configuration routines
Function Documentation
U2C_RESULT _stdcall U2C_GetI2cFreq (
|
HANDLE hDevice,
|
|
BYTE * pFrequency )
|
|
|
Get I2C speed.
The U2C_GetI2cFreq function obtains I2C bus speed -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
pFrequency
|
A pointer to byte to be filled with current I2C bus frequency, where:
- 0 corresponds to I2C bus fast mode
- 1 corresponds to I2C bus standard mode
- 1+n corresponds to clock period of I2C bus equal to
uS
|
For convenience following constants were introduced:
- U2C_I2C_FREQ_FAST I2C bus fast mode
- U2C_I2C_FREQ_STD I2C bus standard mode
- U2C_I2C_FREQ_83KHZ 83 kHz
- U2C_I2C_FREQ_71KHZ 71 kHz
- U2C_I2C_FREQ_62KHZ 62 kHz
- U2C_I2C_FREQ_50KHZ 50 kHz
- U2C_I2C_FREQ_25KHZ 25 kHz
- U2C_I2C_FREQ_10KHZ 10 kHz
- U2C_I2C_FREQ_5KHZ 5 kHz
- U2C_I2C_FREQ_2KHZ 2 kHz
-
Returns:
-
- U2C_SUCCESS The frequency value was successfully retrieved.
- U2C_HARDWARE_NOT_FOUND I2CBridge device referenced by hDevice handle was not found
|
|
Execute I2C transactions pack.
The U2C_RW_Pack function will execute a list ( pack ) of I2C read/write transactions. All transactions will be send to U2C-11 device in a single USB transfer block. Next U2C_RW_Pack will wait for completion of each I2C transaction. I2C transactions will be performed sequantially according to the pack. Each transaction result code will be returned in pTransaction[i].rc element.
You should take care to pack correct sequence of the transactions. For instance attempt to read/write after write to I2C EEPROM may timeout because of the internal EEPROM write cycle. -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
pTransaction
|
List of the I2C transactions |
count
|
Number of the I2C transactions in the list |
-
Returns:
-
- U2C_SUCCESS - The data was successfully written.
- U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
- U2C_BAD_PARAMETER - Transactions list is too big.
|
|
I2C Read.
The U2C_Read function reads up to 256 bytes from the I2C slave device -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
pTransaction
|
Pointer to the U2C_TRANSACTION structure to be used during the read transaction Before calling the function this structure has to be partially filled:
- nSlaveDeviceAddress - must contain the slave I2C device address;
- nMemoryAddressLength - must contain the internal address length (in bytes from 0 up to 4). If nMemoryAddressLength is equal to 0, no address will be sent to device and repeated I2C start condition won't be generated
- MemoryAddress - must contain the internal I2C slave device address.
- nBufferLength - must contain the number of bytes to be read from the I2C slave device. After successful completion of the read operation Buffer member of the structure will be filled with data read from slave I2C device
|
-
Returns:
-
- U2C_SUCCESS - The data was successfully read.
- U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
- U2C_SLAVE_OPENNING_FOR_WRITE_FAILED
- U2C_SLAVE_OPENNING_FOR_READ_FAILED
- U2C_SENDING_MEMORY_ADDRESS_FAILED
|
|
Scan slave devices.
The U2C_ScanDevices function scans slave device addresses currently occupied by I2C slave devices connected to the I2C bus -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
pList
|
Pointer to the U2C_SLAVE_ADDR_LIST structure to be filled with slave device addresses. nDeviceNumber member will contain the number of the valid addresses in List array |
-
Returns:
-
- U2C_SUCCESS - Operation was successfully completed and pList is filled with valid data.
- U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
|
U2C_RESULT _stdcall U2C_SetI2cFreq (
|
HANDLE hDevice,
|
|
BYTE Frequency )
|
|
|
Select I2C speed.
The U2C_SetI2cFreq function configures I2C bus speed -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
Frequency
|
The frequency of I2C bus, where:
- 0 corresponds to I2C bus fast mode
- 1 corresponds to I2C bus standard mode
- 1+n corresponds to clock period of I2C bus equal to
uS
|
For convenience following constants were introduced:
- U2C_I2C_FREQ_FAST I2C bus fast mode
- U2C_I2C_FREQ_STD I2C bus standard mode
- U2C_I2C_FREQ_83KHZ 83 kHz
- U2C_I2C_FREQ_71KHZ 71 kHz
- U2C_I2C_FREQ_62KHZ 62 kHz
- U2C_I2C_FREQ_50KHZ 50 kHz
- U2C_I2C_FREQ_25KHZ 25 kHz
- U2C_I2C_FREQ_10KHZ 10 kHz
- U2C_I2C_FREQ_5KHZ 5 kHz
- U2C_I2C_FREQ_2KHZ 2 kHz
-
Returns:
-
- U2C_SUCCESS - The frequency value was successfully set.
- U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
|
|
I2C Write.
The U2C_Write function writes up to 256 bytes into the I2C slave device -
Parameters:
-
hDevice
|
Handle to the I2CBridge device |
pTransaction
|
Pointer to the U2C_TRANSACTION structure to be used during the write transaction Before calling the function this structure have to be filled:
- nSlaveDeviceAddress - must contain the slave I2C device address;
- nMemoryAddressLength - must contain the internal address length (in bytes from 0 up to 4). If nMemoryAddressLength is equal to 0, no address will be sent to device
- MemoryAddress - must contain the internal I2C slave device address.
- nBufferLength - must contain the number of bytes to be written into the I2C slave device.
- nBuffer - must contain the data to be written
|
-
Returns:
-
- U2C_SUCCESS - The data was successfully written.
- U2C_HARDWARE_NOT_FOUND - I2CBridge device referenced by hDevice handle was not found
- U2C_SLAVE_OPENNING_FOR_WRITE_FAILED
- U2C_SENDING_MEMORY_ADDRESS_FAILED
- U2C_SENDING_DATA_FAILED
|
|