Name

i2c_rx — reads from a slave device

Synopsis

#include <i2c.h>   
void i2c_rx (dev,  
 data,  
 count); 
uint8_t dev;
uint8_t * data;
uint8_t count;
 

Arguments

dev

7-bit slave device address

data

bytes to be read

count

number of bytes to read

Description

Reads a sequence of bytes from the slave device at address dev, and stores them in data. The API generates the START condition, selects the slave device, reads the data from the slave and generates the STOP condition.

Errors

ERR_I2C_NODEV, ERR_I2C_NOACK

Example


   // Read 3 bytes from device 0x51.
   uint8_t bytes[3];
   i2c_rx(0x51, bytes, 3);