Zephyr Project API  3.4.0
A Scalable Open Source RTOS
sensor.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2016 Intel Corporation
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
13#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
14
22#include <errno.h>
23#include <stdlib.h>
24
25#include <zephyr/device.h>
26#include <zephyr/dsp/types.h>
27#include <zephyr/rtio/rtio.h>
29#include <zephyr/types.h>
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
53};
54
108
117
124
131
134
137
144
147
184
187
192
198
203};
204
234
237
240
243
246
253
259
264};
265
274};
275
296 /* Hysteresis for trigger thresholds. */
330
336
341};
342
350typedef void (*sensor_trigger_handler_t)(const struct device *dev,
351 const struct sensor_trigger *trigger);
352
359typedef int (*sensor_attr_set_t)(const struct device *dev,
360 enum sensor_channel chan,
361 enum sensor_attribute attr,
362 const struct sensor_value *val);
363
370typedef int (*sensor_attr_get_t)(const struct device *dev,
371 enum sensor_channel chan,
372 enum sensor_attribute attr,
373 struct sensor_value *val);
374
381typedef int (*sensor_trigger_set_t)(const struct device *dev,
382 const struct sensor_trigger *trig,
390typedef int (*sensor_sample_fetch_t)(const struct device *dev,
391 enum sensor_channel chan);
398typedef int (*sensor_channel_get_t)(const struct device *dev,
399 enum sensor_channel chan,
400 struct sensor_value *val);
401
435
441
457 int (*get_frame_count)(const uint8_t *buffer, uint16_t *frame_count);
458
468 int (*get_timestamp)(const uint8_t *buffer, uint64_t *timestamp_ns);
469
483 int (*get_shift)(const uint8_t *buffer, enum sensor_channel channel_type, int8_t *shift);
484
501 sensor_channel_iterator_t *cit, enum sensor_channel *channels, q31_t *values,
502 uint8_t max_count);
503};
504
511typedef int (*sensor_get_decoder_t)(const struct device *dev,
512 const struct sensor_decoder_api **api);
513
514/*
515 * Internal data structure used to store information about the IODevice for async reading and
516 * streaming sensor data.
517 */
519 const struct device *sensor;
521 size_t count;
522 const size_t max;
523};
524
539#define SENSOR_DT_READ_IODEV(name, dt_node, ...) \
540 static enum sensor_channel __channel_array_##name[] = {__VA_ARGS__}; \
541 static struct sensor_read_config __sensor_read_config_##name = { \
542 .sensor = DEVICE_DT_GET(dt_node), \
543 .channels = __channel_array_##name, \
544 .count = ARRAY_SIZE(__channel_array_##name), \
545 .max = ARRAY_SIZE(__channel_array_##name), \
546 }; \
547 RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, &__sensor_read_config_##name)
548
549/* Used to submit an RTIO sqe to the sensor's iodev */
550typedef int (*sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe);
551
552/* The default decoder API */
553extern const struct sensor_decoder_api __sensor_default_decoder;
554
555/* The default sensor iodev API */
556extern const struct rtio_iodev_api __sensor_iodev_api;
557
558__subsystem struct sensor_driver_api {
566};
567
580__syscall int sensor_attr_set(const struct device *dev,
581 enum sensor_channel chan,
582 enum sensor_attribute attr,
583 const struct sensor_value *val);
584
585static inline int z_impl_sensor_attr_set(const struct device *dev,
586 enum sensor_channel chan,
587 enum sensor_attribute attr,
588 const struct sensor_value *val)
589{
590 const struct sensor_driver_api *api =
591 (const struct sensor_driver_api *)dev->api;
592
593 if (api->attr_set == NULL) {
594 return -ENOSYS;
595 }
596
597 return api->attr_set(dev, chan, attr, val);
598}
599
612__syscall int sensor_attr_get(const struct device *dev,
613 enum sensor_channel chan,
614 enum sensor_attribute attr,
615 struct sensor_value *val);
616
617static inline int z_impl_sensor_attr_get(const struct device *dev,
618 enum sensor_channel chan,
619 enum sensor_attribute attr,
620 struct sensor_value *val)
621{
622 const struct sensor_driver_api *api =
623 (const struct sensor_driver_api *)dev->api;
624
625 if (api->attr_get == NULL) {
626 return -ENOSYS;
627 }
628
629 return api->attr_get(dev, chan, attr, val);
630}
631
654static inline int sensor_trigger_set(const struct device *dev,
655 const struct sensor_trigger *trig,
657{
658 const struct sensor_driver_api *api =
659 (const struct sensor_driver_api *)dev->api;
660
661 if (api->trigger_set == NULL) {
662 return -ENOSYS;
663 }
664
665 return api->trigger_set(dev, trig, handler);
666}
667
686__syscall int sensor_sample_fetch(const struct device *dev);
687
688static inline int z_impl_sensor_sample_fetch(const struct device *dev)
689{
690 const struct sensor_driver_api *api =
691 (const struct sensor_driver_api *)dev->api;
692
693 return api->sample_fetch(dev, SENSOR_CHAN_ALL);
694}
695
717__syscall int sensor_sample_fetch_chan(const struct device *dev,
718 enum sensor_channel type);
719
720static inline int z_impl_sensor_sample_fetch_chan(const struct device *dev,
721 enum sensor_channel type)
722{
723 const struct sensor_driver_api *api =
724 (const struct sensor_driver_api *)dev->api;
725
726 return api->sample_fetch(dev, type);
727}
728
750__syscall int sensor_channel_get(const struct device *dev,
751 enum sensor_channel chan,
752 struct sensor_value *val);
753
754static inline int z_impl_sensor_channel_get(const struct device *dev,
755 enum sensor_channel chan,
756 struct sensor_value *val)
757{
758 const struct sensor_driver_api *api =
759 (const struct sensor_driver_api *)dev->api;
760
761 return api->channel_get(dev, chan, val);
762}
763
764#if defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__)
765
766/*
767 * Generic data structure used for encoding the sample timestamp and number of channels sampled.
768 */
769struct __attribute__((__packed__)) sensor_data_generic_header {
770 /* The timestamp at which the data was collected from the sensor */
772
773 /*
774 * The number of channels present in the frame. This will be the true number of elements in
775 * channel_info and in the q31 values that follow the header.
776 */
778
779 /* Shift value for all samples in the frame */
781
782 /* Channels present in the frame */
783 enum sensor_channel channels[0];
784};
785
795#define SENSOR_CHANNEL_3_AXIS(chan) \
796 ((chan) == SENSOR_CHAN_ACCEL_XYZ || (chan) == SENSOR_CHAN_GYRO_XYZ || \
797 (chan) == SENSOR_CHAN_MAGN_XYZ)
798
807__syscall int sensor_get_decoder(const struct device *dev,
808 const struct sensor_decoder_api **decoder);
809
810static inline int z_impl_sensor_get_decoder(const struct device *dev,
811 const struct sensor_decoder_api **decoder)
812{
813 const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api;
814
815 __ASSERT_NO_MSG(api != NULL);
816
817 if (api->get_decoder == NULL) {
818 *decoder = &__sensor_default_decoder;
819 return 0;
820 }
821
822 return api->get_decoder(dev, decoder);
823}
824
843__syscall int sensor_reconfigure_read_iodev(struct rtio_iodev *iodev, const struct device *sensor,
844 const enum sensor_channel *channels,
845 size_t num_channels);
846
847static inline int z_impl_sensor_reconfigure_read_iodev(struct rtio_iodev *iodev,
848 const struct device *sensor,
849 const enum sensor_channel *channels,
850 size_t num_channels)
851{
852 struct sensor_read_config *cfg = (struct sensor_read_config *)iodev->data;
853
854 if (cfg->max < num_channels) {
855 return -ENOMEM;
856 }
857
858 cfg->sensor = sensor;
859 memcpy(cfg->channels, channels, num_channels * sizeof(enum sensor_channel));
860 cfg->count = num_channels;
861 return 0;
862 return 0;
863}
864
878static inline int sensor_read(struct rtio_iodev *iodev, struct rtio *ctx, void *userdata)
879{
880 if (IS_ENABLED(CONFIG_USERSPACE)) {
881 struct rtio_sqe sqe;
882
884 rtio_sqe_copy_in(ctx, &sqe, 1);
885 } else {
886 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
887
888 if (sqe == NULL) {
889 return -ENOMEM;
890 }
892 }
893 rtio_submit(ctx, 0);
894 return 0;
895}
896
909 void *userdata);
910
923
924#endif /* defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__) */
925
929#define SENSOR_G 9806650LL
930
934#define SENSOR_PI 3141592LL
935
944static inline int32_t sensor_ms2_to_g(const struct sensor_value *ms2)
945{
946 int64_t micro_ms2 = ms2->val1 * 1000000LL + ms2->val2;
947
948 if (micro_ms2 > 0) {
949 return (micro_ms2 + SENSOR_G / 2) / SENSOR_G;
950 } else {
951 return (micro_ms2 - SENSOR_G / 2) / SENSOR_G;
952 }
953}
954
961static inline void sensor_g_to_ms2(int32_t g, struct sensor_value *ms2)
962{
963 ms2->val1 = ((int64_t)g * SENSOR_G) / 1000000LL;
964 ms2->val2 = ((int64_t)g * SENSOR_G) % 1000000LL;
965}
966
975static inline int32_t sensor_ms2_to_ug(const struct sensor_value *ms2)
976{
977 int64_t micro_ms2 = (ms2->val1 * INT64_C(1000000)) + ms2->val2;
978
979 return (micro_ms2 * 1000000LL) / SENSOR_G;
980}
981
988static inline void sensor_ug_to_ms2(int32_t ug, struct sensor_value *ms2)
989{
990 ms2->val1 = ((int64_t)ug * SENSOR_G / 1000000LL) / 1000000LL;
991 ms2->val2 = ((int64_t)ug * SENSOR_G / 1000000LL) % 1000000LL;
992}
993
1001static inline int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
1002{
1003 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1004
1005 if (micro_rad_s > 0) {
1006 return (micro_rad_s * 180LL + SENSOR_PI / 2) / SENSOR_PI;
1007 } else {
1008 return (micro_rad_s * 180LL - SENSOR_PI / 2) / SENSOR_PI;
1009 }
1010}
1011
1018static inline void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
1019{
1020 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL) / 1000000LL;
1021 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL) % 1000000LL;
1022}
1023
1035static inline int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
1036{
1037 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1038
1039 return (micro_rad_s * 180LL * 100000LL) / SENSOR_PI;
1040}
1041
1048static inline void sensor_10udegrees_to_rad(int32_t d, struct sensor_value *rad)
1049{
1050 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) / 1000000LL;
1051 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) % 1000000LL;
1052}
1053
1060static inline double sensor_value_to_double(const struct sensor_value *val)
1061{
1062 return (double)val->val1 + (double)val->val2 / 1000000;
1063}
1064
1071static inline float sensor_value_to_float(const struct sensor_value *val)
1072{
1073 return (float)val->val1 + (float)val->val2 / 1000000;
1074}
1075
1083static inline int sensor_value_from_double(struct sensor_value *val, double inp)
1084{
1085 if (inp < INT32_MIN || inp > INT32_MAX) {
1086 return -ERANGE;
1087 }
1088
1089 double val2 = (inp - (int32_t)inp) * 1000000.0;
1090
1091 if (val2 < INT32_MIN || val2 > INT32_MAX) {
1092 return -ERANGE;
1093 }
1094
1095 val->val1 = (int32_t)inp;
1096 val->val2 = (int32_t)val2;
1097
1098 return 0;
1099}
1100
1108static inline int sensor_value_from_float(struct sensor_value *val, float inp)
1109{
1110 float val2 = (inp - (int32_t)inp) * 1000000.0;
1111
1112 if (val2 < INT32_MIN || val2 > (float)(INT32_MAX - 1)) {
1113 return -ERANGE;
1114 }
1115
1116 val->val1 = (int32_t)inp;
1117 val->val2 = (int32_t)val2;
1118
1119 return 0;
1120}
1121
1122#ifdef CONFIG_SENSOR_INFO
1123
1124struct sensor_info {
1125 const struct device *dev;
1126 const char *vendor;
1127 const char *model;
1128 const char *friendly_name;
1129};
1130
1131#define SENSOR_INFO_INITIALIZER(_dev, _vendor, _model, _friendly_name) \
1132 { \
1133 .dev = _dev, \
1134 .vendor = _vendor, \
1135 .model = _model, \
1136 .friendly_name = _friendly_name, \
1137 }
1138
1139#define SENSOR_INFO_DEFINE(name, ...) \
1140 static const STRUCT_SECTION_ITERABLE(sensor_info, name) = \
1141 SENSOR_INFO_INITIALIZER(__VA_ARGS__)
1142
1143#define SENSOR_INFO_DT_NAME(node_id) \
1144 _CONCAT(__sensor_info, DEVICE_DT_NAME_GET(node_id))
1145
1146#define SENSOR_INFO_DT_DEFINE(node_id) \
1147 SENSOR_INFO_DEFINE(SENSOR_INFO_DT_NAME(node_id), \
1148 DEVICE_DT_GET(node_id), \
1149 DT_NODE_VENDOR_OR(node_id, NULL), \
1150 DT_NODE_MODEL_OR(node_id, NULL), \
1151 DT_PROP_OR(node_id, friendly_name, NULL)) \
1152
1153#else
1154
1155#define SENSOR_INFO_DEFINE(name, ...)
1156#define SENSOR_INFO_DT_DEFINE(node_id)
1157
1158#endif /* CONFIG_SENSOR_INFO */
1159
1187#define SENSOR_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1188 data_ptr, cfg_ptr, level, prio, \
1189 api_ptr, ...) \
1190 DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1191 data_ptr, cfg_ptr, level, prio, \
1192 api_ptr, __VA_ARGS__); \
1193 \
1194 SENSOR_INFO_DT_DEFINE(node_id);
1195
1205#define SENSOR_DEVICE_DT_INST_DEFINE(inst, ...) \
1206 SENSOR_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1207
1215{
1216 return ((int64_t)val->val1 * 1000) + val->val2 / 1000;
1217}
1218
1226{
1227 return ((int64_t)val->val1 * 1000000) + val->val2;
1228}
1229
1234#if defined(CONFIG_HAS_DTS) || defined(__DOXYGEN__)
1235
1241#define SENSOR_DECODER_NAME() UTIL_CAT(DT_DRV_COMPAT, __decoder_api)
1242
1250#define SENSOR_DECODER_DT_GET(node_id) \
1251 &UTIL_CAT(DT_STRING_TOKEN_BY_IDX(node_id, compatible, 0), __decoder_api)
1252
1268#define SENSOR_DECODER_API_DT_DEFINE() \
1269 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), (), (static)) \
1270 const STRUCT_SECTION_ITERABLE(sensor_decoder_api, SENSOR_DECODER_NAME())
1271
1272#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX(node_id, prop, idx) \
1273 extern const struct sensor_decoder_api UTIL_CAT( \
1274 DT_STRING_TOKEN_BY_IDX(node_id, prop, idx), __decoder_api);
1275
1276#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL(node_id) \
1277 COND_CODE_1(DT_NODE_HAS_PROP(node_id, compatible), \
1278 (DT_FOREACH_PROP_ELEM(node_id, compatible, \
1279 Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX)), \
1280 ())
1281
1282DT_FOREACH_STATUS_OKAY_NODE(Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL)
1283#endif /* defined(CONFIG_HAS_DTS) || defined(__DOXYGEN__) */
1284
1285#ifdef __cplusplus
1286}
1287#endif
1288
1289#include <syscalls/sensor.h>
1290
1291#endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_ */
irp nz macro MOVR cc d
Definition: asm-macro-32-bit-gnu.h:11
DT_FOREACH_STATUS_OKAY_NODE(Z_MAYBE_EMUL_DECLARE_INTERNAL)
struct result result[2]
Definition: errno.c:42
System error numbers.
int32_t q31_t
32-bit fractional data type in 1.31 format.
Definition: types.h:35
static void rtio_sqe_prep_read_with_pool(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Prepare a read op submission with context's mempool.
Definition: rtio.h:506
static int rtio_sqe_copy_in(struct rtio *r, const struct rtio_sqe *sqes, size_t sqe_count)
Copy an array of SQEs into the queue.
Definition: rtio.h:1339
static struct rtio_sqe * rtio_sqe_acquire(struct rtio *r)
Acquire a single submission queue event if available.
Definition: rtio.h:883
int rtio_submit(struct rtio *r, uint32_t wait_count)
Submit I/O requests to the underlying executor.
#define RTIO_PRIO_NORM
Normal priority.
Definition: rtio.h:76
#define SENSOR_G
The value of gravitational constant in micro m/s^2.
Definition: sensor.h:929
static int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
Helper function for converting radians to degrees.
Definition: sensor.h:1001
sensor_trigger_type
Sensor trigger types.
Definition: sensor.h:208
sensor_attribute
Sensor attribute types.
Definition: sensor.h:279
int(* sensor_attr_set_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
Callback API upon setting a sensor's attributes.
Definition: sensor.h:359
int sensor_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder)
Get the sensor's decoder API.
int(* sensor_sample_fetch_t)(const struct device *dev, enum sensor_channel chan)
Callback API for fetching data from a sensor.
Definition: sensor.h:390
static void sensor_ug_to_ms2(int32_t ug, struct sensor_value *ms2)
Helper function to convert acceleration from micro Gs to m/s^2.
Definition: sensor.h:988
static double sensor_value_to_double(const struct sensor_value *val)
Helper function for converting struct sensor_value to double.
Definition: sensor.h:1060
static float sensor_value_to_float(const struct sensor_value *val)
Helper function for converting struct sensor_value to float.
Definition: sensor.h:1071
static int sensor_read(struct rtio_iodev *iodev, struct rtio *ctx, void *userdata)
Read data from a sensor.
Definition: sensor.h:878
static void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
Helper function for converting degrees to radians.
Definition: sensor.h:1018
static int32_t sensor_ms2_to_ug(const struct sensor_value *ms2)
Helper function to convert acceleration from m/s^2 to micro Gs.
Definition: sensor.h:975
int(* sensor_attr_get_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val)
Callback API upon getting a sensor's attributes.
Definition: sensor.h:370
static int sensor_value_from_float(struct sensor_value *val, float inp)
Helper function for converting float to struct sensor_value.
Definition: sensor.h:1108
void(* sensor_trigger_handler_t)(const struct device *dev, const struct sensor_trigger *trigger)
Callback API upon firing of a trigger.
Definition: sensor.h:350
static void sensor_g_to_ms2(int32_t g, struct sensor_value *ms2)
Helper function to convert acceleration from Gs to m/s^2.
Definition: sensor.h:961
#define SENSOR_PI
The value of constant PI in micros.
Definition: sensor.h:934
static int sensor_trigger_set(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler)
Activate a sensor's trigger and set the trigger handler.
Definition: sensor.h:654
static int64_t sensor_value_to_milli(struct sensor_value *val)
Helper function for converting struct sensor_value to integer milli units.
Definition: sensor.h:1214
static int64_t sensor_value_to_micro(struct sensor_value *val)
Helper function for converting struct sensor_value to integer micro units.
Definition: sensor.h:1225
int sensor_reconfigure_read_iodev(struct rtio_iodev *iodev, const struct device *sensor, const enum sensor_channel *channels, size_t num_channels)
Reconfigure a reading iodev.
void(* sensor_processing_callback_t)(int result, uint8_t *buf, uint32_t buf_len, void *userdata)
Callback function used with the helper processing function.
Definition: sensor.h:908
int sensor_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Get a reading from a sensor device.
uint32_t sensor_frame_iterator_t
Used for iterating over the data frames via the :c:struct:sensor_decoder_api
Definition: sensor.h:434
int sensor_sample_fetch(const struct device *dev)
Fetch a sample from the sensor and store it in an internal driver buffer.
uint32_t sensor_channel_iterator_t
Used for iterating over data channels in the same frame via :c:struct:sensor_decoder_api
Definition: sensor.h:440
sensor_channel
Sensor channels.
Definition: sensor.h:58
int(* sensor_get_decoder_t)(const struct device *dev, const struct sensor_decoder_api **api)
Get the decoder associate with the given device.
Definition: sensor.h:511
static void sensor_10udegrees_to_rad(int32_t d, struct sensor_value *rad)
Helper function for converting 10 micro degrees to radians.
Definition: sensor.h:1048
int(* sensor_channel_get_t)(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Callback API for getting a reading from a sensor.
Definition: sensor.h:398
static int32_t sensor_ms2_to_g(const struct sensor_value *ms2)
Helper function to convert acceleration from m/s^2 to Gs.
Definition: sensor.h:944
int(* sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe)
Definition: sensor.h:550
void sensor_processing_with_callback(struct rtio *ctx, sensor_processing_callback_t cb)
Helper function for common processing of sensor data.
int(* sensor_trigger_set_t)(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler)
Callback API for setting a sensor's trigger and handler.
Definition: sensor.h:381
int sensor_sample_fetch_chan(const struct device *dev, enum sensor_channel type)
Fetch a sample from the sensor and store it in an internal driver buffer.
static int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
Helper function for converting radians to 10 micro degrees.
Definition: sensor.h:1035
int sensor_attr_get(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val)
Get an attribute for a sensor.
static int sensor_value_from_double(struct sensor_value *val, double inp)
Helper function for converting double to struct sensor_value.
Definition: sensor.h:1083
int sensor_attr_set(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
Set an attribute for a sensor.
@ SENSOR_TRIG_DELTA
Definition: sensor.h:224
@ SENSOR_TRIG_NEAR_FAR
Definition: sensor.h:226
@ SENSOR_TRIG_FREEFALL
Definition: sensor.h:242
@ SENSOR_TRIG_PRIV_START
Definition: sensor.h:258
@ SENSOR_TRIG_MOTION
Definition: sensor.h:245
@ SENSOR_TRIG_STATIONARY
Definition: sensor.h:248
@ SENSOR_TRIG_COMMON_COUNT
Definition: sensor.h:252
@ SENSOR_TRIG_THRESHOLD
Definition: sensor.h:233
@ SENSOR_TRIG_MAX
Definition: sensor.h:263
@ SENSOR_TRIG_DOUBLE_TAP
Definition: sensor.h:239
@ SENSOR_TRIG_TIMER
Definition: sensor.h:213
@ SENSOR_TRIG_TAP
Definition: sensor.h:236
@ SENSOR_TRIG_DATA_READY
Definition: sensor.h:215
@ SENSOR_ATTR_HYSTERESIS
Definition: sensor.h:297
@ SENSOR_ATTR_FEATURE_MASK
Definition: sensor.h:317
@ SENSOR_ATTR_CALIB_TARGET
Definition: sensor.h:311
@ SENSOR_ATTR_OFFSET
Definition: sensor.h:306
@ SENSOR_ATTR_OVERSAMPLING
Definition: sensor.h:299
@ SENSOR_ATTR_FF_DUR
Definition: sensor.h:325
@ SENSOR_ATTR_UPPER_THRESH
Definition: sensor.h:288
@ SENSOR_ATTR_CONFIGURATION
Definition: sensor.h:313
@ SENSOR_ATTR_CALIBRATION
Definition: sensor.h:315
@ SENSOR_ATTR_COMMON_COUNT
Definition: sensor.h:329
@ SENSOR_ATTR_ALERT
Definition: sensor.h:319
@ SENSOR_ATTR_SLOPE_TH
Definition: sensor.h:290
@ SENSOR_ATTR_SAMPLING_FREQUENCY
Definition: sensor.h:284
@ SENSOR_ATTR_FULL_SCALE
Definition: sensor.h:301
@ SENSOR_ATTR_LOWER_THRESH
Definition: sensor.h:286
@ SENSOR_ATTR_SLOPE_DUR
Definition: sensor.h:295
@ SENSOR_ATTR_MAX
Definition: sensor.h:340
@ SENSOR_ATTR_PRIV_START
Definition: sensor.h:335
@ SENSOR_CHAN_GAUGE_STATE_OF_HEALTH
Definition: sensor.h:171
@ SENSOR_CHAN_PM_1_0
Definition: sensor.h:110
@ SENSOR_CHAN_DIE_TEMP
Definition: sensor.h:84
@ SENSOR_CHAN_PRESS
Definition: sensor.h:88
@ SENSOR_CHAN_GAUGE_TIME_TO_FULL
Definition: sensor.h:175
@ SENSOR_CHAN_ACCEL_XYZ
Definition: sensor.h:66
@ SENSOR_CHAN_MAGN_X
Definition: sensor.h:76
@ SENSOR_CHAN_CURRENT
Definition: sensor.h:128
@ SENSOR_CHAN_GYRO_XYZ
Definition: sensor.h:74
@ SENSOR_CHAN_GREEN
Definition: sensor.h:103
@ SENSOR_CHAN_MAGN_Z
Definition: sensor.h:80
@ SENSOR_CHAN_MAGN_Y
Definition: sensor.h:78
@ SENSOR_CHAN_GAUGE_DESIRED_VOLTAGE
Definition: sensor.h:181
@ SENSOR_CHAN_POWER
Definition: sensor.h:130
@ SENSOR_CHAN_PM_2_5
Definition: sensor.h:112
@ SENSOR_CHAN_RESISTANCE
Definition: sensor.h:133
@ SENSOR_CHAN_GAUGE_AVG_CURRENT
Definition: sensor.h:151
@ SENSOR_CHAN_GYRO_Y
Definition: sensor.h:70
@ SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT
Definition: sensor.h:183
@ SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY
Definition: sensor.h:161
@ SENSOR_CHAN_ROTATION
Definition: sensor.h:136
@ SENSOR_CHAN_AMBIENT_TEMP
Definition: sensor.h:86
@ SENSOR_CHAN_MAGN_XYZ
Definition: sensor.h:82
@ SENSOR_CHAN_GAUGE_STDBY_CURRENT
Definition: sensor.h:153
@ SENSOR_CHAN_GAUGE_MAX_LOAD_CURRENT
Definition: sensor.h:155
@ SENSOR_CHAN_ACCEL_Y
Definition: sensor.h:62
@ SENSOR_CHAN_RPM
Definition: sensor.h:146
@ SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY
Definition: sensor.h:167
@ SENSOR_CHAN_VOLTAGE
Definition: sensor.h:126
@ SENSOR_CHAN_BLUE
Definition: sensor.h:105
@ SENSOR_CHAN_LIGHT
Definition: sensor.h:97
@ SENSOR_CHAN_GAUGE_DESIGN_VOLTAGE
Definition: sensor.h:179
@ SENSOR_CHAN_ACCEL_Z
Definition: sensor.h:64
@ SENSOR_CHAN_CO2
Definition: sensor.h:119
@ SENSOR_CHAN_GAUGE_STATE_OF_CHARGE
Definition: sensor.h:159
@ SENSOR_CHAN_GAUGE_CYCLE_COUNT
Definition: sensor.h:177
@ SENSOR_CHAN_GAUGE_TEMP
Definition: sensor.h:157
@ SENSOR_CHAN_POS_DY
Definition: sensor.h:141
@ SENSOR_CHAN_GYRO_Z
Definition: sensor.h:72
@ SENSOR_CHAN_POS_DX
Definition: sensor.h:139
@ SENSOR_CHAN_GAUGE_AVG_POWER
Definition: sensor.h:169
@ SENSOR_CHAN_GAUGE_TIME_TO_EMPTY
Definition: sensor.h:173
@ SENSOR_CHAN_PM_10
Definition: sensor.h:114
@ SENSOR_CHAN_GAUGE_REMAINING_CHARGE_CAPACITY
Definition: sensor.h:163
@ SENSOR_CHAN_ALL
Definition: sensor.h:186
@ SENSOR_CHAN_GAUGE_VOLTAGE
Definition: sensor.h:149
@ SENSOR_CHAN_PROX
Definition: sensor.h:93
@ SENSOR_CHAN_COMMON_COUNT
Definition: sensor.h:191
@ SENSOR_CHAN_PRIV_START
Definition: sensor.h:197
@ SENSOR_CHAN_GYRO_X
Definition: sensor.h:68
@ SENSOR_CHAN_GAS_RES
Definition: sensor.h:123
@ SENSOR_CHAN_HUMIDITY
Definition: sensor.h:95
@ SENSOR_CHAN_DISTANCE
Definition: sensor.h:116
@ SENSOR_CHAN_IR
Definition: sensor.h:99
@ SENSOR_CHAN_MAX
Definition: sensor.h:202
@ SENSOR_CHAN_POS_DZ
Definition: sensor.h:143
@ SENSOR_CHAN_RED
Definition: sensor.h:101
@ SENSOR_CHAN_ALTITUDE
Definition: sensor.h:107
@ SENSOR_CHAN_GAUGE_NOM_AVAIL_CAPACITY
Definition: sensor.h:165
@ SENSOR_CHAN_ACCEL_X
Definition: sensor.h:60
@ SENSOR_CHAN_VOC
Definition: sensor.h:121
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition: util_macro.h:124
#define ENOSYS
Definition: errno.h:83
#define ENOMEM
Definition: errno.h:51
#define ERANGE
Definition: errno.h:73
#define INT64_C(x)
Definition: llvm.h:83
Real-Time IO device API for moving bytes with low effort.
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT32_TYPE__ int32_t
Definition: stdint.h:74
#define INT32_MAX
Definition: stdint.h:18
__UINT64_TYPE__ uint64_t
Definition: stdint.h:91
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
#define INT16_MAX
Definition: stdint.h:17
__INT64_TYPE__ int64_t
Definition: stdint.h:75
__INT8_TYPE__ int8_t
Definition: stdint.h:72
void * memcpy(void *ZRESTRICT d, const void *ZRESTRICT s, size_t n)
Runtime device structure (in ROM) per driver instance.
Definition: device.h:380
const void * api
Definition: device.h:386
API that an RTIO IO device should implement.
Definition: rtio.h:421
Compute the mempool block index for a given pointer.
Definition: rtio.h:411
struct rtio_sqe sqe
Definition: rtio.h:412
An IO device with a function table for submitting requests.
Definition: rtio.h:439
void * data
Definition: rtio.h:447
A submission queue event.
Definition: rtio.h:238
void * userdata
Definition: rtio.h:258
uint8_t * buf
Definition: rtio.h:265
uint32_t buf_len
Definition: rtio.h:264
const struct rtio_iodev * iodev
Definition: rtio.h:249
An RTIO context containing what can be viewed as a pair of queues.
Definition: rtio.h:338
Definition: sensor.h:769
uint64_t timestamp_ns
Definition: sensor.h:771
int8_t shift
Definition: sensor.h:780
size_t num_channels
Definition: sensor.h:777
Decodes a single raw data buffer.
Definition: sensor.h:448
int(* get_timestamp)(const uint8_t *buffer, uint64_t *timestamp_ns)
Get the timestamp associated with the first frame.
Definition: sensor.h:468
int(* get_shift)(const uint8_t *buffer, enum sensor_channel channel_type, int8_t *shift)
Get the shift count of a particular channel (multiplier)
Definition: sensor.h:483
int(* decode)(const uint8_t *buffer, sensor_frame_iterator_t *fit, sensor_channel_iterator_t *cit, enum sensor_channel *channels, q31_t *values, uint8_t max_count)
Decode up to N samples from the buffer.
Definition: sensor.h:500
int(* get_frame_count)(const uint8_t *buffer, uint16_t *frame_count)
Get the number of frames in the current buffer.
Definition: sensor.h:457
Definition: sensor.h:558
sensor_get_decoder_t get_decoder
Definition: sensor.h:564
sensor_attr_set_t attr_set
Definition: sensor.h:559
sensor_attr_get_t attr_get
Definition: sensor.h:560
sensor_trigger_set_t trigger_set
Definition: sensor.h:561
sensor_sample_fetch_t sample_fetch
Definition: sensor.h:562
sensor_channel_get_t channel_get
Definition: sensor.h:563
sensor_submit_t submit
Definition: sensor.h:565
Definition: sensor.h:518
size_t count
Definition: sensor.h:521
const struct device * sensor
Definition: sensor.h:519
const size_t max
Definition: sensor.h:522
enum sensor_channel *const channels
Definition: sensor.h:520
Sensor trigger spec.
Definition: sensor.h:269
enum sensor_trigger_type type
Definition: sensor.h:271
enum sensor_channel chan
Definition: sensor.h:273
Representation of a sensor readout value.
Definition: sensor.h:48
int32_t val2
Definition: sensor.h:52
int32_t val1
Definition: sensor.h:50
static ZTEST_BMEM char buffer[8]
Definition: test_mbox_api.c:551
static void handler(struct k_timer *timer)
Definition: main.c:19