DCMD_I2C_RECV

#include <hw/i2c.h>

#define DCMD_I2C_RECV               __DIOTF(_DCMD_I2C, 6, i2c_recv_t)

The arguments to devctl() are:

Argument Value
filedes A file descriptor that you obtained by opening the device.
dcmd DCMD_I2C_RECV
dev_data_ptr A pointer to a i2c_recv_t, followed by the receive buffer
n_bytes sizeof(i2c_recv_t) plus the size of the receive buffer
dev_info_ptr NULL

The DCMD_I2C_RECV command executes a master receive transaction. It returns when the transaction is complete.

Input
  • i2c_recv_t — the message header
  • uint8_t[] — the receive buffer
Output
  • i2c_recv_t — the message header (unchanged)
  • uint8_t[] — the receive data in the buffer

The i2c_recv_t structure is defined as:

typedef struct {
    i2c_addr_t slave;  /* slave address */
    uint32_t   len;    /* length of receive data in bytes */
    uint32_t   stop;   /* send stop when complete? (0=no, 1=yes) */
} i2c_recv_t;

If an error occurs, the command returns:

EIO
The master send failed. Causes include: bad slave address, bad bus speed, bus is busy.
EINVAL
Bad message format.
ENOMEM
Insufficient memory.
EPERM
The master is locked by another connection.