From 9078b7ec09b135f091cb951ed234bf013c9c838e Mon Sep 17 00:00:00 2001 From: Michal Hanus Date: Sat, 19 Apr 2025 22:50:44 +0200 Subject: bme680 added --- nrfdemo/src/bme680/bme680_i2c.c | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 nrfdemo/src/bme680/bme680_i2c.c (limited to 'nrfdemo/src/bme680/bme680_i2c.c') diff --git a/nrfdemo/src/bme680/bme680_i2c.c b/nrfdemo/src/bme680/bme680_i2c.c new file mode 100644 index 0000000..faa8cea --- /dev/null +++ b/nrfdemo/src/bme680/bme680_i2c.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2016, 2017 Intel Corporation + * Copyright (c) 2017 IpTronix S.r.l. + * Copyright (c) 2021 Nordic Semiconductor ASA + * Copyright (c) 2022, Leonard Pollak + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Bus-specific functionality for BME680s accessed via I2C. + */ + +#include "bme680.h" + +#if BME680_BUS_I2C +static int bme680_bus_check_i2c(const union bme680_bus *bus) +{ + return device_is_ready(bus->i2c.bus) ? 0 : -ENODEV; +} + +static int bme680_reg_read_i2c(const struct device *dev, + uint8_t start, uint8_t *buf, int size) +{ + const struct bme680_config *config = dev->config; + + return i2c_burst_read_dt(&config->bus.i2c, start, buf, size); +} + +static int bme680_reg_write_i2c(const struct device *dev, + uint8_t reg, uint8_t val) +{ + const struct bme680_config *config = dev->config; + + return i2c_reg_write_byte_dt(&config->bus.i2c, reg, val); +} + +const struct bme680_bus_io bme680_bus_io_i2c = { + .check = bme680_bus_check_i2c, + .read = bme680_reg_read_i2c, + .write = bme680_reg_write_i2c, +}; +#endif /* BME680_BUS_I2C */ -- cgit v1.2.3