Use the I2C Master Interface functions to control and monitor the I2C Master module of a DLN-series adapter. The dln_i2c_master.h
file declares the I2C Master Interface functions.
General port information:
Retrieves the total number of I2C master ports available at your DLN-series adapter.
Assigns a port to the I2C Master module.
Releases a port from the I2C Master module.
Retrieves whether a port is assigned to the I2C Master module.
Scans all slave addresses searching for connected I2C slave devices.
I2C Master module configuration functions:
Configures frequency for the specified I2C master port.
Retrieves frequency configuration for an I2C Master port.
Configures the maximum reply count for an I2C master port.
Retrieves the maximum reply count configuration.
Transmission functions:
Receives data from the specified slave. Internal address can be specified.
Sends data to the specified slave. Internal address can be specified.
Sends data to the specified slave, then reads data from the same slave (only DLN-1 and DLN-2 adapters support this function).
The DlnI2cMasterDisable()
function releases the specified port from the I2C Master module.
The DlnI2cMasterEnable()
function assigns the specified port to the I2C Master module.
The DlnI2cMasterGetFrequency()
function retrieves the current I2C bus clock frequency.
The DlnI2cMasterGetMaxReplyCount()
function retrieves maximum reply count for I2C master port.
The DlnI2cMasterGetPortCount()
function retrieves the total number of I2C master ports available at your DLN-series adapter.
The DlnI2cMasterIsEnabled()
function checks whether the specified I2C master port is active or not.
The DlnI2cMasterRead()
function reads data from the specified I2C slave device.
The DlnI2cMasterScanDevices()
function scans all the 127 slave addresses searching for connected I2C slave devices.
The DlnI2cMasterSetFrequency()
function configures the clock frequency for the specified I2C port.
The DlnI2cMasterSetMaxReplyCount()
function sets maximum reply count for I2C master port.
DLN-1 and DLN-2 adapters cannot send a single slave address and direction bit without data bytes. This is a firmware driver limitation. Therefore, an adapter cannot read a single byte at all possible addresses. Retrying every read/write operation 10 times is set by default in firmware I2C driver, but using the DlnI2cMasterSetMaxReplyCount()
function you can modify this parameter.
The DlnI2cMasterTransfer()
function sends and receives data via the I2C bus. The data is sent and received as an array of 1-byte elements.
The DlnI2cMasterWrite()
function sends data to the specified I2C slave device.