There are two ways to detect an I2C transmission:
To observe I2C lines permanently. This consumes much CPU time. Besides, the more times the device polls the I2C bus, the less time it can spend carrying out its intended function. That is why such devices are slow.
To receive events about the requests from the I2C bus. You can configure event generation when the I2C master addresses for receiving or transmitting data.
To configure events, use the DlnI2cSlaveSetEvent() function. You need to specify the slaveAddressNumber
and eventType
parameters. The DlnI2cSlaveGetSupportedEventTypes() function returns the list of event types available for the I2C slave port.
The eventType
parameter can have one of the following values:
| A DLN adapter does not generate any I2C events. |
| A DLN adapter generates events when the I2C master device initiates receiving data from the I2C slave address assigned to the DLN adapter. The |
| A DLN adapter generates events when the I2C master device initiates transmitting data to the I2C slave address assigned to the DLN adapter. The |
| A DLN adapter generates events when the I2C master device initiates receiving data from or transmitting data to the I2C slave address assigned to the DLN adapter. The |
By default, event generation is disabled for all I2C slave addresses (the eventType
parameter is set to DLN_I2C_SLAVE_EVENT_NONE
).
If your DLN adapter uses more than one I2C slave address, you can specify different event configuration for each I2C slave address.
A DLN adapter generates the DLN_I2C_SLAVE_EVENT_READ
events each time the I2C master device initiates receiving data from the I2C slave address assigned to the DLN adapter.
Use the DlnI2cSlaveSetEvent() function to configure events. Pass DLN_I2C_SLAVE_EVENT_READ
for the eventType
parameter.
The DLN_I2C_SLAVE_READ_EV
structure describes the event details: event counter, I2C slave address and port number, and the buffer size. The header of the structure contains the msgId
field that is set to DLN_MSG_ID_I2C_SLAVE_READ_EV (0x0C10)
.
A DLN adapter generates the DLN_I2C_SLAVE_EVENT_WRITE
events each time the I2C master device initiates transmitting data to the I2C slave address assigned to the DLN adapter.
Use the DlnI2cSlaveSetEvent() function to configure events. Pass DLN_I2C_SLAVE_EVENT_WRITE
for the eventType
parameter.
The DLN_I2C_SLAVE_WRITE_EV
structure describes the event details: event counter, I2C slave address and port number, the buffer size and the received data. The header of the structure contains the msgId
field that is set to DLN_MSG_ID_I2C_SLAVE_WRITE_EV (0x0C11)
.
A DLN adapter generates the DLN_I2C_SLAVE_EVENT_READ_WRITE
events each time the I2C master device initiates receiving data from or transmitting data to the I2C slave address assigned to the DLN adapter.
Use the DlnI2cSlaveSetEvent() function to configure events. Pass DLN_I2C_SLAVE_EVENT_READ_WRITE
for the eventType
parameter.
The DLN_I2C_SLAVE_EVENT_READ_WRITE
events are described by two structures:
The DLN_I2C_SLAVE_READ_EV
structure describes the I2C read event details: event counter, I2C slave address and port number, and the buffer size. The header of the structure contains the msgId
field that is set to DLN_MSG_ID_I2C_SLAVE_READ_EV (0x0C10)
.
The DLN_I2C_SLAVE_WRITE_EV
structure describes the I2C write event details: event counter, I2C slave address and port number, the buffer size and the received data. The header of the structure contains the msgId
field that is set to DLN_MSG_ID_I2C_SLAVE_WRITE_EV (0x0C11)
.