Lines Matching +full:sampling +full:- +full:frequencies
5 * SPDX-License-Identifier: Apache-2.0
8 * http://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BMG160-DS000-09.pdf
25 const struct bmg160_device_config *dev_cfg = dev->config; in bmg160_bus_config()
30 return i2c_configure(dev_cfg->i2c.bus, i2c_cfg); in bmg160_bus_config()
36 const struct bmg160_device_config *dev_cfg = dev->config; in bmg160_read()
37 struct bmg160_device_data *bmg160 = dev->data; in bmg160_read()
42 k_sem_take(&bmg160->sem, K_FOREVER); in bmg160_read()
44 if (i2c_burst_read_dt(&dev_cfg->i2c, in bmg160_read()
46 ret = -EIO; in bmg160_read()
49 k_sem_give(&bmg160->sem); in bmg160_read()
64 const struct bmg160_device_config *dev_cfg = dev->config; in bmg160_write()
65 struct bmg160_device_data *bmg160 = dev->data; in bmg160_write()
70 k_sem_take(&bmg160->sem, K_FOREVER); in bmg160_write()
72 if (i2c_burst_write_dt(&dev_cfg->i2c, in bmg160_write()
74 ret = -EIO; in bmg160_write()
77 k_sem_give(&bmg160->sem); in bmg160_write()
92 const struct bmg160_device_config *dev_cfg = dev->config; in bmg160_update_byte()
93 struct bmg160_device_data *bmg160 = dev->data; in bmg160_update_byte()
98 k_sem_take(&bmg160->sem, K_FOREVER); in bmg160_update_byte()
100 if (i2c_reg_update_byte_dt(&dev_cfg->i2c, in bmg160_update_byte()
102 ret = -EIO; in bmg160_update_byte()
105 k_sem_give(&bmg160->sem); in bmg160_update_byte()
114 /* Allowed sampling frequencies, in Hz */
129 return -1; in bmg160_is_val_valid()
136 struct bmg160_device_data *bmg160 = dev->data; in bmg160_attr_set()
138 const struct bmg160_device_config *config = dev->config; in bmg160_attr_set()
144 return -ENOTSUP; in bmg160_attr_set()
155 return -ENOTSUP; in bmg160_attr_set()
159 return -EIO; in bmg160_attr_set()
162 bmg160->scale = BMG160_RANGE_TO_SCALE(range_dps); in bmg160_attr_set()
167 idx = bmg160_is_val_valid(val->val1, in bmg160_attr_set()
171 return -ENOTSUP; in bmg160_attr_set()
175 * The sampling frequencies values start at 1, i.e. a in bmg160_attr_set()
176 * sampling frequency of 2000Hz translates to BW value in bmg160_attr_set()
180 return -EIO; in bmg160_attr_set()
188 if (!config->int_gpio.port) { in bmg160_attr_set()
189 return -ENOTSUP; in bmg160_attr_set()
195 return -ENOTSUP; in bmg160_attr_set()
202 struct bmg160_device_data *bmg160 = dev->data; in bmg160_sample_fetch()
215 return -EIO; in bmg160_sample_fetch()
218 bmg160->raw_gyro_xyz[0] = sys_le16_to_cpu(buf.x_axis); in bmg160_sample_fetch()
219 bmg160->raw_gyro_xyz[1] = sys_le16_to_cpu(buf.y_axis); in bmg160_sample_fetch()
220 bmg160->raw_gyro_xyz[2] = sys_le16_to_cpu(buf.z_axis); in bmg160_sample_fetch()
221 bmg160->raw_temp = buf.temp; in bmg160_sample_fetch()
231 val->val1 = 23 + (raw / 2); in bmg160_to_fixed_point()
232 val->val2 = (raw % 2) * 500000; in bmg160_to_fixed_point()
234 int32_t converted_val = raw * bmg160->scale; in bmg160_to_fixed_point()
236 val->val1 = converted_val / 1000000; in bmg160_to_fixed_point()
237 val->val2 = converted_val % 1000000; in bmg160_to_fixed_point()
245 struct bmg160_device_data *bmg160 = dev->data; in bmg160_channel_get()
253 raw_val = bmg160->raw_gyro_xyz[chan - SENSOR_CHAN_GYRO_X]; in bmg160_channel_get()
260 raw_val = bmg160->raw_gyro_xyz[i]; in bmg160_channel_get()
267 bmg160_to_fixed_point(bmg160, chan, bmg160->raw_temp, val); in bmg160_channel_get()
271 return -ENOTSUP; in bmg160_channel_get()
286 const struct bmg160_device_config *cfg = dev->config; in bmg160_init()
287 struct bmg160_device_data *bmg160 = dev->data; in bmg160_init()
291 if (!device_is_ready(cfg->i2c.bus)) { in bmg160_init()
293 return -ENODEV; in bmg160_init()
296 k_sem_init(&bmg160->sem, 1, K_SEM_MAX_LIMIT); in bmg160_init()
300 return -EIO; in bmg160_init()
305 return -ENODEV; in bmg160_init()
316 return -EIO; in bmg160_init()
321 bmg160->scale = BMG160_RANGE_TO_SCALE(range_dps); in bmg160_init()
324 LOG_DBG("Failed to set sampling frequency."); in bmg160_init()
325 return -EIO; in bmg160_init()
331 return -EIO; in bmg160_init()
335 if (cfg->int_gpio.port) { in bmg160_init()