Skip to content

Commit

Permalink
drivers: sensor: adxl367: Added RTIO stream
Browse files Browse the repository at this point in the history
Updated ADXL367 driver with RTIO stream functionality.
RTIO stream is using both FIFO threshold and FIFO full triggers.
Together with RTIO stream, RTIO async read is also implemented.
Supported FIFO_CHANNEL configurations:
- XYZ
- X
- Y
- Z
- XYZT
- XT
- YT
- ZT
Configurations with external ADC are currently not supported.

Signed-off-by: Vladislav Pejic <[email protected]>
  • Loading branch information
vladislav-pejic committed Nov 1, 2024
1 parent c22233a commit 51adfed
Show file tree
Hide file tree
Showing 8 changed files with 1,601 additions and 23 deletions.
2 changes: 2 additions & 0 deletions drivers/sensor/adi/adxl367/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ zephyr_library_sources(adxl367.c)
zephyr_library_sources(adxl367_spi.c)
zephyr_library_sources(adxl367_i2c.c)
zephyr_library_sources_ifdef(CONFIG_ADXL367_TRIGGER adxl367_trigger.c)
zephyr_library_sources_ifdef(CONFIG_SENSOR_ASYNC_API adxl367_rtio.c adxl367_decoder.c)
zephyr_library_sources_ifdef(CONFIG_ADXL367_STREAM adxl367_stream.c adxl367_decoder.c)
9 changes: 9 additions & 0 deletions drivers/sensor/adi/adxl367/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,15 @@ config ADXL367_TRIGGER_OWN_THREAD

endchoice

config ADXL367_STREAM
bool "Use FIFO to stream data"
select ADXL367_TRIGGER
default y
depends on SPI_RTIO
depends on SENSOR_ASYNC_API
help
Use this configuration option to enable streaming sensor data via RTIO.

config ADXL367_TRIGGER
bool

Expand Down
121 changes: 101 additions & 20 deletions drivers/sensor/adi/adxl367/adxl367.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ static int adxl367_setup_inactivity_detection(const struct device *dev,
*
* @return 0 in case of success, negative error code otherwise.
*/
#ifdef CONFIG_ADXL367_STREAM
int adxl367_set_op_mode(const struct device *dev,
enum adxl367_op_mode op_mode)
#else

Check notice on line 114 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:114 -int adxl367_set_op_mode(const struct device *dev, - enum adxl367_op_mode op_mode) +int adxl367_set_op_mode(const struct device *dev, enum adxl367_op_mode op_mode)
static int adxl367_set_op_mode(const struct device *dev,
enum adxl367_op_mode op_mode)
#endif /* CONFIG_ADXL367_STREAM */
{
struct adxl367_data *data = dev->data;
int ret;
Expand All @@ -126,6 +131,11 @@ static int adxl367_set_op_mode(const struct device *dev,
k_sleep(K_MSEC(100));
}

#ifdef CONFIG_ADXL367_STREAM
data->pwr_reg &= ~ADXL367_POWER_CTL_MEASURE_MSK;
data->pwr_reg |= FIELD_PREP(ADXL367_POWER_CTL_MEASURE_MSK, op_mode);
#endif /* CONFIG_ADXL372_STREAM */

return 0;
}

Expand All @@ -141,11 +151,21 @@ static int adxl367_set_op_mode(const struct device *dev,
*/
static int adxl367_set_autosleep(const struct device *dev, bool enable)
{
int ret;
struct adxl367_data *data = dev->data;

return data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL,
ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL,
ADXL367_POWER_CTL_AUTOSLEEP_MSK,
FIELD_PREP(ADXL367_POWER_CTL_AUTOSLEEP_MSK, enable));

Check notice on line 160 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:160 - ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL, - ADXL367_POWER_CTL_AUTOSLEEP_MSK, - FIELD_PREP(ADXL367_POWER_CTL_AUTOSLEEP_MSK, enable)); + ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL, ADXL367_POWER_CTL_AUTOSLEEP_MSK, + FIELD_PREP(ADXL367_POWER_CTL_AUTOSLEEP_MSK, enable));
#ifdef CONFIG_ADXL367_STREAM
if (ret == 0) {
data->pwr_reg &= ~ADXL367_POWER_CTL_AUTOSLEEP_MSK;
data->pwr_reg |= FIELD_PREP(ADXL367_POWER_CTL_AUTOSLEEP_MSK, enable);
}
#endif /* CONFIG_ADXL372_STREAM */

return ret;
}

/**
Expand All @@ -159,11 +179,21 @@ static int adxl367_set_autosleep(const struct device *dev, bool enable)
*/
static int adxl367_set_low_noise(const struct device *dev, bool enable)
{
int ret;
struct adxl367_data *data = dev->data;

return data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL,
ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL,
ADXL367_POWER_CTL_NOISE_MSK,
FIELD_PREP(ADXL367_POWER_CTL_NOISE_MSK, enable));

Check notice on line 188 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:188 - ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL, - ADXL367_POWER_CTL_NOISE_MSK, - FIELD_PREP(ADXL367_POWER_CTL_NOISE_MSK, enable)); + ret = data->hw_tf->write_reg_mask(dev, ADXL367_POWER_CTL, ADXL367_POWER_CTL_NOISE_MSK, + FIELD_PREP(ADXL367_POWER_CTL_NOISE_MSK, enable));
#ifdef CONFIG_ADXL367_STREAM
if (ret == 0) {
data->pwr_reg &= ~ADXL367_POWER_CTL_NOISE_MSK;
data->pwr_reg |= FIELD_PREP(ADXL367_POWER_CTL_NOISE_MSK, enable);
}
#endif /* CONFIG_ADXL372_STREAM */

return ret;
}

/**
Expand Down Expand Up @@ -203,11 +233,20 @@ static int adxl367_set_act_proc_mode(const struct device *dev,
int adxl367_set_output_rate(const struct device *dev, enum adxl367_odr odr)
{
struct adxl367_data *data = dev->data;
int ret;

return data->hw_tf->write_reg_mask(dev,
ret = data->hw_tf->write_reg_mask(dev,
ADXL367_FILTER_CTL,
ADXL367_FILTER_CTL_ODR_MSK,
FIELD_PREP(ADXL367_FILTER_CTL_ODR_MSK, odr));

Check notice on line 241 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:241 - ret = data->hw_tf->write_reg_mask(dev, - ADXL367_FILTER_CTL, - ADXL367_FILTER_CTL_ODR_MSK, + ret = data->hw_tf->write_reg_mask(dev, ADXL367_FILTER_CTL, ADXL367_FILTER_CTL_ODR_MSK,

#ifdef CONFIG_ADXL367_STREAM
if (ret == 0) {
data->odr = odr;
}
#endif /* CONFIG_ADXL367_STREAM */

return ret;
}

/**
Expand All @@ -224,11 +263,20 @@ int adxl367_set_output_rate(const struct device *dev, enum adxl367_odr odr)
int adxl367_set_range(const struct device *dev, enum adxl367_range range)
{
struct adxl367_data *data = dev->data;
int ret;

return data->hw_tf->write_reg_mask(dev,
ret = data->hw_tf->write_reg_mask(dev,
ADXL367_FILTER_CTL,
ADXL367_FILTER_CTL_RANGE_MSK,
FIELD_PREP(ADXL367_FILTER_CTL_RANGE_MSK, range));

Check notice on line 271 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:271 - ret = data->hw_tf->write_reg_mask(dev, - ADXL367_FILTER_CTL, - ADXL367_FILTER_CTL_RANGE_MSK, + ret = data->hw_tf->write_reg_mask(dev, ADXL367_FILTER_CTL, ADXL367_FILTER_CTL_RANGE_MSK,

#ifdef CONFIG_ADXL367_STREAM
if (ret == 0) {
data->range = range;
}
#endif /* CONFIG_ADXL367_STREAM */

return ret;
}

/**
Expand Down Expand Up @@ -594,7 +642,21 @@ int adxl367_fifo_setup(const struct device *dev,
return ret;
}

return adxl367_set_fifo_read_mode(dev, read_mode);
ret = adxl367_set_fifo_read_mode(dev, read_mode);
if (ret != 0) {
return ret;
}

#ifdef CONFIG_ADXL367_STREAM
struct adxl367_data *data = (struct adxl367_data *)dev->data;

data->fifo_config.fifo_mode = mode;
data->fifo_config.fifo_format = format;
data->fifo_config.fifo_samples = sets_nb;
data->fifo_config.fifo_read_mode = read_mode;
#endif /* CONFIG_ADXL367_STREAM */

return ret;
}

/**
Expand Down Expand Up @@ -820,20 +882,26 @@ static int adxl367_sample_fetch(const struct device *dev,

return adxl367_get_temp_data(dev, &data->temp_val);
}

static void adxl367_accel_convert(const struct device *dev,
struct sensor_value *val, int16_t value)
#ifdef CONFIG_SENSOR_ASYNC_API
void adxl367_accel_convert(struct sensor_value *val, int16_t value,
enum adxl367_range range)
#else
static void adxl367_accel_convert(struct sensor_value *val, int16_t value,
enum adxl367_range range)
#endif /*CONFIG_SENSOR_ASYNC_API*/
{
struct adxl367_data *data = dev->data;

int64_t micro_ms2 = value * (SENSOR_G * 250 / 10000 *
adxl367_scale_mul[data->range] / 1000);
adxl367_scale_mul[range] / 1000);

Check notice on line 895 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:895 -void adxl367_accel_convert(struct sensor_value *val, int16_t value, - enum adxl367_range range) +void adxl367_accel_convert(struct sensor_value *val, int16_t value, enum adxl367_range range) #else -static void adxl367_accel_convert(struct sensor_value *val, int16_t value, - enum adxl367_range range) +static void adxl367_accel_convert(struct sensor_value *val, int16_t value, enum adxl367_range range) #endif /*CONFIG_SENSOR_ASYNC_API*/ { - int64_t micro_ms2 = value * (SENSOR_G * 250 / 10000 * - adxl367_scale_mul[range] / 1000); + int64_t micro_ms2 = value * (SENSOR_G * 250 / 10000 * adxl367_scale_mul[range] / 1000);
val->val1 = micro_ms2 / 1000000;
val->val2 = micro_ms2 % 1000000;
}

#ifdef CONFIG_SENSOR_ASYNC_API
void adxl367_temp_convert(struct sensor_value *val, int16_t value)
#else
static void adxl367_temp_convert(struct sensor_value *val, int16_t value)
#endif /*CONFIG_SENSOR_ASYNC_API*/
{
int64_t temp_data = (value + ADXL367_TEMP_OFFSET) * ADXL367_TEMP_SCALE;

Expand All @@ -849,18 +917,18 @@ static int adxl367_channel_get(const struct device *dev,

switch (chan) {
case SENSOR_CHAN_ACCEL_X:
adxl367_accel_convert(dev, val, data->sample.x);
adxl367_accel_convert(val, data->sample.x, data->range);
break;
case SENSOR_CHAN_ACCEL_Y:
adxl367_accel_convert(dev, val, data->sample.y);
adxl367_accel_convert(val, data->sample.y, data->range);
break;
case SENSOR_CHAN_ACCEL_Z:
adxl367_accel_convert(dev, val, data->sample.z);
adxl367_accel_convert(val, data->sample.z, data->range);
break;
case SENSOR_CHAN_ACCEL_XYZ:
adxl367_accel_convert(dev, val++, data->sample.x);
adxl367_accel_convert(dev, val++, data->sample.y);
adxl367_accel_convert(dev, val, data->sample.z);
adxl367_accel_convert(val++, data->sample.x, data->range);
adxl367_accel_convert(val++, data->sample.y, data->range);
adxl367_accel_convert(val, data->sample.z, data->range);
break;
case SENSOR_CHAN_DIE_TEMP:
adxl367_temp_convert(val, data->temp_val);
Expand All @@ -878,6 +946,10 @@ static const struct sensor_driver_api adxl367_api_funcs = {
#ifdef CONFIG_ADXL367_TRIGGER

Check notice on line 946 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:946 - .attr_set = adxl367_attr_set, + .attr_set = adxl367_attr_set, .sample_fetch = adxl367_sample_fetch, - .channel_get = adxl367_channel_get, + .channel_get = adxl367_channel_get,
.trigger_set = adxl367_trigger_set,
#endif
#ifdef CONFIG_SENSOR_ASYNC_API
.submit = adxl367_submit,
.get_decoder = adxl367_get_decoder,
#endif /* CONFIG_SENSOR_ASYNC_API */
};

static int adxl367_probe(const struct device *dev)
Expand Down Expand Up @@ -1055,19 +1127,28 @@ static int adxl367_init(const struct device *dev)
/*
* Instantiation macros used when a device is on a SPI bus.
*/
#define ADXL367_SPI_CFG SPI_WORD_SET(8) | SPI_TRANSFER_MSB

#define ADXL367_RTIO_DEFINE(inst) \
SPI_DT_IODEV_DEFINE(adxl367_iodev_##inst, DT_DRV_INST(inst), \
ADXL367_SPI_CFG, 0U); \
RTIO_DEFINE(adxl367_rtio_ctx_##inst, 8, 8);

#define ADXL367_CONFIG_SPI(inst) \
{ \
.bus_init = adxl367_spi_init, \
.spi = SPI_DT_SPEC_INST_GET(inst, SPI_WORD_SET(8) | \
SPI_TRANSFER_MSB, 0), \
.spi = SPI_DT_SPEC_INST_GET(inst, ADXL367_SPI_CFG, 0), \
ADXL367_CONFIG(inst) \
COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, int1_gpios), \
(ADXL367_CFG_IRQ(inst)), ()) \
}

#define ADXL367_DEFINE_SPI(inst) \
static struct adxl367_data adxl367_data_##inst; \
IF_ENABLED(CONFIG_ADXL367_STREAM, (ADXL367_RTIO_DEFINE(inst))); \
static struct adxl367_data adxl367_data_##inst = { \
IF_ENABLED(CONFIG_ADXL367_STREAM, (.rtio_ctx = &adxl367_rtio_ctx_##inst, \
.iodev = &adxl367_iodev_##inst,)) \
}; \
static const struct adxl367_dev_config adxl367_config_##inst = \
ADXL367_CONFIG_SPI(inst); \
ADXL367_DEVICE_INIT(inst)

Check notice on line 1154 in drivers/sensor/adi/adxl367/adxl367.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.c:1154 -#define ADXL367_RTIO_DEFINE(inst) \ - SPI_DT_IODEV_DEFINE(adxl367_iodev_##inst, DT_DRV_INST(inst), \ - ADXL367_SPI_CFG, 0U); \ +#define ADXL367_RTIO_DEFINE(inst) \ + SPI_DT_IODEV_DEFINE(adxl367_iodev_##inst, DT_DRV_INST(inst), ADXL367_SPI_CFG, 0U); \ RTIO_DEFINE(adxl367_rtio_ctx_##inst, 8, 8); -#define ADXL367_CONFIG_SPI(inst) \ - { \ - .bus_init = adxl367_spi_init, \ - .spi = SPI_DT_SPEC_INST_GET(inst, ADXL367_SPI_CFG, 0), \ - ADXL367_CONFIG(inst) \ - COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, int1_gpios), \ - (ADXL367_CFG_IRQ(inst)), ()) \ - } - -#define ADXL367_DEFINE_SPI(inst) \ - IF_ENABLED(CONFIG_ADXL367_STREAM, (ADXL367_RTIO_DEFINE(inst))); \ - static struct adxl367_data adxl367_data_##inst = { \ - IF_ENABLED(CONFIG_ADXL367_STREAM, (.rtio_ctx = &adxl367_rtio_ctx_##inst, \ - .iodev = &adxl367_iodev_##inst,)) \ - }; \ - static const struct adxl367_dev_config adxl367_config_##inst = \ - ADXL367_CONFIG_SPI(inst); \ +#define ADXL367_CONFIG_SPI(inst) \ + {.bus_init = adxl367_spi_init, \ + .spi = SPI_DT_SPEC_INST_GET(inst, ADXL367_SPI_CFG, 0), \ + ADXL367_CONFIG(inst) \ + COND_CODE_1(DT_INST_NODE_HAS_PROP(inst, int1_gpios), \ + (ADXL367_CFG_IRQ(inst)), ()) } + +#define ADXL367_DEFINE_SPI(inst) \ + IF_ENABLED(CONFIG_ADXL367_STREAM, (ADXL367_RTIO_DEFINE(inst))); \ + static struct adxl367_data adxl367_data_##inst = { \ + IF_ENABLED(CONFIG_ADXL367_STREAM, (.rtio_ctx = &adxl367_rtio_ctx_##inst, \ + .iodev = &adxl367_iodev_##inst,)) }; \ + static const struct adxl367_dev_config adxl367_config_##inst = ADXL367_CONFIG_SPI(inst); \
Expand Down
87 changes: 84 additions & 3 deletions drivers/sensor/adi/adxl367/adxl367.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>

#define DT_DRV_COMPAT adi_adxl367

#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
#include <zephyr/drivers/spi.h>
#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */
Expand Down Expand Up @@ -102,6 +104,7 @@
#define ADXL367_TO_REG(x) ((x) >> 1)
#define ADXL367_SPI_WRITE_REG 0x0Au
#define ADXL367_SPI_READ_REG 0x0Bu
#define ADXL367_SPI_READ_FIFO 0x0Du

Check notice on line 108 in drivers/sensor/adi/adxl367/adxl367.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.h:108 -#define ADXL367_SPI_READ_FIFO 0x0Du +#define ADXL367_SPI_READ_FIFO 0x0Du
#define ADXL367_ABSOLUTE 0x00
#define ADXL367_REFERENCED 0x01
Expand Down Expand Up @@ -201,10 +204,19 @@
/* Max change = 270mg. Sensitivity = 4LSB / mg */
#define ADXL367_SELF_TEST_MAX (270 * 100 / 25)

/* ADXL367 get fifo sample header */
#define ADXL367_FIFO_HDR_GET_ACCEL_AXIS(x) (((x) & 0xC000) >> 14)
#define ADXL367_FIFO_HDR_CHECK_TEMP(x) ((((x) & 0xC000) >> 14) == 0x3)

/* ADXL362 scale factors from specifications */
#define ADXL367_ACCEL_2G_LSB_PER_G 4000
#define ADXL367_ACCEL_4G_LSB_PER_G 2000
#define ADXL367_ACCEL_8G_LSB_PER_G 1000

Check notice on line 215 in drivers/sensor/adi/adxl367/adxl367.h

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

drivers/sensor/adi/adxl367/adxl367.h:215 -#define ADXL367_FIFO_HDR_GET_ACCEL_AXIS(x) (((x) & 0xC000) >> 14) -#define ADXL367_FIFO_HDR_CHECK_TEMP(x) ((((x) & 0xC000) >> 14) == 0x3) +#define ADXL367_FIFO_HDR_GET_ACCEL_AXIS(x) (((x) & 0xC000) >> 14) +#define ADXL367_FIFO_HDR_CHECK_TEMP(x) ((((x) & 0xC000) >> 14) == 0x3) /* ADXL362 scale factors from specifications */ -#define ADXL367_ACCEL_2G_LSB_PER_G 4000 -#define ADXL367_ACCEL_4G_LSB_PER_G 2000 -#define ADXL367_ACCEL_8G_LSB_PER_G 1000 +#define ADXL367_ACCEL_2G_LSB_PER_G 4000 +#define ADXL367_ACCEL_4G_LSB_PER_G 2000 +#define ADXL367_ACCEL_8G_LSB_PER_G 1000
enum adxl367_axis {
ADXL367_X_AXIS,
ADXL367_Y_AXIS,
ADXL367_Z_AXIS
ADXL367_X_AXIS = 0x0,
ADXL367_Y_AXIS = 0x1,
ADXL367_Z_AXIS = 0x2
};

enum adxl367_op_mode {
Expand Down Expand Up @@ -279,6 +291,16 @@ struct adxl367_xyz_accel_data {
int16_t x;
int16_t y;
int16_t z;
enum adxl367_range range;
};

struct adxl367_sample_data {
#ifdef CONFIG_ADXL367_STREAM
uint8_t is_fifo: 1;
uint8_t res: 7;
#endif /*CONFIG_ADXL367_STREAM*/
struct adxl367_xyz_accel_data xyz;
int16_t raw_temp;
};

struct adxl367_transfer_function {
Expand Down Expand Up @@ -316,6 +338,20 @@ struct adxl367_data {
struct k_work work;
#endif
#endif /* CONFIG_ADXL367_TRIGGER */
#ifdef CONFIG_ADXL367_STREAM
uint8_t status;
uint8_t fifo_ent[2];
struct rtio_iodev_sqe *sqe;
struct rtio *rtio_ctx;
struct rtio_iodev *iodev;
uint64_t timestamp;
struct rtio *r_cb;
uint8_t fifo_full_irq: 1;
uint8_t fifo_wmark_irq: 1;
uint8_t res: 6;
enum adxl367_odr odr;
uint8_t pwr_reg;
#endif /* CONFIG_ADXL367_STREAM */
};

struct adxl367_dev_config {
Expand Down Expand Up @@ -349,12 +385,57 @@ struct adxl367_dev_config {
uint8_t activity_time;
};

struct adxl367_fifo_data {
uint8_t is_fifo: 1;
uint8_t res: 7;
uint8_t packet_size;
uint8_t fifo_read_mode;
uint8_t has_tmp: 1;
uint8_t has_adc: 1;
uint8_t has_x: 1;
uint8_t has_y: 1;
uint8_t has_z: 1;
uint8_t res1: 3;
uint8_t int_status;
uint8_t accel_odr: 4;
uint8_t range: 4;
uint16_t fifo_byte_count;
uint64_t timestamp;
} __attribute__((__packed__));

BUILD_ASSERT(sizeof(struct adxl367_fifo_data) % 4 == 0,
"adxl367_fifo_data struct should be word aligned");

int adxl367_spi_init(const struct device *dev);
int adxl367_i2c_init(const struct device *dev);
int adxl367_trigger_set(const struct device *dev,
const struct sensor_trigger *trig,
sensor_trigger_handler_t handler);

int adxl367_init_interrupt(const struct device *dev);
void adxl367_submit_stream(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
void adxl367_stream_irq_handler(const struct device *dev);

#ifdef CONFIG_SENSOR_ASYNC_API
void adxl367_submit(const struct device *dev, struct rtio_iodev_sqe *iodev_sqe);
int adxl367_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder);
int adxl367_get_accel_data(const struct device *dev,
struct adxl367_xyz_accel_data *accel_data);
int adxl367_get_temp_data(const struct device *dev, int16_t *raw_temp);
void adxl367_accel_convert(struct sensor_value *val, int16_t value,
enum adxl367_range range);
void adxl367_temp_convert(struct sensor_value *val, int16_t value);
#endif /* CONFIG_SENSOR_ASYNC_API */

#ifdef CONFIG_ADXL367_STREAM
int adxl367_fifo_setup(const struct device *dev,
enum adxl367_fifo_mode mode,
enum adxl367_fifo_format format,
enum adxl367_fifo_read_mode read_mode,
uint8_t sets_nb);
int adxl367_set_op_mode(const struct device *dev,
enum adxl367_op_mode op_mode);
size_t adxl367_get_packet_size(const struct adxl367_dev_config *cfg);
#endif /* CONFIG_ADXL367_STREAM */

#endif /* ZEPHYR_DRIVERS_SENSOR_ADXL367_ADXL367_H_ */
Loading

0 comments on commit 51adfed

Please sign in to comment.