Lines Matching +full:bus +full:- +full:range

5  * SPDX-License-Identifier: Apache-2.0
29 const struct bmi270_config *cfg = dev->config; in bmi270_bus_check()
31 return cfg->bus_io->check(&cfg->bus); in bmi270_bus_check()
36 const struct bmi270_config *cfg = dev->config; in bmi270_bus_init()
38 return cfg->bus_io->init(&cfg->bus); in bmi270_bus_init()
43 const struct bmi270_config *cfg = dev->config; in bmi270_reg_read()
45 return cfg->bus_io->read(&cfg->bus, reg, data, length); in bmi270_reg_read()
51 const struct bmi270_config *cfg = dev->config; in bmi270_reg_write()
53 return cfg->bus_io->write(&cfg->bus, reg, data, length); in bmi270_reg_write()
72 uint8_t range) in channel_accel_convert() argument
74 /* 16 bit accelerometer. 2^15 bits represent the range in G */ in channel_accel_convert()
76 raw_val = (raw_val * SENSOR_G * (int64_t) range) / INT16_MAX; in channel_accel_convert()
78 val->val1 = raw_val / 1000000LL; in channel_accel_convert()
79 val->val2 = raw_val % 1000000LL; in channel_accel_convert()
83 uint16_t range) in channel_gyro_convert() argument
85 /* 16 bit gyroscope. 2^15 bits represent the range in degrees/s */ in channel_gyro_convert()
88 val->val1 = ((raw_val * (int64_t) range * SENSOR_PI) in channel_gyro_convert()
90 val->val2 = ((raw_val * (int64_t) range * SENSOR_PI) in channel_gyro_convert()
130 struct bmi270_data *data = dev->data; in set_accel_odr_osr()
172 data->acc_odr = odr_bits; in set_accel_odr_osr()
176 if (data->acc_odr >= BMI270_ACC_ODR_100_HZ) { in set_accel_odr_osr()
178 /* osr->val2 should be unused */ in set_accel_odr_osr()
179 switch (osr->val1) { in set_accel_odr_osr()
195 /* osr->val2 should be unused */ in set_accel_odr_osr()
196 switch (osr->val1) { in set_accel_odr_osr()
222 return -ENOTSUP; in set_accel_odr_osr()
248 static int set_accel_range(const struct device *dev, const struct sensor_value *range) in set_accel_range() argument
250 struct bmi270_data *data = dev->data; in set_accel_range()
259 /* range->val2 is unused */ in set_accel_range()
260 switch (range->val1) { in set_accel_range()
263 data->acc_range = 2; in set_accel_range()
267 data->acc_range = 4; in set_accel_range()
271 data->acc_range = 8; in set_accel_range()
275 data->acc_range = 16; in set_accel_range()
278 return -ENOTSUP; in set_accel_range()
318 struct bmi270_data *data = dev->data; in set_gyro_odr_osr()
368 data->gyr_odr = odr_bits; in set_gyro_odr_osr()
372 /* osr->val2 should be unused */ in set_gyro_odr_osr()
373 switch (osr->val1) { in set_gyro_odr_osr()
407 static int set_gyro_range(const struct device *dev, const struct sensor_value *range) in set_gyro_range() argument
409 struct bmi270_data *data = dev->data; in set_gyro_range()
418 /* range->val2 is unused */ in set_gyro_range()
419 switch (range->val1) { in set_gyro_range()
422 data->gyr_range = 125; in set_gyro_range()
426 data->gyr_range = 250; in set_gyro_range()
430 data->gyr_range = 500; in set_gyro_range()
434 data->gyr_range = 1000; in set_gyro_range()
438 data->gyr_range = 2000; in set_gyro_range()
441 return -ENOTSUP; in set_gyro_range()
453 const struct bmi270_config *cfg = dev->config; in write_config_file()
458 LOG_DBG("writing config file %s", cfg->feature->name); in write_config_file()
461 for (index = 0; index < cfg->feature->config_file_len; in write_config_file()
476 &cfg->feature->config_file[index], in write_config_file()
487 struct bmi270_data *data = dev->data; in bmi270_sample_fetch()
492 return -ENOTSUP; in bmi270_sample_fetch()
497 data->ax = (int16_t)sys_get_le16(&buf[0]); in bmi270_sample_fetch()
498 data->ay = (int16_t)sys_get_le16(&buf[2]); in bmi270_sample_fetch()
499 data->az = (int16_t)sys_get_le16(&buf[4]); in bmi270_sample_fetch()
500 data->gx = (int16_t)sys_get_le16(&buf[6]); in bmi270_sample_fetch()
501 data->gy = (int16_t)sys_get_le16(&buf[8]); in bmi270_sample_fetch()
502 data->gz = (int16_t)sys_get_le16(&buf[10]); in bmi270_sample_fetch()
504 data->ax = 0; in bmi270_sample_fetch()
505 data->ay = 0; in bmi270_sample_fetch()
506 data->az = 0; in bmi270_sample_fetch()
507 data->gx = 0; in bmi270_sample_fetch()
508 data->gy = 0; in bmi270_sample_fetch()
509 data->gz = 0; in bmi270_sample_fetch()
518 struct bmi270_data *data = dev->data; in bmi270_channel_get()
521 channel_accel_convert(val, data->ax, data->acc_range); in bmi270_channel_get()
523 channel_accel_convert(val, data->ay, data->acc_range); in bmi270_channel_get()
525 channel_accel_convert(val, data->az, data->acc_range); in bmi270_channel_get()
527 channel_accel_convert(&val[0], data->ax, in bmi270_channel_get()
528 data->acc_range); in bmi270_channel_get()
529 channel_accel_convert(&val[1], data->ay, in bmi270_channel_get()
530 data->acc_range); in bmi270_channel_get()
531 channel_accel_convert(&val[2], data->az, in bmi270_channel_get()
532 data->acc_range); in bmi270_channel_get()
534 channel_gyro_convert(val, data->gx, data->gyr_range); in bmi270_channel_get()
536 channel_gyro_convert(val, data->gy, data->gyr_range); in bmi270_channel_get()
538 channel_gyro_convert(val, data->gz, data->gyr_range); in bmi270_channel_get()
540 channel_gyro_convert(&val[0], data->gx, in bmi270_channel_get()
541 data->gyr_range); in bmi270_channel_get()
542 channel_gyro_convert(&val[1], data->gy, in bmi270_channel_get()
543 data->gyr_range); in bmi270_channel_get()
544 channel_gyro_convert(&val[2], data->gz, in bmi270_channel_get()
545 data->gyr_range); in bmi270_channel_get()
547 return -ENOTSUP; in bmi270_channel_get()
562 struct bmi270_data *data = dev->data; in bmi270_write_anymo_threshold()
575 return -EINVAL; in bmi270_write_anymo_threshold()
581 data->anymo_2 = anymo_2; in bmi270_write_anymo_threshold()
587 struct bmi270_data *data = dev->data; in bmi270_write_anymo_duration()
591 data->anymo_1 = val; in bmi270_write_anymo_duration()
599 int ret = -ENOTSUP; in bmi270_attr_set()
616 return bmi270_write_anymo_duration(dev, val->val1); in bmi270_attr_set()
621 ret = -ENOTSUP; in bmi270_attr_set()
637 ret = -ENOTSUP; in bmi270_attr_set()
647 struct bmi270_data *data = dev->data; in bmi270_init()
657 LOG_ERR("Could not initialize bus"); in bmi270_init()
662 data->dev = dev; in bmi270_init()
663 k_mutex_init(&data->trigger_mutex); in bmi270_init()
666 data->acc_odr = BMI270_ACC_ODR_100_HZ; in bmi270_init()
667 data->acc_range = 8; in bmi270_init()
668 data->gyr_odr = BMI270_GYR_ODR_200_HZ; in bmi270_init()
669 data->gyr_range = 2000; in bmi270_init()
675 LOG_ERR("Could not initiate bus communication"); in bmi270_init()
687 return -EIO; in bmi270_init()
751 return -EIO; in bmi270_init()
808 /* Initializes a struct bmi270_config for an instance on a SPI bus. */
810 .bus.spi = SPI_DT_SPEC_INST_GET( \
814 /* Initializes a struct bmi270_config for an instance on an I2C bus. */
816 .bus.i2c = I2C_DT_SPEC_INST_GET(inst), \