Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
 4.1.99
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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
24#include <errno.h>
25#include <stdlib.h>
26
27#include <zephyr/device.h>
29#include <zephyr/dsp/types.h>
30#include <zephyr/rtio/rtio.h>
32#include <zephyr/types.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
57
111
120
129
132
135
140
143
146
155
158
161
204
207
212
218
223};
224
295
305
379
387typedef void (*sensor_trigger_handler_t)(const struct device *dev,
388 const struct sensor_trigger *trigger);
389
396typedef int (*sensor_attr_set_t)(const struct device *dev,
397 enum sensor_channel chan,
398 enum sensor_attribute attr,
399 const struct sensor_value *val);
400
407typedef int (*sensor_attr_get_t)(const struct device *dev,
408 enum sensor_channel chan,
409 enum sensor_attribute attr,
410 struct sensor_value *val);
411
418typedef int (*sensor_trigger_set_t)(const struct device *dev,
419 const struct sensor_trigger *trig,
427typedef int (*sensor_sample_fetch_t)(const struct device *dev,
428 enum sensor_channel chan);
435typedef int (*sensor_channel_get_t)(const struct device *dev,
436 enum sensor_channel chan,
437 struct sensor_value *val);
438
451
453/* Ensure sensor_chan_spec is sensibly sized to pass by value */
454BUILD_ASSERT(sizeof(struct sensor_chan_spec) <= sizeof(uintptr_t),
455 "sensor_chan_spec size should be equal or less than the size of a machine word");
466static inline bool sensor_chan_spec_eq(struct sensor_chan_spec chan_spec0,
467 struct sensor_chan_spec chan_spec1)
468{
469 return chan_spec0.chan_type == chan_spec1.chan_type &&
470 chan_spec0.chan_idx == chan_spec1.chan_idx;
471}
472
489 int (*get_frame_count)(const uint8_t *buffer, struct sensor_chan_spec channel,
490 uint16_t *frame_count);
491
504 int (*get_size_info)(struct sensor_chan_spec channel, size_t *base_size,
505 size_t *frame_size);
506
532 int (*decode)(const uint8_t *buffer, struct sensor_chan_spec channel, uint32_t *fit,
533 uint16_t max_count, void *data_out);
534
542 bool (*has_trigger)(const uint8_t *buffer, enum sensor_trigger_type trigger);
543};
544
575
579#define SENSOR_DECODE_CONTEXT_INIT(decoder_, buffer_, channel_type_, channel_index_) \
580 { \
581 .decoder = (decoder_), \
582 .buffer = (buffer_), \
583 .channel = {.chan_type = (channel_type_), .chan_idx = (channel_index_)}, \
584 .fit = 0, \
585 }
586
595static inline int sensor_decode(struct sensor_decode_context *ctx, void *out, uint16_t max_count)
596{
597 return ctx->decoder->decode(ctx->buffer, ctx->channel, &ctx->fit, max_count, out);
598}
599
601 size_t *frame_size);
602
609typedef int (*sensor_get_decoder_t)(const struct device *dev,
610 const struct sensor_decoder_api **api);
611
623
628
629#define SENSOR_STREAM_TRIGGER_PREP(_trigger, _opt) \
630 { \
631 .trigger = (_trigger), .opt = (_opt), \
632 }
633
634/*
635 * Internal data structure used to store information about the IODevice for async reading and
636 * streaming sensor data.
637 */
639 const struct device *sensor;
640 const bool is_streaming;
641 union {
644 };
645 size_t count;
646 const size_t max;
647};
648
664#define SENSOR_DT_READ_IODEV(name, dt_node, ...) \
665 static struct sensor_chan_spec _CONCAT(__channel_array_, name)[] = {__VA_ARGS__}; \
666 static struct sensor_read_config _CONCAT(__sensor_read_config_, name) = { \
667 .sensor = DEVICE_DT_GET(dt_node), \
668 .is_streaming = false, \
669 .channels = _CONCAT(__channel_array_, name), \
670 .count = ARRAY_SIZE(_CONCAT(__channel_array_, name)), \
671 .max = ARRAY_SIZE(_CONCAT(__channel_array_, name)), \
672 }; \
673 RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, _CONCAT(&__sensor_read_config_, name))
674
694#define SENSOR_DT_STREAM_IODEV(name, dt_node, ...) \
695 static struct sensor_stream_trigger _CONCAT(__trigger_array_, name)[] = {__VA_ARGS__}; \
696 static struct sensor_read_config _CONCAT(__sensor_read_config_, name) = { \
697 .sensor = DEVICE_DT_GET(dt_node), \
698 .is_streaming = true, \
699 .triggers = _CONCAT(__trigger_array_, name), \
700 .count = ARRAY_SIZE(_CONCAT(__trigger_array_, name)), \
701 .max = ARRAY_SIZE(_CONCAT(__trigger_array_, name)), \
702 }; \
703 RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, &_CONCAT(__sensor_read_config_, name))
704
705/* Used to submit an RTIO sqe to the sensor's iodev */
706typedef void (*sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe);
707
708/* The default decoder API */
709extern const struct sensor_decoder_api __sensor_default_decoder;
710
711/* The default sensor iodev API */
712extern const struct rtio_iodev_api __sensor_iodev_api;
713
723
736__syscall int sensor_attr_set(const struct device *dev,
737 enum sensor_channel chan,
738 enum sensor_attribute attr,
739 const struct sensor_value *val);
740
741static inline int z_impl_sensor_attr_set(const struct device *dev,
742 enum sensor_channel chan,
743 enum sensor_attribute attr,
744 const struct sensor_value *val)
745{
746 const struct sensor_driver_api *api =
747 (const struct sensor_driver_api *)dev->api;
748
749 if (api->attr_set == NULL) {
750 return -ENOSYS;
751 }
752
753 return api->attr_set(dev, chan, attr, val);
754}
755
768__syscall int sensor_attr_get(const struct device *dev,
769 enum sensor_channel chan,
770 enum sensor_attribute attr,
771 struct sensor_value *val);
772
773static inline int z_impl_sensor_attr_get(const struct device *dev,
774 enum sensor_channel chan,
775 enum sensor_attribute attr,
776 struct sensor_value *val)
777{
778 const struct sensor_driver_api *api =
779 (const struct sensor_driver_api *)dev->api;
780
781 if (api->attr_get == NULL) {
782 return -ENOSYS;
783 }
784
785 return api->attr_get(dev, chan, attr, val);
786}
787
810static inline int sensor_trigger_set(const struct device *dev,
811 const struct sensor_trigger *trig,
813{
814 const struct sensor_driver_api *api =
815 (const struct sensor_driver_api *)dev->api;
816
817 if (api->trigger_set == NULL) {
818 return -ENOSYS;
819 }
820
821 return api->trigger_set(dev, trig, handler);
822}
823
842__syscall int sensor_sample_fetch(const struct device *dev);
843
844static inline int z_impl_sensor_sample_fetch(const struct device *dev)
845{
846 const struct sensor_driver_api *api =
847 (const struct sensor_driver_api *)dev->api;
848
849 return api->sample_fetch(dev, SENSOR_CHAN_ALL);
850}
851
873__syscall int sensor_sample_fetch_chan(const struct device *dev,
874 enum sensor_channel type);
875
876static inline int z_impl_sensor_sample_fetch_chan(const struct device *dev,
877 enum sensor_channel type)
878{
879 const struct sensor_driver_api *api =
880 (const struct sensor_driver_api *)dev->api;
881
882 return api->sample_fetch(dev, type);
883}
884
906__syscall int sensor_channel_get(const struct device *dev,
907 enum sensor_channel chan,
908 struct sensor_value *val);
909
910static inline int z_impl_sensor_channel_get(const struct device *dev,
911 enum sensor_channel chan,
912 struct sensor_value *val)
913{
914 const struct sensor_driver_api *api =
915 (const struct sensor_driver_api *)dev->api;
916
917 return api->channel_get(dev, chan, val);
918}
919
920#if defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__)
921
922/*
923 * Generic data structure used for encoding the sample timestamp and number of channels sampled.
924 */
925struct __attribute__((__packed__)) sensor_data_generic_header {
926 /* The timestamp at which the data was collected from the sensor */
928
929 /*
930 * The number of channels present in the frame. This will be the true number of elements in
931 * channel_info and in the q31 values that follow the header.
932 */
934
935 /* Shift value for all samples in the frame */
937
938 /* This padding is needed to make sure that the 'channels' field is aligned */
939 int8_t _padding[sizeof(struct sensor_chan_spec) - 1];
940
941 /* Channels present in the frame */
942 struct sensor_chan_spec channels[0];
943};
944
953#define SENSOR_CHANNEL_3_AXIS(chan) \
954 ((chan) == SENSOR_CHAN_ACCEL_XYZ || (chan) == SENSOR_CHAN_GYRO_XYZ || \
955 (chan) == SENSOR_CHAN_MAGN_XYZ || (chan) == SENSOR_CHAN_POS_DXYZ)
956
965#define SENSOR_CHANNEL_IS_ACCEL(chan) \
966 ((chan) == SENSOR_CHAN_ACCEL_XYZ || (chan) == SENSOR_CHAN_ACCEL_X || \
967 (chan) == SENSOR_CHAN_ACCEL_Y || (chan) == SENSOR_CHAN_ACCEL_Z)
968
977#define SENSOR_CHANNEL_IS_GYRO(chan) \
978 ((chan) == SENSOR_CHAN_GYRO_XYZ || (chan) == SENSOR_CHAN_GYRO_X || \
979 (chan) == SENSOR_CHAN_GYRO_Y || (chan) == SENSOR_CHAN_GYRO_Z)
980
989__syscall int sensor_get_decoder(const struct device *dev,
990 const struct sensor_decoder_api **decoder);
991
992static inline int z_impl_sensor_get_decoder(const struct device *dev,
993 const struct sensor_decoder_api **decoder)
994{
995 const struct sensor_driver_api *api = (const struct sensor_driver_api *)dev->api;
996
997 __ASSERT_NO_MSG(api != NULL);
998
999 if (api->get_decoder == NULL) {
1000 *decoder = &__sensor_default_decoder;
1001 return 0;
1002 }
1003
1004 return api->get_decoder(dev, decoder);
1005}
1006
1025__syscall int sensor_reconfigure_read_iodev(struct rtio_iodev *iodev, const struct device *sensor,
1026 const struct sensor_chan_spec *channels,
1027 size_t num_channels);
1028
1029static inline int z_impl_sensor_reconfigure_read_iodev(struct rtio_iodev *iodev,
1030 const struct device *sensor,
1031 const struct sensor_chan_spec *channels,
1032 size_t num_channels)
1033{
1034 struct sensor_read_config *cfg = (struct sensor_read_config *)iodev->data;
1035
1036 if (cfg->max < num_channels || cfg->is_streaming) {
1037 return -ENOMEM;
1038 }
1039
1040 cfg->sensor = sensor;
1041 memcpy(cfg->channels, channels, num_channels * sizeof(struct sensor_chan_spec));
1042 cfg->count = num_channels;
1043 return 0;
1044}
1045
1046static inline int sensor_stream(struct rtio_iodev *iodev, struct rtio *ctx, void *userdata,
1047 struct rtio_sqe **handle)
1048{
1049 if (IS_ENABLED(CONFIG_USERSPACE)) {
1050 struct rtio_sqe sqe;
1051
1053 rtio_sqe_copy_in_get_handles(ctx, &sqe, handle, 1);
1054 } else {
1055 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1056
1057 if (sqe == NULL) {
1058 return -ENOMEM;
1059 }
1060 if (handle != NULL) {
1061 *handle = sqe;
1062 }
1064 }
1065 rtio_submit(ctx, 0);
1066 return 0;
1067}
1068
1083static inline int sensor_read(struct rtio_iodev *iodev, struct rtio *ctx, uint8_t *buf,
1084 size_t buf_len)
1085{
1086 if (IS_ENABLED(CONFIG_USERSPACE)) {
1087 struct rtio_sqe sqe;
1088
1090 rtio_sqe_copy_in(ctx, &sqe, 1);
1091 } else {
1092 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1093
1094 if (sqe == NULL) {
1095 return -ENOMEM;
1096 }
1098 }
1099 rtio_submit(ctx, 0);
1100
1101 struct rtio_cqe *cqe = rtio_cqe_consume_block(ctx);
1102 int res = cqe->result;
1103
1104 __ASSERT(cqe->userdata == buf,
1105 "consumed non-matching completion for sensor read into buffer %p\n", buf);
1106
1107 rtio_cqe_release(ctx, cqe);
1108
1109 return res;
1110}
1111
1125static inline int sensor_read_async_mempool(struct rtio_iodev *iodev, struct rtio *ctx,
1126 void *userdata)
1127{
1128 if (IS_ENABLED(CONFIG_USERSPACE)) {
1129 struct rtio_sqe sqe;
1130
1132 rtio_sqe_copy_in(ctx, &sqe, 1);
1133 } else {
1134 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1135
1136 if (sqe == NULL) {
1137 return -ENOMEM;
1138 }
1140 }
1141 rtio_submit(ctx, 0);
1142 return 0;
1143}
1144
1157 void *userdata);
1158
1171
1172#endif /* defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__) */
1173
1177#define SENSOR_G 9806650LL
1178
1182#define SENSOR_PI 3141592LL
1183
1192static inline int32_t sensor_ms2_to_g(const struct sensor_value *ms2)
1193{
1194 int64_t micro_ms2 = ms2->val1 * 1000000LL + ms2->val2;
1195
1196 if (micro_ms2 > 0) {
1197 return (micro_ms2 + SENSOR_G / 2) / SENSOR_G;
1198 } else {
1199 return (micro_ms2 - SENSOR_G / 2) / SENSOR_G;
1200 }
1201}
1202
1209static inline void sensor_g_to_ms2(int32_t g, struct sensor_value *ms2)
1210{
1211 ms2->val1 = ((int64_t)g * SENSOR_G) / 1000000LL;
1212 ms2->val2 = ((int64_t)g * SENSOR_G) % 1000000LL;
1213}
1214
1223static inline int32_t sensor_ms2_to_mg(const struct sensor_value *ms2)
1224{
1225 int64_t nano_ms2 = (ms2->val1 * 1000000LL + ms2->val2) * 1000LL;
1226
1227 if (nano_ms2 > 0) {
1228 return (nano_ms2 + SENSOR_G / 2) / SENSOR_G;
1229 } else {
1230 return (nano_ms2 - SENSOR_G / 2) / SENSOR_G;
1231 }
1232}
1233
1242static inline int32_t sensor_ms2_to_ug(const struct sensor_value *ms2)
1243{
1244 int64_t micro_ms2 = (ms2->val1 * INT64_C(1000000)) + ms2->val2;
1245
1246 return (micro_ms2 * 1000000LL) / SENSOR_G;
1247}
1248
1255static inline void sensor_ug_to_ms2(int32_t ug, struct sensor_value *ms2)
1256{
1257 ms2->val1 = ((int64_t)ug * SENSOR_G / 1000000LL) / 1000000LL;
1258 ms2->val2 = ((int64_t)ug * SENSOR_G / 1000000LL) % 1000000LL;
1259}
1260
1268static inline int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
1269{
1270 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1271
1272 if (micro_rad_s > 0) {
1273 return (micro_rad_s * 180LL + SENSOR_PI / 2) / SENSOR_PI;
1274 } else {
1275 return (micro_rad_s * 180LL - SENSOR_PI / 2) / SENSOR_PI;
1276 }
1277}
1278
1285static inline void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
1286{
1287 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL) / 1000000LL;
1288 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL) % 1000000LL;
1289}
1290
1302static inline int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
1303{
1304 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1305
1306 return (micro_rad_s * 180LL * 100000LL) / SENSOR_PI;
1307}
1308
1315static inline void sensor_10udegrees_to_rad(int32_t d, struct sensor_value *rad)
1316{
1317 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) / 1000000LL;
1318 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) % 1000000LL;
1319}
1320
1327static inline double sensor_value_to_double(const struct sensor_value *val)
1328{
1329 return (double)val->val1 + (double)val->val2 / 1000000;
1330}
1331
1338static inline float sensor_value_to_float(const struct sensor_value *val)
1339{
1340 return (float)val->val1 + (float)val->val2 / 1000000;
1341}
1342
1350static inline int sensor_value_from_double(struct sensor_value *val, double inp)
1351{
1352 if (inp < INT32_MIN || inp > INT32_MAX) {
1353 return -ERANGE;
1354 }
1355
1356 double val2 = (inp - (int32_t)inp) * 1000000.0;
1357
1358 if (val2 < INT32_MIN || val2 > INT32_MAX) {
1359 return -ERANGE;
1360 }
1361
1362 val->val1 = (int32_t)inp;
1363 val->val2 = (int32_t)val2;
1364
1365 return 0;
1366}
1367
1375static inline int sensor_value_from_float(struct sensor_value *val, float inp)
1376{
1377 float val2 = (inp - (int32_t)inp) * 1000000.0f;
1378
1379 if (val2 < INT32_MIN || val2 > (float)(INT32_MAX - 1)) {
1380 return -ERANGE;
1381 }
1382
1383 val->val1 = (int32_t)inp;
1384 val->val2 = (int32_t)val2;
1385
1386 return 0;
1387}
1388
1389#ifdef CONFIG_SENSOR_INFO
1390
1391struct sensor_info {
1392 const struct device *dev;
1393 const char *vendor;
1394 const char *model;
1395 const char *friendly_name;
1396};
1397
1398#define SENSOR_INFO_INITIALIZER(_dev, _vendor, _model, _friendly_name) \
1399 { \
1400 .dev = _dev, \
1401 .vendor = _vendor, \
1402 .model = _model, \
1403 .friendly_name = _friendly_name, \
1404 }
1405
1406#define SENSOR_INFO_DEFINE(name, ...) \
1407 static const STRUCT_SECTION_ITERABLE(sensor_info, name) = \
1408 SENSOR_INFO_INITIALIZER(__VA_ARGS__)
1409
1410#define SENSOR_INFO_DT_NAME(node_id) \
1411 _CONCAT(__sensor_info, DEVICE_DT_NAME_GET(node_id))
1412
1413#define SENSOR_INFO_DT_DEFINE(node_id) \
1414 SENSOR_INFO_DEFINE(SENSOR_INFO_DT_NAME(node_id), \
1415 DEVICE_DT_GET(node_id), \
1416 DT_NODE_VENDOR_OR(node_id, NULL), \
1417 DT_NODE_MODEL_OR(node_id, NULL), \
1418 DT_PROP_OR(node_id, friendly_name, NULL)) \
1419
1420#else
1421
1422#define SENSOR_INFO_DEFINE(name, ...)
1423#define SENSOR_INFO_DT_DEFINE(node_id)
1424
1425#endif /* CONFIG_SENSOR_INFO */
1426
1454#define SENSOR_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1455 data_ptr, cfg_ptr, level, prio, \
1456 api_ptr, ...) \
1457 DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1458 data_ptr, cfg_ptr, level, prio, \
1459 api_ptr, __VA_ARGS__); \
1460 \
1461 SENSOR_INFO_DT_DEFINE(node_id);
1462
1472#define SENSOR_DEVICE_DT_INST_DEFINE(inst, ...) \
1473 SENSOR_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1474
1481static inline int64_t sensor_value_to_deci(const struct sensor_value *val)
1482{
1483 return ((int64_t)val->val1 * 10) + val->val2 / 100000;
1484}
1485
1492static inline int64_t sensor_value_to_centi(const struct sensor_value *val)
1493{
1494 return ((int64_t)val->val1 * 100) + val->val2 / 10000;
1495}
1496
1503static inline int64_t sensor_value_to_milli(const struct sensor_value *val)
1504{
1505 return ((int64_t)val->val1 * 1000) + val->val2 / 1000;
1506}
1507
1514static inline int64_t sensor_value_to_micro(const struct sensor_value *val)
1515{
1516 return ((int64_t)val->val1 * 1000000) + val->val2;
1517}
1518
1526static inline int sensor_value_from_milli(struct sensor_value *val, int64_t milli)
1527{
1528 if (milli < ((int64_t)INT32_MIN - 1) * 1000LL ||
1529 milli > ((int64_t)INT32_MAX + 1) * 1000LL) {
1530 return -ERANGE;
1531 }
1532
1533 val->val1 = (int32_t)(milli / 1000);
1534 val->val2 = (int32_t)(milli % 1000) * 1000;
1535
1536 return 0;
1537}
1538
1546static inline int sensor_value_from_micro(struct sensor_value *val, int64_t micro)
1547{
1548 if (micro < ((int64_t)INT32_MIN - 1) * 1000000LL ||
1549 micro > ((int64_t)INT32_MAX + 1) * 1000000LL) {
1550 return -ERANGE;
1551 }
1552
1553 val->val1 = (int32_t)(micro / 1000000LL);
1554 val->val2 = (int32_t)(micro % 1000000LL);
1555
1556 return 0;
1557}
1558
1568#define SENSOR_DECODER_NAME() UTIL_CAT(DT_DRV_COMPAT, __decoder_api)
1569
1577#define SENSOR_DECODER_DT_GET(node_id) \
1578 &UTIL_CAT(DT_STRING_TOKEN_BY_IDX(node_id, compatible, 0), __decoder_api)
1579
1595#define SENSOR_DECODER_API_DT_DEFINE() \
1596 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), (), (static)) \
1597 const STRUCT_SECTION_ITERABLE(sensor_decoder_api, SENSOR_DECODER_NAME())
1598
1599#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX(node_id, prop, idx) \
1600 extern const struct sensor_decoder_api UTIL_CAT( \
1601 DT_STRING_TOKEN_BY_IDX(node_id, prop, idx), __decoder_api);
1602
1603#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL(node_id) \
1604 COND_CODE_1(DT_NODE_HAS_PROP(node_id, compatible), \
1605 (DT_FOREACH_PROP_ELEM(node_id, compatible, \
1606 Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX)), \
1607 ())
1608
1609DT_FOREACH_STATUS_OKAY_NODE(Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL)
1610
1611#ifdef __cplusplus
1612}
1613#endif
1614
1615#include <zephyr/syscalls/sensor.h>
1616
1617#endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_ */
irp nz macro MOVR cc d
Definition asm-macro-32-bit-gnu.h:11
System error numbers.
#define DT_FOREACH_STATUS_OKAY_NODE(fn)
Invokes fn for every status okay node in the tree.
Definition devicetree.h:3000
#define RTIO_PRIO_NORM
Normal priority.
Definition rtio.h:71
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:623
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:1563
int rtio_sqe_copy_in_get_handles(struct rtio *r, const struct rtio_sqe *sqes, struct rtio_sqe **handle, size_t sqe_count)
Copy an array of SQEs into the queue and get resulting handles back.
static void rtio_sqe_prep_read(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, uint8_t *buf, uint32_t len, void *userdata)
Prepare a read op submission.
Definition rtio.h:602
static struct rtio_sqe * rtio_sqe_acquire(struct rtio *r)
Acquire a single submission queue event if available.
Definition rtio.h:1054
static void rtio_sqe_prep_read_multishot(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Definition rtio.h:631
static void rtio_cqe_release(struct rtio *r, struct rtio_cqe *cqe)
Release consumed completion queue event.
Definition rtio.h:1173
static struct rtio_cqe * rtio_cqe_consume_block(struct rtio *r)
Wait for and consume a single completion queue event.
Definition rtio.h:1149
int rtio_submit(struct rtio *r, uint32_t wait_count)
Submit I/O requests to the underlying executor.
#define SENSOR_G
The value of gravitational constant in micro m/s^2.
Definition sensor.h:1177
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:407
static int sensor_decode(struct sensor_decode_context *ctx, void *out, uint16_t max_count)
Decode N frames using a sensor_decode_context.
Definition sensor.h:595
static int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
Helper function for converting radians to degrees.
Definition sensor.h:1268
sensor_trigger_type
Sensor trigger types.
Definition sensor.h:228
sensor_attribute
Sensor attribute types.
Definition sensor.h:309
int sensor_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder)
Get the sensor's decoder API.
static int sensor_read(struct rtio_iodev *iodev, struct rtio *ctx, uint8_t *buf, size_t buf_len)
Blocking one shot read of samples from a sensor into a buffer.
Definition sensor.h:1083
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:609
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:1255
static double sensor_value_to_double(const struct sensor_value *val)
Helper function for converting struct sensor_value to double.
Definition sensor.h:1327
static float sensor_value_to_float(const struct sensor_value *val)
Helper function for converting struct sensor_value to float.
Definition sensor.h:1338
int sensor_natively_supported_channel_size_info(struct sensor_chan_spec channel, size_t *base_size, size_t *frame_size)
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:396
static void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
Helper function for converting degrees to radians.
Definition sensor.h:1285
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:1242
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:435
static int sensor_value_from_float(struct sensor_value *val, float inp)
Helper function for converting float to struct sensor_value.
Definition sensor.h:1375
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:1209
static int64_t sensor_value_to_milli(const struct sensor_value *val)
Helper function for converting struct sensor_value to integer milli units.
Definition sensor.h:1503
#define SENSOR_PI
The value of constant PI in micros.
Definition sensor.h:1182
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:810
sensor_stream_data_opt
Options for what to do with the associated data when a trigger is consumed.
Definition sensor.h:615
static int sensor_value_from_milli(struct sensor_value *val, int64_t milli)
Helper function for converting integer milli units to struct sensor_value.
Definition sensor.h:1526
void(* sensor_trigger_handler_t)(const struct device *dev, const struct sensor_trigger *trigger)
Callback API upon firing of a trigger.
Definition sensor.h:387
static int64_t sensor_value_to_micro(const struct sensor_value *val)
Helper function for converting struct sensor_value to integer micro units.
Definition sensor.h:1514
int sensor_channel_get(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Get a reading from a sensor device.
static int32_t sensor_ms2_to_mg(const struct sensor_value *ms2)
Helper function to convert acceleration from m/s^2 to milli Gs.
Definition sensor.h:1223
int sensor_sample_fetch(const struct device *dev)
Fetch a sample from the sensor and store it in an internal driver buffer.
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:1156
sensor_channel
Sensor channels.
Definition sensor.h:61
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:1315
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:1192
int sensor_reconfigure_read_iodev(struct rtio_iodev *iodev, const struct device *sensor, const struct sensor_chan_spec *channels, size_t num_channels)
Reconfigure a reading iodev.
static int sensor_read_async_mempool(struct rtio_iodev *iodev, struct rtio *ctx, void *userdata)
One shot non-blocking read with pool allocated buffer.
Definition sensor.h:1125
void sensor_processing_with_callback(struct rtio *ctx, sensor_processing_callback_t cb)
Helper function for common processing of sensor data.
static int64_t sensor_value_to_deci(const struct sensor_value *val)
Helper function for converting struct sensor_value to integer deci units.
Definition sensor.h:1481
static int sensor_value_from_micro(struct sensor_value *val, int64_t micro)
Helper function for converting integer micro units to struct sensor_value.
Definition sensor.h:1546
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 int sensor_stream(struct rtio_iodev *iodev, struct rtio *ctx, void *userdata, struct rtio_sqe **handle)
Definition sensor.h:1046
int(* sensor_sample_fetch_t)(const struct device *dev, enum sensor_channel chan)
Callback API for fetching data from a sensor.
Definition sensor.h:427
void(* sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe)
Definition sensor.h:706
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:418
static int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
Helper function for converting radians to 10 micro degrees.
Definition sensor.h:1302
static int64_t sensor_value_to_centi(const struct sensor_value *val)
Helper function for converting struct sensor_value to integer centi units.
Definition sensor.h:1492
static bool sensor_chan_spec_eq(struct sensor_chan_spec chan_spec0, struct sensor_chan_spec chan_spec1)
Check if channel specs are equivalent.
Definition sensor.h:466
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:1350
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
Trigger fires when the selected channel varies significantly.
Definition sensor.h:244
@ SENSOR_TRIG_NEAR_FAR
Trigger fires when a near/far event is detected.
Definition sensor.h:246
@ SENSOR_TRIG_FREEFALL
Trigger fires when a free fall is detected.
Definition sensor.h:262
@ SENSOR_TRIG_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:288
@ SENSOR_TRIG_FIFO_FULL
Trigger fires when the FIFO becomes full.
Definition sensor.h:274
@ SENSOR_TRIG_MOTION
Trigger fires when motion is detected.
Definition sensor.h:265
@ SENSOR_TRIG_STATIONARY
Trigger fires when no motion has been detected for a while.
Definition sensor.h:268
@ SENSOR_TRIG_COMMON_COUNT
Number of all common sensor triggers.
Definition sensor.h:282
@ SENSOR_TRIG_THRESHOLD
Trigger fires when channel reading transitions configured thresholds.
Definition sensor.h:253
@ SENSOR_TRIG_MAX
Maximum value describing a sensor trigger type.
Definition sensor.h:293
@ SENSOR_TRIG_DOUBLE_TAP
Trigger fires when a double tap is detected.
Definition sensor.h:259
@ SENSOR_TRIG_TILT
Trigger fires when a tilt is detected.
Definition sensor.h:277
@ SENSOR_TRIG_TIMER
Timer-based trigger, useful when the sensor does not have an interrupt line.
Definition sensor.h:233
@ SENSOR_TRIG_FIFO_WATERMARK
Trigger fires when the FIFO watermark has been reached.
Definition sensor.h:271
@ SENSOR_TRIG_TAP
Trigger fires when a single tap is detected.
Definition sensor.h:256
@ SENSOR_TRIG_DATA_READY
Trigger fires whenever new data is ready.
Definition sensor.h:235
@ SENSOR_ATTR_HYSTERESIS
Definition sensor.h:327
@ SENSOR_ATTR_FEATURE_MASK
Enable/disable sensor features.
Definition sensor.h:347
@ SENSOR_ATTR_CALIB_TARGET
Calibration target.
Definition sensor.h:341
@ SENSOR_ATTR_OFFSET
The sensor value returned will be altered by the amount indicated by offset: final_value = sensor_val...
Definition sensor.h:336
@ SENSOR_ATTR_BATCH_DURATION
Hardware batch duration in ticks.
Definition sensor.h:358
@ SENSOR_ATTR_OVERSAMPLING
Oversampling factor.
Definition sensor.h:329
@ SENSOR_ATTR_FF_DUR
Free-fall duration represented in milliseconds.
Definition sensor.h:355
@ SENSOR_ATTR_UPPER_THRESH
Upper threshold for trigger.
Definition sensor.h:318
@ SENSOR_ATTR_CONFIGURATION
Configure the operating modes of a sensor.
Definition sensor.h:343
@ SENSOR_ATTR_RESOLUTION
Definition sensor.h:362
@ SENSOR_ATTR_CALIBRATION
Set a calibration value needed by a sensor.
Definition sensor.h:345
@ SENSOR_ATTR_COMMON_COUNT
Number of all common sensor attributes.
Definition sensor.h:366
@ SENSOR_ATTR_ALERT
Alert threshold or alert enable/disable.
Definition sensor.h:349
@ SENSOR_ATTR_SLOPE_TH
Threshold for any-motion (slope) trigger.
Definition sensor.h:320
@ SENSOR_ATTR_GAIN
Definition sensor.h:360
@ SENSOR_ATTR_SAMPLING_FREQUENCY
Sensor sampling frequency, i.e.
Definition sensor.h:314
@ SENSOR_ATTR_FULL_SCALE
Sensor range, in SI units.
Definition sensor.h:331
@ SENSOR_ATTR_LOWER_THRESH
Lower threshold for trigger.
Definition sensor.h:316
@ SENSOR_ATTR_SLOPE_DUR
Duration for which the slope values needs to be outside the threshold for the trigger to fire.
Definition sensor.h:325
@ SENSOR_ATTR_MAX
Maximum value describing a sensor attribute type.
Definition sensor.h:377
@ SENSOR_ATTR_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:372
@ SENSOR_STREAM_DATA_INCLUDE
Include whatever data is associated with the trigger.
Definition sensor.h:617
@ SENSOR_STREAM_DATA_NOP
Do nothing with the associated trigger data, it may be consumed later.
Definition sensor.h:619
@ SENSOR_STREAM_DATA_DROP
Flush/clear whatever data is associated with the trigger.
Definition sensor.h:621
@ SENSOR_CHAN_GAUGE_STATE_OF_HEALTH
State of health measurement in %.
Definition sensor.h:185
@ SENSOR_CHAN_PM_1_0
1.0 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:113
@ SENSOR_CHAN_DIE_TEMP
Device die temperature in degrees Celsius.
Definition sensor.h:87
@ SENSOR_CHAN_PRESS
Pressure in kilopascal.
Definition sensor.h:91
@ SENSOR_CHAN_GAUGE_TIME_TO_FULL
Time to full in minutes.
Definition sensor.h:189
@ SENSOR_CHAN_ACCEL_XYZ
Acceleration on the X, Y and Z axes.
Definition sensor.h:69
@ SENSOR_CHAN_MAGN_X
Magnetic field on the X axis, in Gauss.
Definition sensor.h:79
@ SENSOR_CHAN_O2
O2 level, in parts per million (ppm)
Definition sensor.h:124
@ SENSOR_CHAN_CURRENT
Current, in amps.
Definition sensor.h:137
@ SENSOR_CHAN_GYRO_XYZ
Angular velocity around the X, Y and Z axes.
Definition sensor.h:77
@ SENSOR_CHAN_VSHUNT
Current Shunt Voltage in milli-volts.
Definition sensor.h:134
@ SENSOR_CHAN_GREEN
Illuminance in green spectrum, in lux.
Definition sensor.h:106
@ SENSOR_CHAN_GRAVITY_VECTOR
Gravity Vector (X/Y/Z components in m/s^2)
Definition sensor.h:201
@ SENSOR_CHAN_MAGN_Z
Magnetic field on the Z axis, in Gauss.
Definition sensor.h:83
@ SENSOR_CHAN_MAGN_Y
Magnetic field on the Y axis, in Gauss.
Definition sensor.h:81
@ SENSOR_CHAN_GAUGE_DESIRED_VOLTAGE
Desired voltage of cell in V (nominal voltage)
Definition sensor.h:195
@ SENSOR_CHAN_POWER
Power in watts.
Definition sensor.h:139
@ SENSOR_CHAN_PM_2_5
2.5 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:115
@ SENSOR_CHAN_RESISTANCE
Resistance , in Ohm.
Definition sensor.h:142
@ SENSOR_CHAN_GAME_ROTATION_VECTOR
Game Rotation Vector (unit quaternion components X/Y/Z/W)
Definition sensor.h:199
@ SENSOR_CHAN_GAUGE_AVG_CURRENT
Average current, in amps (negative=discharging)
Definition sensor.h:165
@ SENSOR_CHAN_GYRO_Y
Angular velocity around the Y axis, in radians/s.
Definition sensor.h:73
@ SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT
Desired charging current in mA.
Definition sensor.h:197
@ SENSOR_CHAN_FREQUENCY
Frequency, in Hz.
Definition sensor.h:160
@ SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY
Full Charge Capacity in mAh.
Definition sensor.h:175
@ SENSOR_CHAN_ROTATION
Angular rotation, in degrees.
Definition sensor.h:145
@ SENSOR_CHAN_AMBIENT_TEMP
Ambient temperature in degrees Celsius.
Definition sensor.h:89
@ SENSOR_CHAN_MAGN_XYZ
Magnetic field on the X, Y and Z axes.
Definition sensor.h:85
@ SENSOR_CHAN_GAUGE_STDBY_CURRENT
Standby current, in amps (negative=discharging)
Definition sensor.h:167
@ SENSOR_CHAN_GAUGE_MAX_LOAD_CURRENT
Max load current, in amps (negative=discharging)
Definition sensor.h:169
@ SENSOR_CHAN_ACCEL_Y
Acceleration on the Y axis, in m/s^2.
Definition sensor.h:65
@ SENSOR_CHAN_RPM
Revolutions per minute, in RPM.
Definition sensor.h:157
@ SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY
Full Available Capacity in mAh.
Definition sensor.h:181
@ SENSOR_CHAN_VOLTAGE
Voltage, in volts.
Definition sensor.h:131
@ SENSOR_CHAN_BLUE
Illuminance in blue spectrum, in lux.
Definition sensor.h:108
@ SENSOR_CHAN_LIGHT
Illuminance in visible spectrum, in lux.
Definition sensor.h:100
@ SENSOR_CHAN_GAUGE_DESIGN_VOLTAGE
Design voltage of cell in V (max voltage)
Definition sensor.h:193
@ SENSOR_CHAN_ACCEL_Z
Acceleration on the Z axis, in m/s^2.
Definition sensor.h:67
@ SENSOR_CHAN_CO2
CO2 level, in parts per million (ppm)
Definition sensor.h:122
@ SENSOR_CHAN_GAUGE_STATE_OF_CHARGE
State of charge measurement in %.
Definition sensor.h:173
@ SENSOR_CHAN_POS_DXYZ
Position change on the X, Y and Z axis, in points.
Definition sensor.h:154
@ SENSOR_CHAN_GBIAS_XYZ
Gyroscope bias (X/Y/Z components in radians/s)
Definition sensor.h:203
@ SENSOR_CHAN_GAUGE_CYCLE_COUNT
Cycle count (total number of charge/discharge cycles)
Definition sensor.h:191
@ SENSOR_CHAN_GAUGE_TEMP
Gauge temperature
Definition sensor.h:171
@ SENSOR_CHAN_POS_DY
Position change on the Y axis, in points.
Definition sensor.h:150
@ SENSOR_CHAN_GYRO_Z
Angular velocity around the Z axis, in radians/s.
Definition sensor.h:75
@ SENSOR_CHAN_POS_DX
Position change on the X axis, in points.
Definition sensor.h:148
@ SENSOR_CHAN_GAUGE_AVG_POWER
Average power in mW.
Definition sensor.h:183
@ SENSOR_CHAN_GAUGE_TIME_TO_EMPTY
Time to empty in minutes.
Definition sensor.h:187
@ SENSOR_CHAN_PM_10
10 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:117
@ SENSOR_CHAN_GAUGE_REMAINING_CHARGE_CAPACITY
Remaining Charge Capacity in mAh.
Definition sensor.h:177
@ SENSOR_CHAN_ALL
All channels.
Definition sensor.h:206
@ SENSOR_CHAN_GAUGE_VOLTAGE
Voltage, in volts.
Definition sensor.h:163
@ SENSOR_CHAN_PROX
Proximity.
Definition sensor.h:96
@ SENSOR_CHAN_COMMON_COUNT
Number of all common sensor channels.
Definition sensor.h:211
@ SENSOR_CHAN_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:217
@ SENSOR_CHAN_GYRO_X
Angular velocity around the X axis, in radians/s.
Definition sensor.h:71
@ SENSOR_CHAN_GAS_RES
Gas sensor resistance in ohms.
Definition sensor.h:128
@ SENSOR_CHAN_HUMIDITY
Humidity, in percent.
Definition sensor.h:98
@ SENSOR_CHAN_DISTANCE
Distance.
Definition sensor.h:119
@ SENSOR_CHAN_IR
Illuminance in infra-red spectrum, in lux.
Definition sensor.h:102
@ SENSOR_CHAN_MAX
Maximum value describing a sensor channel type.
Definition sensor.h:222
@ SENSOR_CHAN_POS_DZ
Position change on the Z axis, in points.
Definition sensor.h:152
@ SENSOR_CHAN_RED
Illuminance in red spectrum, in lux.
Definition sensor.h:104
@ SENSOR_CHAN_ALTITUDE
Altitude, in meters.
Definition sensor.h:110
@ SENSOR_CHAN_GAUGE_NOM_AVAIL_CAPACITY
Nominal Available Capacity in mAh.
Definition sensor.h:179
@ SENSOR_CHAN_ACCEL_X
Acceleration on the X axis, in m/s^2.
Definition sensor.h:63
@ SENSOR_CHAN_VOC
VOC level, in parts per billion (ppb)
Definition sensor.h:126
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:148
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define ENOMEM
Not enough core.
Definition errno.h:50
#define ERANGE
Result too large.
Definition errno.h:72
#define NULL
Definition iar_missing_defs.h:20
Size of off_t must be equal or less than size of size_t
Definition retained_mem.h:28
Real-Time IO device API for moving bytes with low effort.
#define bool
Definition stdbool.h:13
__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
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
#define INT32_MIN
Definition stdint.h:24
#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:510
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516
A completion queue event.
Definition rtio.h:385
void * userdata
Associated userdata with operation.
Definition rtio.h:389
int32_t result
Result from operation.
Definition rtio.h:388
API that an RTIO IO device should implement.
Definition rtio.h:524
Compute the mempool block index for a given pointer.
Definition rtio.h:514
struct rtio_sqe sqe
Definition rtio.h:515
An IO device with a function table for submitting requests.
Definition rtio.h:539
void * data
Definition rtio.h:544
A submission queue event.
Definition rtio.h:295
void * userdata
User provided data which is returned upon operation completion.
Definition rtio.h:313
uint32_t buf_len
Length of buffer.
Definition rtio.h:319
const struct rtio_iodev * iodev
Device to operation on.
Definition rtio.h:304
const uint8_t * buf
Buffer to write from.
Definition rtio.h:320
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:418
Sensor Channel Specification.
Definition sensor.h:447
uint16_t chan_idx
A sensor channel index.
Definition sensor.h:449
uint16_t chan_type
A sensor channel type.
Definition sensor.h:448
Definition sensor.h:925
uint64_t timestamp_ns
Definition sensor.h:927
int8_t shift
Definition sensor.h:936
uint32_t num_channels
Definition sensor.h:933
Used for iterating over the data frames via the sensor_decoder_api.
Definition sensor.h:569
const struct sensor_decoder_api * decoder
Definition sensor.h:570
struct sensor_chan_spec channel
Definition sensor.h:572
const uint8_t * buffer
Definition sensor.h:571
uint32_t fit
Definition sensor.h:573
Decodes a single raw data buffer.
Definition sensor.h:479
int(* get_size_info)(struct sensor_chan_spec channel, size_t *base_size, size_t *frame_size)
Get the size required to decode a given channel.
Definition sensor.h:504
int(* get_frame_count)(const uint8_t *buffer, struct sensor_chan_spec channel, uint16_t *frame_count)
Get the number of frames in the current buffer.
Definition sensor.h:489
int(* decode)(const uint8_t *buffer, struct sensor_chan_spec channel, uint32_t *fit, uint16_t max_count, void *data_out)
Decode up to max_count samples from the buffer.
Definition sensor.h:532
bool(* has_trigger)(const uint8_t *buffer, enum sensor_trigger_type trigger)
Check if the given trigger type is present.
Definition sensor.h:542
Definition sensor.h:714
sensor_get_decoder_t get_decoder
Definition sensor.h:720
sensor_attr_set_t attr_set
Definition sensor.h:715
sensor_attr_get_t attr_get
Definition sensor.h:716
sensor_trigger_set_t trigger_set
Definition sensor.h:717
sensor_sample_fetch_t sample_fetch
Definition sensor.h:718
sensor_channel_get_t channel_get
Definition sensor.h:719
sensor_submit_t submit
Definition sensor.h:721
Definition sensor.h:638
struct sensor_chan_spec *const channels
Definition sensor.h:642
size_t count
Definition sensor.h:645
struct sensor_stream_trigger *const triggers
Definition sensor.h:643
const bool is_streaming
Definition sensor.h:640
const struct device * sensor
Definition sensor.h:639
const size_t max
Definition sensor.h:646
Definition sensor.h:624
enum sensor_stream_data_opt opt
Definition sensor.h:626
enum sensor_trigger_type trigger
Definition sensor.h:625
Sensor trigger spec.
Definition sensor.h:299
enum sensor_trigger_type type
Trigger type.
Definition sensor.h:301
enum sensor_channel chan
Channel the trigger is set on.
Definition sensor.h:303
Representation of a sensor readout value.
Definition sensor.h:51
int32_t val2
Fractional part of the value (in one-millionth parts).
Definition sensor.h:55
int32_t val1
Integer part of the value.
Definition sensor.h:53
#define INT64_C(x)
Definition xcc.h:119