Please enable JavaScript to view this site.

IDS Software Suite 4.96.1

Windows_Logo
Linux_Logo

USB 2.0

USB 3.x

GigE

USB 2.0

USB 3.x

GigE

Syntax

INT is_WriteI2C (HIDS hCam, INT nDeviceAddr, INT nRegisterAddr, BYTE* pbData, INT nLen)

Description

Using is_WriteI2C(), you can write data via the TWI (Two Wire Interface) of a board level camera.

The function expects the device address as an 8-bit value, which is generated by a bit shift to the left from the 7-bit address of the device according to the data sheet. The function automatically fills bit 0 to indicate whether the device address is to be written (0) or read (1) from there.

For information on the signals applied to the TWI, refer to the D: Specifications chapters.

hint_info

I2C functions are only supported by the following PCB versions:

uEye LE USB 3.1 Gen 1

USB 3 uEye LE

USB uEye LE

GigE uEye LE.

hint_info

If you write data on a micro controller via the uEye camera, make sure that the micro controller confirms the transfer with an ACK message.

hint_info

The following addresses for nDeviceAddr are assigned to the uEye camera and must not be used:

7-bit format: 0x10, 0x20, 0x21, 0x48, 0x49, 0x4C, 0x50, 0x51, 0x52, 0x55, 0x5C, 0x5D, 0x69, 0x77

8-bit format: 0x20, 0x40, 0x42, 0x90, 0x92, 0x98, 0xA0, 0xA2, 0xA4, 0xAA, 0xB8, 0xBA, 0xD2, 0xEE

For UI-336x/UI-536x and UI-337x/UI-537x: 0x82

Input parameters

hCam

Camera handle

nDeviceAddr

Device address (8 bit format)

nDeviceAddr | IS_I2C_DONT_WAIT

By default, it is polled when the byte is actually written to the storage cell. If IS_I2C_DONT_WAIT is used with "OR" in combination with nDeviceAddr there will be no polling.

nRegisterAddr

Address of a 8 bit register (only 8-bit addresses are valid)

nRegisterAddr |
IS_I2C_16_BIT_REGISTER

Address of a 16 bit register

nRegisterAddr |
IS_I2C_0_BIT_REGISTER

If only a device address but no register address exists.

pbData

Data to be written

nLen

Data length (see list below)

Depending on the camera model and the register address, different minimum and maximum values apply for the data length (nLen).

Camera family

7-bit address

Register address

Minimum value

Maximum value

USB uEye LE

Yes

No flag

-

1 byte

nLen == 1 (1 byte data)

USB uEye LE

Yes

8-bit register

-

1 byte

nLen == 1 (1 byte data)

USB uEye LE

Yes

16-bit register

1 byte

nLen == 1 (1 byte data)

2 byte

nLen == 2 (2 byte data)

USB 3 uEye LE

Yes

No flag

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

USB 3 uEye LE

Yes

8-bit register

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

USB 3 uEye LE

Yes

16-bit register

2 byte

nLen == 2 (2 byte data)

62 byte

nLen == 62 (62 byte data)

uEye LE USB 3.1 Gen 1

Yes

No flag

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

uEye LE USB 3.1 Gen 1

Yes

8-bit register

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

uEye LE USB 3.1 Gen 1

Yes

16-bit register

2 byte

nLen == 2 (2 byte data)

62 byte

nLen == 62 (62 byte data)

GigE uEye LE

Yes

No flag

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

GigE uEye LE

Yes

8-bit register

1 byte

nLen == 1 (1 byte data)

62 byte

nLen == 62 (62 byte data)

GigE uEye LE

Yes

16-bit register

2 byte

nLen == 2 (2 byte data)

62 byte

nLen == 62 (62 byte data)

Return values

IS_CANT_COMMUNICATE_WITH_DRIVER

Communication with the driver failed because no driver has been loaded.

IS_CANT_OPEN_DEVICE

An attempt to initialize or select the camera failed (no camera connected or initialization error).

IS_INVALID_CAMERA_HANDLE

Invalid camera handle

IS_INVALID_I2C_DEVICE_ADDRESS

Invalid I2C device address

IS_INVALID_PARAMETER

One of the submitted parameters is outside the valid range or is not supported for this sensor or is not available in this mode.

IS_IO_REQUEST_FAILED

An IO request from the uEye driver failed. Possibly the versions of the ueye_api.dll (API) and the driver file (ueye_usb.sys or ueye_eth.sys) do not match.

This error code is also returned if the micro controller does not report back with ACK.

IS_NO_SUCCESS

General error message

IS_SUCCESS

Function executed successfully

Related functions

is_ReadI2C()

is_DeviceFeature: Setting the I2C stop bit

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);
 
// 8 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
is_ReadI2C (hCam, DevAdr, RegAdr | IS_I2C_16_BIT_REGISTER, pbData, 2);
 
// 8 bit register addressing
 
// 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);

© 2022 IDS Imaging Development Systems GmbH