DlnI2cMasterScanDevices() Function

The DlnI2cMasterScanDevices() function scans all the 127 slave addresses searching for connected I2C slave devices.

Syntax
C/C++
DLN_RESULT DlnI2cMasterScanDevices(
   HDLN handle,
   uint8_t port,
   uint8_t* addressCount,
   uint8_t* addressList
);
Parameters
handle

A handle to the DLN adapter.

port

A number of the I2C master port scan for I2C slave devices.

addressCount

A pointer to an unsigned 8-bit integer that receives the number of found I2C slave devices.

addressList

A pointer to an array of unsigned 8-bit integers that receives the addresses of found I2C slave devices. I2C address is 7-bit long, so the most significant bit of the received integers will always be equal to zero. Some vendors specify the 8-bit addresses in their documentation. If you need to convert a 8-bit I2C address to 7-bit address, take a look at I2C address article.

Return Value
DLN_RES_SUCCESS (0x00)

The function scanned the I2C addresses and found all connected I2C slaves successfully.

DLN_RES_INVALID_PORT_NUMBER (0xA8)

The port number is not valid. Use the DlnI2cMasterGetPortCount() function to find the maximum possible port number.

DLN_RES_BUSY (0xB6)

The function cannot scan I2C addresses while the I2C master port is busy transferring.

DLN_RES_DISABLED (0xB7)

The function cannot scan I2C addresses because the specified I2C master port is not active. Use the DlnI2cMasterEnable()function to activate the I2C master port.

DLN_RES_OPERATION_TIMEOUT

The function failed to scan all slave addresses.

Remarks

The DlnI2cMasterScanDevices() function is defined in the dln_i2c_master.h file.