Lines Matching +full:adxl362 +full:- +full:stream

1 /* adxl362.c - ADXL362 Three-Axis Digital Accelerometers */
6 * SPDX-License-Identifier: Apache-2.0
22 #include "adxl362.h"
24 LOG_MODULE_REGISTER(ADXL362, CONFIG_SENSOR_LOG_LEVEL);
29 const struct adxl362_config *cfg = dev->config; in adxl362_reg_access()
53 return spi_transceive_dt(&cfg->bus, &tx, &rx); in adxl362_reg_access()
58 return spi_write_dt(&cfg->bus, &tx); in adxl362_reg_access()
162 return -EINVAL; in adxl362_freq_to_odr_val()
173 return -EINVAL; in adxl362_freq_to_odr_val()
197 return -EINVAL; in adxl362_range_to_reg_val()
203 struct adxl362_data *adxl362_data = dev->data; in adxl362_set_range()
220 adxl362_data->selected_range = range; in adxl362_set_range()
229 struct adxl362_data *adxl362_data = dev->data; in adxl362_set_output_rate()
238 adxl362_data->accel_odr = out_rate; in adxl362_set_output_rate()
257 return -ENOTSUP; in axl362_acc_config()
269 out_rate = adxl362_freq_to_odr_val(val->val1, in axl362_acc_config()
270 val->val2 / 1000); in axl362_acc_config()
273 return -ENOTSUP; in axl362_acc_config()
282 return -ENOTSUP; in axl362_acc_config()
294 uint16_t threshold = val->val1; in adxl362_attr_set_thresh()
300 return -EINVAL; in adxl362_attr_set_thresh()
304 return -EINVAL; in adxl362_attr_set_thresh()
330 uint16_t timeout = val->val1; in adxl362_attr_set()
347 return -ENOTSUP; in adxl362_attr_set()
364 struct adxl362_data *data = (struct adxl362_data *)dev->data; in adxl362_fifo_setup()
366 data->fifo_mode = mode; in adxl362_fifo_setup()
367 data->water_mark_lvl = water_mark_lvl; in adxl362_fifo_setup()
368 data->en_temp_read = en_temp_read; in adxl362_fifo_setup()
403 * ADXL362_FIFO_DISABLE - FIFO is disabled. in adxl362_setup_activity_detection()
404 * ADXL362_FIFO_OLDEST_SAVED - Oldest saved mode. in adxl362_setup_activity_detection()
405 * ADXL362_FIFO_STREAM - Stream mode. in adxl362_setup_activity_detection()
406 * ADXL362_FIFO_TRIGGERED - Triggered mode. in adxl362_setup_activity_detection()
411 * 1 - temperature data is stored in the FIFO in adxl362_setup_activity_detection()
412 * together with x-, y- and x-axis data. in adxl362_setup_activity_detection()
413 * 0 - temperature data is skipped. in adxl362_setup_activity_detection()
504 return -EINVAL; in adxl362_set_interrupt_mode()
532 struct adxl362_data *data = dev->data; in adxl362_sample_fetch()
544 data->acc_x = sys_le16_to_cpu(buf[0]); in adxl362_sample_fetch()
545 data->acc_y = sys_le16_to_cpu(buf[1]); in adxl362_sample_fetch()
546 data->acc_z = sys_le16_to_cpu(buf[2]); in adxl362_sample_fetch()
547 data->temp = sys_le16_to_cpu(buf[3]); in adxl362_sample_fetch()
556 struct adxl362_data *data = dev->data; in adxl362_rtio_fetch()
567 sample_data->is_fifo = 0; in adxl362_rtio_fetch()
570 sample_data->acc_x = sys_le16_to_cpu(buf[0]); in adxl362_rtio_fetch()
571 sample_data->acc_y = sys_le16_to_cpu(buf[1]); in adxl362_rtio_fetch()
572 sample_data->acc_z = sys_le16_to_cpu(buf[2]); in adxl362_rtio_fetch()
573 sample_data->temp = sys_le16_to_cpu(buf[3]); in adxl362_rtio_fetch()
574 sample_data->selected_range = data->selected_range; in adxl362_rtio_fetch()
591 return -EINVAL; in adxl362_range_to_scale()
606 __ASSERT_NO_MSG(scale != -EINVAL); in adxl362_accel_convert()
608 val->val1 = micro_ms2 / 1000000; in adxl362_accel_convert()
609 val->val2 = micro_ms2 % 1000000; in adxl362_accel_convert()
619 int milli_c = (temp - ADXL362_TEMP_BIAS_LSB) * ADXL362_TEMP_MC_PER_LSB + in adxl362_temp_convert()
622 val->val1 = milli_c / 1000; in adxl362_temp_convert()
623 val->val2 = (milli_c % 1000) * 1000; in adxl362_temp_convert()
630 struct adxl362_data *data = dev->data; in adxl362_channel_get()
634 adxl362_accel_convert(val, data->acc_x, data->selected_range); in adxl362_channel_get()
637 adxl362_accel_convert(val, data->acc_y, data->selected_range); in adxl362_channel_get()
640 adxl362_accel_convert(val, data->acc_z, data->selected_range); in adxl362_channel_get()
644 adxl362_accel_convert(&val[i], data->acc_xyz[i], data->selected_range); in adxl362_channel_get()
648 adxl362_temp_convert(val, data->temp); in adxl362_channel_get()
651 return -ENOTSUP; in adxl362_channel_get()
672 const struct adxl362_config *config = dev->config; in adxl362_chip_init()
677 * 0 - absolute mode. in adxl362_chip_init()
678 * 1 - referenced mode. in adxl362_chip_init()
680 * 11-bit unsigned value that the adxl362 samples are in adxl362_chip_init()
683 * 8-bit value written to the activity timer register. in adxl362_chip_init()
686 * where ODR - is the output data rate. in adxl362_chip_init()
699 * 0 - absolute mode. in adxl362_chip_init()
700 * 1 - referenced mode. in adxl362_chip_init()
702 * 11-bit unsigned value that the adxl362 samples are in adxl362_chip_init()
705 * 16-bit value written to the activity timer register. in adxl362_chip_init()
708 * where ODR - is the output data rate. in adxl362_chip_init()
727 * ADXL362_RANGE_2G - +-2 g in adxl362_chip_init()
728 * ADXL362_RANGE_4G - +-4 g in adxl362_chip_init()
729 * ADXL362_RANGE_8G - +-8 g in adxl362_chip_init()
738 * ADXL362_ODR_12_5_HZ - 12.5Hz in adxl362_chip_init()
739 * ADXL362_ODR_25_HZ - 25Hz in adxl362_chip_init()
740 * ADXL362_ODR_50_HZ - 50Hz in adxl362_chip_init()
741 * ADXL362_ODR_100_HZ - 100Hz in adxl362_chip_init()
742 * ADXL362_ODR_200_HZ - 200Hz in adxl362_chip_init()
743 * ADXL362_ODR_400_HZ - 400Hz in adxl362_chip_init()
751 LOG_DBG("setting pwrctl: 0x%02x", config->power_ctl); in adxl362_chip_init()
752 ret = adxl362_set_reg(dev, config->power_ctl, ADXL362_REG_POWER_CTL, 1); in adxl362_chip_init()
764 * @return 0 - the initialization was successful and the device is present;
765 * -1 - an error occurred.
770 const struct adxl362_config *config = dev->config; in adxl362_init()
774 if (!spi_is_ready_dt(&config->bus)) { in adxl362_init()
775 LOG_DBG("spi device not ready: %s", config->bus.bus->name); in adxl362_init()
776 return -EINVAL; in adxl362_init()
783 return -ENODEV; in adxl362_init()
791 return -ENODEV; in adxl362_init()
795 return -ENODEV; in adxl362_init()
799 if (config->interrupt.port) { in adxl362_init()
802 return -EIO; in adxl362_init()
806 config->int1_config, in adxl362_init()
807 config->int2_config) < 0) { in adxl362_init()
809 return -EIO; in adxl362_init()