Lines Matching +full:chip +full:- +full:id
4 * SPDX-License-Identifier: Apache-2.0
22 struct bma280_data *drv_data = dev->data; in bma280_sample_fetch()
23 const struct bma280_config *config = dev->config; in bma280_sample_fetch()
33 if (i2c_burst_read_dt(&config->i2c, in bma280_sample_fetch()
36 return -EIO; in bma280_sample_fetch()
40 drv_data->x_sample = (((int8_t)buf[1]) << BMA280_ACCEL_LSB_BITS) | lsb; in bma280_sample_fetch()
43 drv_data->y_sample = (((int8_t)buf[3]) << BMA280_ACCEL_LSB_BITS) | lsb; in bma280_sample_fetch()
46 drv_data->z_sample = (((int8_t)buf[5]) << BMA280_ACCEL_LSB_BITS) | lsb; in bma280_sample_fetch()
48 if (i2c_reg_read_byte_dt(&config->i2c, in bma280_sample_fetch()
50 (uint8_t *)&drv_data->temp_sample) < 0) { in bma280_sample_fetch()
52 return -EIO; in bma280_sample_fetch()
67 val->val1 = raw_val / 1000000; in bma280_channel_accel_convert()
68 val->val2 = raw_val % 1000000; in bma280_channel_accel_convert()
70 /* normalize val to make sure val->val2 is positive */ in bma280_channel_accel_convert()
71 if (val->val2 < 0) { in bma280_channel_accel_convert()
72 val->val1 -= 1; in bma280_channel_accel_convert()
73 val->val2 += 1000000; in bma280_channel_accel_convert()
81 struct bma280_data *drv_data = dev->data; in bma280_channel_get()
88 bma280_channel_accel_convert(val, drv_data->x_sample); in bma280_channel_get()
90 bma280_channel_accel_convert(val, drv_data->y_sample); in bma280_channel_get()
92 bma280_channel_accel_convert(val, drv_data->z_sample); in bma280_channel_get()
94 bma280_channel_accel_convert(val, drv_data->x_sample); in bma280_channel_get()
95 bma280_channel_accel_convert(val + 1, drv_data->y_sample); in bma280_channel_get()
96 bma280_channel_accel_convert(val + 2, drv_data->z_sample); in bma280_channel_get()
99 val->val1 = (drv_data->temp_sample >> 1) + 23; in bma280_channel_get()
100 val->val2 = 500000 * (drv_data->temp_sample & 1); in bma280_channel_get()
103 return -ENOTSUP; in bma280_channel_get()
120 const struct bma280_config *config = dev->config; in bma280_init()
121 uint8_t id = 0U; in bma280_init() local
123 if (!device_is_ready(config->i2c.bus)) { in bma280_init()
125 return -ENODEV; in bma280_init()
128 /* read device ID */ in bma280_init()
129 if (i2c_reg_read_byte_dt(&config->i2c, in bma280_init()
130 BMA280_REG_CHIP_ID, &id) < 0) { in bma280_init()
131 LOG_DBG("Could not read chip id"); in bma280_init()
132 return -EIO; in bma280_init()
135 if (id != BMA280_CHIP_ID) { in bma280_init()
136 LOG_DBG("Unexpected chip id (%x)", id); in bma280_init()
137 return -EIO; in bma280_init()
140 if (i2c_reg_write_byte_dt(&config->i2c, in bma280_init()
143 return -EIO; in bma280_init()
146 /* set g-range */ in bma280_init()
147 if (i2c_reg_write_byte_dt(&config->i2c, in bma280_init()
149 LOG_DBG("Could not set data g-range"); in bma280_init()
150 return -EIO; in bma280_init()
154 if (config->int1_gpio.port) { in bma280_init()
157 return -EIO; in bma280_init()