Home > C: Programming > Function Descriptions > | History back Previous chapter Next chapter Print |
is_WriteI2C |
uEye Camera Manual Version 3.80
is_WriteI2C
USB 2.0 |
USB 2.0 |
Syntax
INT is_WriteI2C (HIDS hCam,
INT nDeviceAddr, INT nRegisterAddr,
BYTE* pbData, INT nLen)
Description
Using is_WriteI2C(), you can write data via the I2C bus of a board level camera.
The uEye processes I2C addresses in a 7-bit format that is created from the 8-bit format by a bit shift to the right. The eighth bit indicates whether an address is a read (1) or write (0) address. For example, the 7-bit address 0x48 is the write address 0x90 and the read address 0x91 in 8-bit format.
For information on the signals applied to the I2C bus, refer to the chapters with electrical specifications for the USB uEye LE and the USB uEye ME.
|
|
|
Input Parameters
hCam |
Camera handle |
nDeviceAddr |
Device address |
nRegisterAddr |
Address of a 8 bit register (only 8-bit addresses are valid) |
nRegisterAddr | |
Address of a 16 bit register |
pbData |
Data to be written |
nLen |
Data length nLen = 1: 8 bits data nLen = 2: 16 bits data |
Return Values
IS_SUCCESS |
Function executed successfully |
IS_NO_SUCCESS |
General error message |
Related Functions
Example
// ------------------------------------------------------ // Write to I2C device: // // 16 bit register addressing // Note: // Only writing 2 bytes at once is allowed
is_WriteI2C (hCam, DevAdr, RegAdr | IS_I2C_16_BIT_REGISTER, pbData, 2);
// 16 bit register addressing // Note: // Writing 1 or 2 bytes at once is allowed
// Writing 1 byte is_WriteI2C (hCam, DevAdr, RegAdr, pbData, 1); // Writing 2 bytes is_WriteI2C (hCam, DevAdr, RegAdr, pbData, 2);
// ------------------------------------------------------ // Read from I2C device: // // 16 bit register addressing // Note: // Only reading 2 bytes at once is allowed
is_ReadI2C (hCam, DevAdr, RegAdr | IS_I2C_16_BIT_REGISTER, pbData, 2);
// 8 bit register addressing // Note: // Reading 1 or 2 bytes at once is allowed
// Reading 1 byte is_ReadI2C (hCam, DevAdr, RegAdr, pbData, 1); // Reading 2 bytes is_ReadI2C (hCam, DevAdr, RegAdr, pbData, 2);
// ------------------------------------------------------ // Example values // Device address (from device data sheet): 0x40 // Device address in 8 bit format (after left shift): 0x80 // Device address for write (generated by is_WriteI2C()): 0x80 // Device address for read (generated by is_ReadI2C()) 0x81
// Write value 0x52 to device with address 0x40 in register 0x00 BYTE bValue = 0x52; is_WriteI2C (hCam, 0x80, 0x00, &bValue, 1);
// Read from device with address 0x40, register 0x00 INT nVal; BYTE bValue = 0; is_ReadI2C (hCam, 0x80, 0x00, &bValue, 1); |