Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
mpu6050: Add check of WHO_AM_I register value
Most of i2c chips have a special read-only register with unique id. So the easiest way to communicate with the device is to read that register. It should be accessibe even during power off modes and so failing to read it means no communication with the device. Reading non-expected value will indicate wrong adress or data size used, or incorrect device connected (other revision). Reading small amounts of data is easiest done using i2c_smbus_read_byte() or similar functions. Why smbus? Because they are wrappers to i2c_transfer() function and have internal device address as a parameter. This eliminates need to fill i2c_transfer structure for each small read or write. Using i2c_transfer() should be considered for large blocks of data and gives a performance boost over i2c_smbus wrappers. Signed-off-by: Andriy.Khulap <[email protected]>
- Loading branch information