drivers: sensor: lis2dh: Fix I2C burst read/write operations

As stated in LIS2DH datasheet in section "5.1.1 I2C Operation",
in order to read/write multiple bytes on I2C it is necessary
to add the autoincrement bit to the subaddress field.

Signed-off-by: Armando Visconti <armando.visconti@st.com>
This commit is contained in:
Armando Visconti 2018-06-08 11:39:03 +02:00 committed by Anas Nashif
parent e16037d87a
commit 87bd2c25bf
1 changed files with 4 additions and 2 deletions

View File

@ -235,7 +235,8 @@ static inline int lis2dh_burst_read(struct device *dev, u8_t start_addr,
return lis2dh_spi_access(lis2dh, start_addr, buf, num_bytes);
#elif defined(CONFIG_LIS2DH_BUS_I2C)
return i2c_burst_read(lis2dh->bus, LIS2DH_BUS_ADDRESS, start_addr,
return i2c_burst_read(lis2dh->bus, LIS2DH_BUS_ADDRESS,
start_addr | LIS2DH_AUTOINCREMENT_ADDR,
buf, num_bytes);
#else
return -ENODEV;
@ -269,7 +270,8 @@ static inline int lis2dh_burst_write(struct device *dev, u8_t start_addr,
return lis2dh_spi_access(lis2dh, start_addr, buf, num_bytes);
#elif defined(CONFIG_LIS2DH_BUS_I2C)
return i2c_burst_write(lis2dh->bus, LIS2DH_BUS_ADDRESS, start_addr,
return i2c_burst_write(lis2dh->bus, LIS2DH_BUS_ADDRESS,
start_addr | LIS2DH_AUTOINCREMENT_ADDR,
buf, num_bytes);
#else
return -ENODEV;