summaryrefslogtreecommitdiff
path: root/driver/baro_bmp280.c
diff options
context:
space:
mode:
authorVijay Hiremath <vijay.p.hiremath@intel.com>2015-08-03 23:37:54 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-09-23 15:10:08 -0700
commitf9272713da615e51ea14f70872fec46fbd88e938 (patch)
tree7b12c57a3435a615718c9d3325dfc0671fc297b6 /driver/baro_bmp280.c
parent806aae81f6bed5ab1a26e860eaa2b5b1349a1444 (diff)
downloadchrome-ec-f9272713da615e51ea14f70872fec46fbd88e938.tar.gz
i2c: Add i2ctest console command
Added i2ctest console command to test the reliability of the I2C. By reading/writing to the known registers this tests provides the number of successful read and writes. BUG=chrome-os-partner:57487 TEST=Enabled the i2ctest config on Reef and tested the i2c read/writes. BRANCH=none Change-Id: I9e27ff96f2b85422933bc590d112a083990e2dfb Signed-off-by: Vijay Hiremath <vijay.p.hiremath@intel.com> Reviewed-on: https://chromium-review.googlesource.com/290427 Commit-Ready: Vijay P Hiremath <vijay.p.hiremath@intel.com> Tested-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'driver/baro_bmp280.c')
-rw-r--r--driver/baro_bmp280.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/driver/baro_bmp280.c b/driver/baro_bmp280.c
index 6e394dbf72..3a3f3e3b6d 100644
--- a/driver/baro_bmp280.c
+++ b/driver/baro_bmp280.c
@@ -68,7 +68,7 @@
static const uint16_t standby_durn[] = {1, 63, 125, 250, 500, 1000, 2000, 4000};
-static inline int raw_read8(const int port, const int addr, const uint8_t reg,
+static inline int raw_read8(const int port, const int addr, const int reg,
int *data_ptr)
{
return i2c_read8(port, addr, reg, data_ptr);
@@ -92,7 +92,7 @@ static inline int raw_read_n(const int port, const int addr, const uint8_t reg,
/*
* Write 8bit register from accelerometer.
*/
-static inline int raw_write8(const int port, const int addr, const uint8_t reg,
+static inline int raw_write8(const int port, const int addr, const int reg,
int data)
{
return i2c_write8(port, addr, reg, data);
@@ -405,3 +405,15 @@ const struct accelgyro_drv bmp280_drv = {
.set_data_rate = bmp280_set_data_rate,
.get_data_rate = bmp280_get_data_rate,
};
+
+#ifdef CONFIG_CMD_I2C_STRESS_TEST_ACCEL
+struct i2c_stress_test_dev bmp280_i2c_stress_test_dev = {
+ .reg_info = {
+ .read_reg = BMP280_CHIP_ID_REG,
+ .read_val = BMP280_CHIP_ID,
+ .write_reg = BMP280_CONFIG_REG,
+ },
+ .i2c_read = &raw_read8,
+ .i2c_write = &raw_write8,
+};
+#endif /* CONFIG_CMD_I2C_STRESS_TEST_ACCEL */