diff options
| author | Michal Hanus <mikehanus@protonmail.com> | 2025-04-19 22:50:44 +0200 |
|---|---|---|
| committer | Michal Hanus <mikehanus@protonmail.com> | 2025-04-19 22:50:44 +0200 |
| commit | 9078b7ec09b135f091cb951ed234bf013c9c838e (patch) | |
| tree | ba953e144c2dd42d327a83720cdfc9fb5bb9fe34 /nrfdemo/src/bme680/bme680_i2c.c | |
| parent | 2e13c372f1419f08dab7797b244681f889dd9bcf (diff) | |
bme680 added
Diffstat (limited to 'nrfdemo/src/bme680/bme680_i2c.c')
| -rw-r--r-- | nrfdemo/src/bme680/bme680_i2c.c | 43 |
1 files changed, 43 insertions, 0 deletions
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 */ |
