Zephyr API Documentation 4.4.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
sensor.h
Go to the documentation of this file.
1/*
2* Copyright (c) 2016 Intel Corporation
3*
4* SPDX-License-Identifier: Apache-2.0
5*/
6#ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
7#define ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_
8
14
27
28#include <errno.h>
29#include <stdlib.h>
30
31#include <zephyr/device.h>
33#include <zephyr/dsp/types.h>
34#include <zephyr/rtio/rtio.h>
36#include <zephyr/types.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
61
117
142
145
156
159
162
167
170
173
182
185
188
231
234
237
242
248
253};
254
328
338
414
421typedef void (*sensor_trigger_handler_t)(const struct device *dev,
422 const struct sensor_trigger *trigger);
423
428
433typedef int (*sensor_attr_set_t)(const struct device *dev,
434 enum sensor_channel chan,
435 enum sensor_attribute attr,
436 const struct sensor_value *val);
437
442typedef int (*sensor_attr_get_t)(const struct device *dev,
443 enum sensor_channel chan,
444 enum sensor_attribute attr,
445 struct sensor_value *val);
446
451typedef int (*sensor_trigger_set_t)(const struct device *dev,
452 const struct sensor_trigger *trig,
454
459typedef int (*sensor_sample_fetch_t)(const struct device *dev,
460 enum sensor_channel chan);
461
466typedef int (*sensor_channel_get_t)(const struct device *dev,
467 enum sensor_channel chan,
468 struct sensor_value *val);
469
470/* Forward declaration */
471struct sensor_decoder_api;
472
477typedef int (*sensor_get_decoder_t)(const struct device *dev,
478 const struct sensor_decoder_api **api);
479
488typedef void (*sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe);
489
523
526
539
541/* Ensure sensor_chan_spec is sensibly sized to pass by value */
542BUILD_ASSERT(sizeof(struct sensor_chan_spec) <= sizeof(uintptr_t),
543 "sensor_chan_spec size should be equal or less than the size of a machine word");
545
554static inline bool sensor_chan_spec_eq(struct sensor_chan_spec chan_spec0,
555 struct sensor_chan_spec chan_spec1)
556{
557 return chan_spec0.chan_type == chan_spec1.chan_type &&
558 chan_spec0.chan_idx == chan_spec1.chan_idx;
559}
560
578 int (*get_frame_count)(const uint8_t *buffer, struct sensor_chan_spec chan_spec,
579 uint16_t *frame_count);
580
593 int (*get_size_info)(struct sensor_chan_spec channel, size_t *base_size,
594 size_t *frame_size);
595
620 int (*decode)(const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint32_t *fit,
621 uint16_t max_count, void *data_out);
622
630 bool (*has_trigger)(const uint8_t *buffer, enum sensor_trigger_type trigger);
631};
632
663
667#define SENSOR_DECODE_CONTEXT_INIT(decoder_, buffer_, channel_type_, channel_index_) \
668 { \
669 .decoder = (decoder_), \
670 .buffer = (buffer_), \
671 .channel = {.chan_type = (channel_type_), .chan_idx = (channel_index_)}, \
672 .fit = 0, \
673 }
674
683static inline int sensor_decode(struct sensor_decode_context *ctx, void *out, uint16_t max_count)
684{
685 return ctx->decoder->decode(ctx->buffer, ctx->channel, &ctx->fit, max_count, out);
686}
687
689 size_t *frame_size);
690
702
707
708#define SENSOR_STREAM_TRIGGER_PREP(_trigger, _opt) \
709 { \
710 .trigger = (_trigger), .opt = (_opt), \
711 }
712
713/*
714 * Internal data structure used to store information about the IODevice for async reading and
715 * streaming sensor data.
716 */
718 const struct device *sensor;
719 const bool is_streaming;
720 union {
723 };
724 size_t count;
725 const size_t max;
726};
727
743#define SENSOR_DT_READ_IODEV(name, dt_node, ...) \
744 static struct sensor_chan_spec _CONCAT(__channel_array_, name)[] = {__VA_ARGS__}; \
745 static struct sensor_read_config _CONCAT(__sensor_read_config_, name) = { \
746 .sensor = DEVICE_DT_GET(dt_node), \
747 .is_streaming = false, \
748 .channels = _CONCAT(__channel_array_, name), \
749 .count = ARRAY_SIZE(_CONCAT(__channel_array_, name)), \
750 .max = ARRAY_SIZE(_CONCAT(__channel_array_, name)), \
751 }; \
752 RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, _CONCAT(&__sensor_read_config_, name))
753
773#define SENSOR_DT_STREAM_IODEV(name, dt_node, ...) \
774 static struct sensor_stream_trigger _CONCAT(__trigger_array_, name)[] = {__VA_ARGS__}; \
775 static struct sensor_read_config _CONCAT(__sensor_read_config_, name) = { \
776 .sensor = DEVICE_DT_GET(dt_node), \
777 .is_streaming = true, \
778 .triggers = _CONCAT(__trigger_array_, name), \
779 .count = ARRAY_SIZE(_CONCAT(__trigger_array_, name)), \
780 .max = ARRAY_SIZE(_CONCAT(__trigger_array_, name)), \
781 }; \
782 RTIO_IODEV_DEFINE(name, &__sensor_iodev_api, &_CONCAT(__sensor_read_config_, name))
783
784/* The default decoder API */
785extern const struct sensor_decoder_api __sensor_default_decoder;
786
787/* The default sensor iodev API */
788extern const struct rtio_iodev_api __sensor_iodev_api;
789
802__syscall int sensor_attr_set(const struct device *dev,
803 enum sensor_channel chan,
804 enum sensor_attribute attr,
805 const struct sensor_value *val);
806
807static inline int z_impl_sensor_attr_set(const struct device *dev,
808 enum sensor_channel chan,
809 enum sensor_attribute attr,
810 const struct sensor_value *val)
811{
812 const struct sensor_driver_api *api = DEVICE_API_GET(sensor, dev);
813
814 if (api->attr_set == NULL) {
815 return -ENOSYS;
816 }
817
818 return api->attr_set(dev, chan, attr, val);
819}
820
833__syscall int sensor_attr_get(const struct device *dev,
834 enum sensor_channel chan,
835 enum sensor_attribute attr,
836 struct sensor_value *val);
837
838static inline int z_impl_sensor_attr_get(const struct device *dev,
839 enum sensor_channel chan,
840 enum sensor_attribute attr,
841 struct sensor_value *val)
842{
843 const struct sensor_driver_api *api = DEVICE_API_GET(sensor, dev);
844
845 if (api->attr_get == NULL) {
846 return -ENOSYS;
847 }
848
849 return api->attr_get(dev, chan, attr, val);
850}
851
874static inline int sensor_trigger_set(const struct device *dev,
875 const struct sensor_trigger *trig,
877{
878 const struct sensor_driver_api *api = DEVICE_API_GET(sensor, dev);
879
880 if (api->trigger_set == NULL) {
881 return -ENOSYS;
882 }
883
884 return api->trigger_set(dev, trig, handler);
885}
886
905__syscall int sensor_sample_fetch(const struct device *dev);
906
907static inline int z_impl_sensor_sample_fetch(const struct device *dev)
908{
909 return DEVICE_API_GET(sensor, dev)->sample_fetch(dev, SENSOR_CHAN_ALL);
910}
911
933__syscall int sensor_sample_fetch_chan(const struct device *dev,
934 enum sensor_channel type);
935
936static inline int z_impl_sensor_sample_fetch_chan(const struct device *dev,
937 enum sensor_channel type)
938{
939 return DEVICE_API_GET(sensor, dev)->sample_fetch(dev, type);
940}
941
963__syscall int sensor_channel_get(const struct device *dev,
964 enum sensor_channel chan,
965 struct sensor_value *val);
966
967static inline int z_impl_sensor_channel_get(const struct device *dev,
968 enum sensor_channel chan,
969 struct sensor_value *val)
970{
971 return DEVICE_API_GET(sensor, dev)->channel_get(dev, chan, val);
972}
973
974#if defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__)
975
976/*
977 * Generic data structure used for encoding the sample timestamp and number of channels sampled.
978 */
979struct __attribute__((__packed__)) sensor_data_generic_header {
982
983 /*
984 ** The number of channels present in the frame.
985 * This will be the true number of elements in channel_info and in the q31 values that
986 * follow the header.
987 */
989
992
993 /* This padding is needed to make sure that the 'channels' field is aligned */
994 int8_t _padding[sizeof(struct sensor_chan_spec) - 1];
995
998};
999
1008#define SENSOR_CHANNEL_3_AXIS(chan) \
1009 ((chan) == SENSOR_CHAN_ACCEL_XYZ || (chan) == SENSOR_CHAN_GYRO_XYZ || \
1010 (chan) == SENSOR_CHAN_MAGN_XYZ || (chan) == SENSOR_CHAN_POS_DXYZ)
1011
1020#define SENSOR_CHANNEL_IS_ACCEL(chan) \
1021 ((chan) == SENSOR_CHAN_ACCEL_XYZ || (chan) == SENSOR_CHAN_ACCEL_X || \
1022 (chan) == SENSOR_CHAN_ACCEL_Y || (chan) == SENSOR_CHAN_ACCEL_Z)
1023
1032#define SENSOR_CHANNEL_IS_GYRO(chan) \
1033 ((chan) == SENSOR_CHAN_GYRO_XYZ || (chan) == SENSOR_CHAN_GYRO_X || \
1034 (chan) == SENSOR_CHAN_GYRO_Y || (chan) == SENSOR_CHAN_GYRO_Z)
1035
1044__syscall int sensor_get_decoder(const struct device *dev,
1045 const struct sensor_decoder_api **decoder);
1046
1047static inline int z_impl_sensor_get_decoder(const struct device *dev,
1048 const struct sensor_decoder_api **decoder)
1049{
1050 const struct sensor_driver_api *api = DEVICE_API_GET(sensor, dev);
1051
1052 __ASSERT_NO_MSG(api != NULL);
1053
1054 if (api->get_decoder == NULL) {
1055 *decoder = &__sensor_default_decoder;
1056 return 0;
1057 }
1058
1059 return api->get_decoder(dev, decoder);
1060}
1061
1080__syscall int sensor_reconfigure_read_iodev(const struct rtio_iodev *iodev,
1081 const struct device *sensor,
1082 const struct sensor_chan_spec *channels,
1083 size_t num_channels);
1084
1085static inline int z_impl_sensor_reconfigure_read_iodev(const struct rtio_iodev *iodev,
1086 const struct device *sensor,
1087 const struct sensor_chan_spec *channels,
1088 size_t num_channels)
1089{
1090 struct sensor_read_config *cfg = (struct sensor_read_config *)iodev->data;
1091
1092 if (cfg->max < num_channels || cfg->is_streaming) {
1093 return -ENOMEM;
1094 }
1095
1096 cfg->sensor = sensor;
1097 memcpy(cfg->channels, channels, num_channels * sizeof(struct sensor_chan_spec));
1098 cfg->count = num_channels;
1099 return 0;
1100}
1101
1102static inline int sensor_stream(const struct rtio_iodev *iodev, struct rtio *ctx, void *userdata,
1103 struct rtio_sqe **handle)
1104{
1105 if (IS_ENABLED(CONFIG_USERSPACE)) {
1106 struct rtio_sqe sqe;
1107
1109 rtio_sqe_copy_in_get_handles(ctx, &sqe, handle, 1);
1110 } else {
1111 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1112
1113 if (sqe == NULL) {
1114 return -ENOMEM;
1115 }
1116 if (handle != NULL) {
1117 *handle = sqe;
1118 }
1120 }
1121 rtio_submit(ctx, 0);
1122 return 0;
1123}
1124
1139static inline int sensor_read(const struct rtio_iodev *iodev, struct rtio *ctx, uint8_t *buf,
1140 size_t buf_len)
1141{
1142 if (IS_ENABLED(CONFIG_USERSPACE)) {
1143 struct rtio_sqe sqe;
1144
1146 rtio_sqe_copy_in(ctx, &sqe, 1);
1147 } else {
1148 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1149
1150 if (sqe == NULL) {
1151 return -ENOMEM;
1152 }
1154 }
1155 rtio_submit(ctx, 0);
1156
1157 struct rtio_cqe *cqe = rtio_cqe_consume_block(ctx);
1158 int res = cqe->result;
1159
1160 __ASSERT(cqe->userdata == buf,
1161 "consumed non-matching completion for sensor read into buffer %p\n", buf);
1162
1163 rtio_cqe_release(ctx, cqe);
1164
1165 return res;
1166}
1167
1181static inline int sensor_read_async_mempool(const struct rtio_iodev *iodev, struct rtio *ctx,
1182 void *userdata)
1183{
1184 if (IS_ENABLED(CONFIG_USERSPACE)) {
1185 struct rtio_sqe sqe;
1186
1188 rtio_sqe_copy_in(ctx, &sqe, 1);
1189 } else {
1190 struct rtio_sqe *sqe = rtio_sqe_acquire(ctx);
1191
1192 if (sqe == NULL) {
1193 return -ENOMEM;
1194 }
1196 }
1197 rtio_submit(ctx, 0);
1198 return 0;
1199}
1200
1212 void *userdata);
1213
1226
1227#endif /* defined(CONFIG_SENSOR_ASYNC_API) || defined(__DOXYGEN__) */
1228
1232#define SENSOR_G 9806650LL
1233
1237#define SENSOR_PI 3141592LL
1238
1247static inline int32_t sensor_ms2_to_g(const struct sensor_value *ms2)
1248{
1249 int64_t micro_ms2 = ms2->val1 * 1000000LL + ms2->val2;
1250
1251 if (micro_ms2 > 0) {
1252 return (micro_ms2 + SENSOR_G / 2) / SENSOR_G;
1253 } else {
1254 return (micro_ms2 - SENSOR_G / 2) / SENSOR_G;
1255 }
1256}
1257
1264static inline void sensor_g_to_ms2(int32_t g, struct sensor_value *ms2)
1265{
1266 ms2->val1 = ((int64_t)g * SENSOR_G) / 1000000LL;
1267 ms2->val2 = ((int64_t)g * SENSOR_G) % 1000000LL;
1268}
1269
1278static inline int32_t sensor_ms2_to_mg(const struct sensor_value *ms2)
1279{
1280 int64_t nano_ms2 = (ms2->val1 * 1000000LL + ms2->val2) * 1000LL;
1281
1282 if (nano_ms2 > 0) {
1283 return (nano_ms2 + SENSOR_G / 2) / SENSOR_G;
1284 } else {
1285 return (nano_ms2 - SENSOR_G / 2) / SENSOR_G;
1286 }
1287}
1288
1297static inline int32_t sensor_ms2_to_ug(const struct sensor_value *ms2)
1298{
1299 int64_t micro_ms2 = (ms2->val1 * INT64_C(1000000)) + ms2->val2;
1300
1301 return (micro_ms2 * 1000000LL) / SENSOR_G;
1302}
1303
1310static inline void sensor_ug_to_ms2(int32_t ug, struct sensor_value *ms2)
1311{
1312 ms2->val1 = ((int64_t)ug * SENSOR_G / 1000000LL) / 1000000LL;
1313 ms2->val2 = ((int64_t)ug * SENSOR_G / 1000000LL) % 1000000LL;
1314}
1315
1323static inline int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
1324{
1325 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1326
1327 if (micro_rad_s > 0) {
1328 return (micro_rad_s * 180LL + SENSOR_PI / 2) / SENSOR_PI;
1329 } else {
1330 return (micro_rad_s * 180LL - SENSOR_PI / 2) / SENSOR_PI;
1331 }
1332}
1333
1340static inline void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
1341{
1342 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL) / 1000000LL;
1343 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL) % 1000000LL;
1344}
1345
1357static inline int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
1358{
1359 int64_t micro_rad_s = rad->val1 * 1000000LL + rad->val2;
1360
1361 return (micro_rad_s * 180LL * 100000LL) / SENSOR_PI;
1362}
1363
1370static inline void sensor_10udegrees_to_rad(int32_t d, struct sensor_value *rad)
1371{
1372 rad->val1 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) / 1000000LL;
1373 rad->val2 = ((int64_t)d * SENSOR_PI / 180LL / 100000LL) % 1000000LL;
1374}
1375
1382static inline double sensor_value_to_double(const struct sensor_value *val)
1383{
1384 return (double)val->val1 + (double)val->val2 / 1000000;
1385}
1386
1393static inline float sensor_value_to_float(const struct sensor_value *val)
1394{
1395 return (float)val->val1 + (float)val->val2 / 1000000;
1396}
1397
1405static inline int sensor_value_from_double(struct sensor_value *val, double inp)
1406{
1407 if (inp < (double)INT32_MIN || inp > (double)INT32_MAX) {
1408 return -ERANGE;
1409 }
1410
1411 int32_t val1 = (int32_t)inp;
1412 int32_t val2 = (int32_t)((inp - (double)val1) * 1000000.0);
1413
1414 val->val1 = val1;
1415 val->val2 = val2;
1416
1417 return 0;
1418}
1419
1427static inline int sensor_value_from_float(struct sensor_value *val, float inp)
1428{
1429 if (inp < (float)INT32_MIN || inp >= (float)INT32_MAX) {
1430 return -ERANGE;
1431 }
1432
1433 int32_t val1 = (int32_t)inp;
1434 int32_t val2 = (int32_t)((inp - (float)val1) * 1000000.0f);
1435
1436 val->val1 = val1;
1437 val->val2 = val2;
1438
1439 return 0;
1440}
1441
1442#ifdef CONFIG_SENSOR_INFO
1443
1444struct sensor_info {
1445 const struct device *dev;
1446 const char *vendor;
1447 const char *model;
1448 const char *friendly_name;
1449};
1450
1451#define SENSOR_INFO_INITIALIZER(_dev, _vendor, _model, _friendly_name) \
1452 { \
1453 .dev = _dev, \
1454 .vendor = _vendor, \
1455 .model = _model, \
1456 .friendly_name = _friendly_name, \
1457 }
1458
1459#define SENSOR_INFO_DEFINE(name, ...) \
1460 static const STRUCT_SECTION_ITERABLE(sensor_info, name) = \
1461 SENSOR_INFO_INITIALIZER(__VA_ARGS__)
1462
1463#define SENSOR_INFO_DT_NAME(node_id) \
1464 _CONCAT(__sensor_info, DEVICE_DT_NAME_GET(node_id))
1465
1466#define SENSOR_INFO_DT_DEFINE(node_id) \
1467 SENSOR_INFO_DEFINE(SENSOR_INFO_DT_NAME(node_id), \
1468 DEVICE_DT_GET(node_id), \
1469 DT_NODE_VENDOR_OR(node_id, NULL), \
1470 DT_NODE_MODEL_OR(node_id, NULL), \
1471 DT_PROP_OR(node_id, friendly_name, NULL)) \
1472
1473#else
1474
1475#define SENSOR_INFO_DEFINE(name, ...)
1476#define SENSOR_INFO_DT_DEFINE(node_id)
1477
1478#endif /* CONFIG_SENSOR_INFO */
1479
1507#define SENSOR_DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1508 data_ptr, cfg_ptr, level, prio, \
1509 api_ptr, ...) \
1510 DEVICE_DT_DEFINE(node_id, init_fn, pm_device, \
1511 data_ptr, cfg_ptr, level, prio, \
1512 api_ptr, __VA_ARGS__); \
1513 \
1514 SENSOR_INFO_DT_DEFINE(node_id);
1515
1525#define SENSOR_DEVICE_DT_INST_DEFINE(inst, ...) \
1526 SENSOR_DEVICE_DT_DEFINE(DT_DRV_INST(inst), __VA_ARGS__)
1527
1534static inline int64_t sensor_value_to_deci(const struct sensor_value *val)
1535{
1536 return ((int64_t)val->val1 * 10) + val->val2 / 100000;
1537}
1538
1545static inline int64_t sensor_value_to_centi(const struct sensor_value *val)
1546{
1547 return ((int64_t)val->val1 * 100) + val->val2 / 10000;
1548}
1549
1556static inline int64_t sensor_value_to_milli(const struct sensor_value *val)
1557{
1558 return ((int64_t)val->val1 * 1000) + val->val2 / 1000;
1559}
1560
1567static inline int64_t sensor_value_to_micro(const struct sensor_value *val)
1568{
1569 return ((int64_t)val->val1 * 1000000) + val->val2;
1570}
1571
1579static inline int sensor_value_from_milli(struct sensor_value *val, int64_t milli)
1580{
1581 if (milli < ((int64_t)INT32_MIN - 1) * 1000LL ||
1582 milli > ((int64_t)INT32_MAX + 1) * 1000LL) {
1583 return -ERANGE;
1584 }
1585
1586 val->val1 = (int32_t)(milli / 1000);
1587 val->val2 = (int32_t)(milli % 1000) * 1000;
1588
1589 return 0;
1590}
1591
1599static inline int sensor_value_from_micro(struct sensor_value *val, int64_t micro)
1600{
1601 if (micro < ((int64_t)INT32_MIN - 1) * 1000000LL ||
1602 micro > ((int64_t)INT32_MAX + 1) * 1000000LL) {
1603 return -ERANGE;
1604 }
1605
1606 val->val1 = (int32_t)(micro / 1000000LL);
1607 val->val2 = (int32_t)(micro % 1000000LL);
1608
1609 return 0;
1610}
1611
1615
1621#define SENSOR_DECODER_NAME() UTIL_CAT(DT_DRV_COMPAT, __decoder_api)
1622
1630#define SENSOR_DECODER_DT_GET(node_id) \
1631 &UTIL_CAT(DT_STRING_TOKEN_BY_IDX(node_id, compatible, 0), __decoder_api)
1632
1648#define SENSOR_DECODER_API_DT_DEFINE() \
1649 COND_CODE_1(DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT), (), (static)) \
1650 const STRUCT_SECTION_ITERABLE(sensor_decoder_api, SENSOR_DECODER_NAME())
1651
1652#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX(node_id, prop, idx) \
1653 extern const struct sensor_decoder_api UTIL_CAT( \
1654 DT_STRING_TOKEN_BY_IDX(node_id, prop, idx), __decoder_api);
1655
1656#define Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL(node_id) \
1657 COND_CODE_1(DT_NODE_HAS_PROP(node_id, compatible), \
1658 (DT_FOREACH_PROP_ELEM(node_id, compatible, \
1659 Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL_IDX)), \
1660 ())
1661
1662DT_FOREACH_STATUS_OKAY_NODE(Z_MAYBE_SENSOR_DECODER_DECLARE_INTERNAL)
1663
1664#ifdef __cplusplus
1665}
1666#endif
1667
1668#include <zephyr/syscalls/sensor.h>
1669
1670#endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_H_ */
irp nz macro MOVR cc d
Definition asm-macro-32-bit-gnu.h:11
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
System error numbers.
#define DT_FOREACH_STATUS_OKAY_NODE(fn)
Invokes fn for every status okay node in the tree.
Definition devicetree.h:3185
#define RTIO_PRIO_NORM
Normal priority.
Definition sqe.h:55
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 sqe.h:452
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:934
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 sqe.h:431
static struct rtio_sqe * rtio_sqe_acquire(struct rtio *r)
Acquire a single submission queue event if available.
Definition rtio.h:339
static void rtio_sqe_prep_read_multishot(struct rtio_sqe *sqe, const struct rtio_iodev *iodev, int8_t prio, void *userdata)
Definition sqe.h:460
static void rtio_cqe_release(struct rtio *r, struct rtio_cqe *cqe)
Release consumed completion queue event.
Definition rtio.h:513
static struct rtio_cqe * rtio_cqe_consume_block(struct rtio *r)
Wait for and consume a single completion queue event.
Definition rtio.h:489
int rtio_submit(struct rtio *r, uint32_t wait_count)
Submit I/O requests to the underlying executor.
int(* sensor_attr_get_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, struct sensor_value *val)
Callback API to get a sensor attribute.
Definition sensor.h:442
int(* sensor_get_decoder_t)(const struct device *dev, const struct sensor_decoder_api **api)
Callback API to get the sensor decoder implementation.
Definition sensor.h:477
int(* sensor_attr_set_t)(const struct device *dev, enum sensor_channel chan, enum sensor_attribute attr, const struct sensor_value *val)
Callback API to set a sensor attribute.
Definition sensor.h:433
int(* sensor_channel_get_t)(const struct device *dev, enum sensor_channel chan, struct sensor_value *val)
Callback API to read a sensor channel from the driver buffer.
Definition sensor.h:466
int(* sensor_sample_fetch_t)(const struct device *dev, enum sensor_channel chan)
Callback API to fetch a sensor sample into the driver buffer.
Definition sensor.h:459
void(* sensor_submit_t)(const struct device *sensor, struct rtio_iodev_sqe *sqe)
Callback API to service an RTIO submission for a sensor device.
Definition sensor.h:488
int(* sensor_trigger_set_t)(const struct device *dev, const struct sensor_trigger *trig, sensor_trigger_handler_t handler)
Callback API to set a sensor trigger and handler.
Definition sensor.h:451
#define SENSOR_G
The value of gravitational constant in micro m/s^2.
Definition sensor.h:1232
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:683
static int sensor_stream(const struct rtio_iodev *iodev, struct rtio *ctx, void *userdata, struct rtio_sqe **handle)
Definition sensor.h:1102
static int32_t sensor_rad_to_degrees(const struct sensor_value *rad)
Helper function for converting radians to degrees.
Definition sensor.h:1323
sensor_trigger_type
Sensor trigger types.
Definition sensor.h:258
sensor_attribute
Sensor attribute types.
Definition sensor.h:342
int sensor_get_decoder(const struct device *dev, const struct sensor_decoder_api **decoder)
Get the sensor's decoder API.
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:1310
static double sensor_value_to_double(const struct sensor_value *val)
Helper function for converting struct sensor_value to double.
Definition sensor.h:1382
static float sensor_value_to_float(const struct sensor_value *val)
Helper function for converting struct sensor_value to float.
Definition sensor.h:1393
int sensor_natively_supported_channel_size_info(struct sensor_chan_spec channel, size_t *base_size, size_t *frame_size)
static void sensor_degrees_to_rad(int32_t d, struct sensor_value *rad)
Helper function for converting degrees to radians.
Definition sensor.h:1340
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:1297
static int sensor_value_from_float(struct sensor_value *val, float inp)
Helper function for converting float to struct sensor_value.
Definition sensor.h:1427
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:1264
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:1556
#define SENSOR_PI
The value of constant PI in micros.
Definition sensor.h:1237
int sensor_reconfigure_read_iodev(const 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_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:874
sensor_stream_data_opt
Options for what to do with the associated data when a trigger is consumed.
Definition sensor.h:694
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:1579
void(* sensor_trigger_handler_t)(const struct device *dev, const struct sensor_trigger *trigger)
Callback API upon firing of a trigger.
Definition sensor.h:421
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:1567
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:1278
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:1211
sensor_channel
Sensor channels.
Definition sensor.h:65
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:1370
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:1247
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:1534
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:1599
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_read(const 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:1139
static int32_t sensor_rad_to_10udegrees(const struct sensor_value *rad)
Helper function for converting radians to 10 micro degrees.
Definition sensor.h:1357
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:1545
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:554
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:1405
static int sensor_read_async_mempool(const struct rtio_iodev *iodev, struct rtio *ctx, void *userdata)
One shot non-blocking read with pool allocated buffer.
Definition sensor.h:1181
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_OVERFLOW
Trigger fires when data overflows.
Definition sensor.h:310
@ SENSOR_TRIG_DELTA
Trigger fires when the selected channel varies significantly.
Definition sensor.h:274
@ SENSOR_TRIG_NEAR_FAR
Trigger fires when a near/far event is detected.
Definition sensor.h:276
@ SENSOR_TRIG_FREEFALL
Trigger fires when a free fall is detected.
Definition sensor.h:292
@ SENSOR_TRIG_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:321
@ SENSOR_TRIG_FIFO_FULL
Trigger fires when the FIFO becomes full.
Definition sensor.h:304
@ SENSOR_TRIG_MOTION
Trigger fires when motion is detected.
Definition sensor.h:295
@ SENSOR_TRIG_STATIONARY
Trigger fires when no motion has been detected for a while.
Definition sensor.h:298
@ SENSOR_TRIG_COMMON_COUNT
Number of all common sensor triggers.
Definition sensor.h:315
@ SENSOR_TRIG_THRESHOLD
Trigger fires when channel reading transitions configured thresholds.
Definition sensor.h:283
@ SENSOR_TRIG_MAX
Maximum value describing a sensor trigger type.
Definition sensor.h:326
@ SENSOR_TRIG_DOUBLE_TAP
Trigger fires when a double tap is detected.
Definition sensor.h:289
@ SENSOR_TRIG_TILT
Trigger fires when a tilt is detected.
Definition sensor.h:307
@ SENSOR_TRIG_TIMER
Timer-based trigger, useful when the sensor does not have an interrupt line.
Definition sensor.h:263
@ SENSOR_TRIG_FIFO_WATERMARK
Trigger fires when the FIFO watermark has been reached.
Definition sensor.h:301
@ SENSOR_TRIG_TAP
Trigger fires when a single tap is detected.
Definition sensor.h:286
@ SENSOR_TRIG_DATA_READY
Trigger fires whenever new data is ready.
Definition sensor.h:265
@ SENSOR_ATTR_HYSTERESIS
Definition sensor.h:360
@ SENSOR_ATTR_FEATURE_MASK
Enable/disable sensor features.
Definition sensor.h:380
@ SENSOR_ATTR_CALIB_TARGET
Calibration target.
Definition sensor.h:374
@ SENSOR_ATTR_OFFSET
The sensor value returned will be altered by the amount indicated by offset: final_value = sensor_val...
Definition sensor.h:369
@ SENSOR_ATTR_BATCH_DURATION
Hardware batch duration in ticks.
Definition sensor.h:391
@ SENSOR_ATTR_OVERSAMPLING
Oversampling factor.
Definition sensor.h:362
@ SENSOR_ATTR_FF_DUR
Free-fall duration represented in milliseconds.
Definition sensor.h:388
@ SENSOR_ATTR_UPPER_THRESH
Upper threshold for trigger.
Definition sensor.h:351
@ SENSOR_ATTR_CONFIGURATION
Configure the operating modes of a sensor.
Definition sensor.h:376
@ SENSOR_ATTR_RESOLUTION
Configure the resolution of a sensor.
Definition sensor.h:395
@ SENSOR_ATTR_CALIBRATION
Set a calibration value needed by a sensor.
Definition sensor.h:378
@ SENSOR_ATTR_CHIP_ID
Chip ID of a sensor.
Definition sensor.h:397
@ SENSOR_ATTR_COMMON_COUNT
Number of all common sensor attributes.
Definition sensor.h:401
@ SENSOR_ATTR_ALERT
Alert threshold or alert enable/disable.
Definition sensor.h:382
@ SENSOR_ATTR_SLOPE_TH
Threshold for any-motion (slope) trigger.
Definition sensor.h:353
@ SENSOR_ATTR_GAIN
Configure the gain of a sensor.
Definition sensor.h:393
@ SENSOR_ATTR_SAMPLING_FREQUENCY
Sensor sampling frequency, i.e.
Definition sensor.h:347
@ SENSOR_ATTR_FULL_SCALE
Sensor range, in SI units.
Definition sensor.h:364
@ SENSOR_ATTR_LOWER_THRESH
Lower threshold for trigger.
Definition sensor.h:349
@ SENSOR_ATTR_SLOPE_DUR
Duration for which the slope values needs to be outside the threshold for the trigger to fire.
Definition sensor.h:358
@ SENSOR_ATTR_MAX
Maximum value describing a sensor attribute type.
Definition sensor.h:412
@ SENSOR_ATTR_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:407
@ SENSOR_STREAM_DATA_INCLUDE
Include whatever data is associated with the trigger.
Definition sensor.h:696
@ SENSOR_STREAM_DATA_NOP
Do nothing with the associated trigger data, it may be consumed later.
Definition sensor.h:698
@ SENSOR_STREAM_DATA_DROP
Flush/clear whatever data is associated with the trigger.
Definition sensor.h:700
@ SENSOR_CHAN_GAUGE_STATE_OF_HEALTH
State of health measurement in %.
Definition sensor.h:212
@ SENSOR_CHAN_PM_1_0_CF
PM1.0 concentration (standard particle, CF=1), in µg/m³
Definition sensor.h:119
@ SENSOR_CHAN_PM_1_0
1.0 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:125
@ SENSOR_CHAN_DIE_TEMP
Device die temperature in degrees Celsius.
Definition sensor.h:91
@ SENSOR_CHAN_PRESS
Pressure in kilopascal.
Definition sensor.h:95
@ SENSOR_CHAN_GAUGE_TIME_TO_FULL
Time to full in minutes.
Definition sensor.h:216
@ SENSOR_CHAN_ACCEL_XYZ
Acceleration on the X, Y and Z axes.
Definition sensor.h:73
@ SENSOR_CHAN_MAGN_X
Magnetic field on the X axis, in G.
Definition sensor.h:83
@ SENSOR_CHAN_O2
O2 level, in parts per million (ppm).
Definition sensor.h:149
@ SENSOR_CHAN_CURRENT
Current, in amps.
Definition sensor.h:164
@ SENSOR_CHAN_GYRO_XYZ
Angular velocity around the X, Y and Z axes.
Definition sensor.h:81
@ SENSOR_CHAN_VSHUNT
Current Shunt Voltage in milli-volts.
Definition sensor.h:161
@ SENSOR_CHAN_GREEN
Illuminance in green spectrum, in lux.
Definition sensor.h:112
@ SENSOR_CHAN_GRAVITY_VECTOR
Gravity Vector (X/Y/Z components in m/s^2).
Definition sensor.h:228
@ SENSOR_CHAN_MAGN_Z
Magnetic field on the Z axis, in G.
Definition sensor.h:87
@ SENSOR_CHAN_MAGN_Y
Magnetic field on the Y axis, in G.
Definition sensor.h:85
@ SENSOR_CHAN_GAUGE_DESIRED_VOLTAGE
Desired voltage of cell in V (nominal voltage).
Definition sensor.h:222
@ SENSOR_CHAN_POWER
Power in watts.
Definition sensor.h:166
@ SENSOR_CHAN_PM_2_5
2.5 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:127
@ SENSOR_CHAN_RESISTANCE
Resistance , in Ohm.
Definition sensor.h:169
@ SENSOR_CHAN_GAME_ROTATION_VECTOR
Game Rotation Vector (unit quaternion components X/Y/Z/W).
Definition sensor.h:226
@ SENSOR_CHAN_AMBIENT_LIGHT
Ambient illuminance in visible spectrum, in lux.
Definition sensor.h:104
@ SENSOR_CHAN_PM_0_5_COUNT
Number of particles ≥ 0.5 µm per 0.1 liter of air.
Definition sensor.h:133
@ SENSOR_CHAN_GAUGE_AVG_CURRENT
Average current, in amps (negative=discharging).
Definition sensor.h:192
@ SENSOR_CHAN_ENCODER_COUNT
Raw quadrature decoder count, in counts.
Definition sensor.h:233
@ SENSOR_CHAN_GYRO_Y
Angular velocity around the Y axis, in rad/s.
Definition sensor.h:77
@ SENSOR_CHAN_GAUGE_DESIRED_CHARGING_CURRENT
Desired charging current in mA.
Definition sensor.h:224
@ SENSOR_CHAN_FREQUENCY
Frequency, in Hz.
Definition sensor.h:187
@ SENSOR_CHAN_PM_2_5_CF
PM2.5 concentration (standard particle, CF=1), in µg/m³
Definition sensor.h:121
@ SENSOR_CHAN_GAUGE_FULL_CHARGE_CAPACITY
Full Charge Capacity in mAh.
Definition sensor.h:202
@ SENSOR_CHAN_ROTATION
Angular rotation, in degrees.
Definition sensor.h:172
@ SENSOR_CHAN_AMBIENT_TEMP
Ambient temperature in degrees Celsius.
Definition sensor.h:93
@ SENSOR_CHAN_MAGN_XYZ
Magnetic field on the X, Y and Z axes.
Definition sensor.h:89
@ SENSOR_CHAN_GAUGE_STDBY_CURRENT
Standby current, in amps (negative=discharging).
Definition sensor.h:194
@ SENSOR_CHAN_GAUGE_MAX_LOAD_CURRENT
Max load current, in amps (negative=discharging).
Definition sensor.h:196
@ SENSOR_CHAN_ACCEL_Y
Acceleration on the Y axis, in m/s^2.
Definition sensor.h:69
@ SENSOR_CHAN_RPM
Revolutions per minute, in RPM.
Definition sensor.h:184
@ SENSOR_CHAN_GAUGE_FULL_AVAIL_CAPACITY
Full Available Capacity in mAh.
Definition sensor.h:208
@ SENSOR_CHAN_VOLTAGE
Voltage, in volts.
Definition sensor.h:158
@ SENSOR_CHAN_FLOW_RATE
Flow rate in litres per minute.
Definition sensor.h:155
@ SENSOR_CHAN_BLUE
Illuminance in blue spectrum, in lux.
Definition sensor.h:114
@ SENSOR_CHAN_LIGHT
Illuminance in visible spectrum, in lux.
Definition sensor.h:106
@ SENSOR_CHAN_GAUGE_DESIGN_VOLTAGE
Design voltage of cell in V (max voltage).
Definition sensor.h:220
@ SENSOR_CHAN_PM_5_COUNT
Number of particles ≥ 5.0 µm per 0.1 liter of air.
Definition sensor.h:139
@ SENSOR_CHAN_ACCEL_Z
Acceleration on the Z axis, in m/s^2.
Definition sensor.h:71
@ SENSOR_CHAN_CO2
CO2 level, in parts per million (ppm).
Definition sensor.h:147
@ SENSOR_CHAN_GAUGE_STATE_OF_CHARGE
State of charge measurement in %.
Definition sensor.h:200
@ SENSOR_CHAN_POS_DXYZ
Position change on the X, Y and Z axis, in points.
Definition sensor.h:181
@ SENSOR_CHAN_GBIAS_XYZ
Gyroscope bias (X/Y/Z components in rad/s).
Definition sensor.h:230
@ SENSOR_CHAN_GAUGE_CYCLE_COUNT
Cycle count (total number of charge/discharge cycles).
Definition sensor.h:218
@ SENSOR_CHAN_GAUGE_TEMP
Gauge temperature.
Definition sensor.h:198
@ SENSOR_CHAN_POS_DY
Position change on the Y axis, in points.
Definition sensor.h:177
@ SENSOR_CHAN_GYRO_Z
Angular velocity around the Z axis, in rad/s.
Definition sensor.h:79
@ SENSOR_CHAN_PM_10_CF
PM10 concentration (standard particle, CF=1), in µg/m³
Definition sensor.h:123
@ SENSOR_CHAN_POS_DX
Position change on the X axis, in points.
Definition sensor.h:175
@ SENSOR_CHAN_GAUGE_AVG_POWER
Average power in mW.
Definition sensor.h:210
@ SENSOR_CHAN_GAUGE_TIME_TO_EMPTY
Time to empty in minutes.
Definition sensor.h:214
@ SENSOR_CHAN_PM_10
10 micro-meters Particulate Matter, in ug/m^3
Definition sensor.h:129
@ SENSOR_CHAN_GAUGE_REMAINING_CHARGE_CAPACITY
Remaining Charge Capacity in mAh.
Definition sensor.h:204
@ SENSOR_CHAN_PM_1_0_COUNT
Number of particles ≥ 1.0 µm per 0.1 liter of air.
Definition sensor.h:135
@ SENSOR_CHAN_PM_0_3_COUNT
Number of particles ≥ 0.3 µm per 0.1 liter of air.
Definition sensor.h:131
@ SENSOR_CHAN_PM_10_COUNT
Number of particles ≥ 10.0 µm per 0.1 liter of air.
Definition sensor.h:141
@ SENSOR_CHAN_ALL
All channels.
Definition sensor.h:236
@ SENSOR_CHAN_GAUGE_VOLTAGE
Voltage, in volts.
Definition sensor.h:190
@ SENSOR_CHAN_PROX
Proximity.
Definition sensor.h:100
@ SENSOR_CHAN_COMMON_COUNT
Number of all common sensor channels.
Definition sensor.h:241
@ SENSOR_CHAN_PRIV_START
This and higher values are sensor specific.
Definition sensor.h:247
@ SENSOR_CHAN_GYRO_X
Angular velocity around the X axis, in rad/s.
Definition sensor.h:75
@ SENSOR_CHAN_GAS_RES
Gas sensor resistance in ohms.
Definition sensor.h:153
@ SENSOR_CHAN_HUMIDITY
Humidity, in percent.
Definition sensor.h:102
@ SENSOR_CHAN_DISTANCE
Distance.
Definition sensor.h:144
@ SENSOR_CHAN_IR
Illuminance in infra-red spectrum, in lux.
Definition sensor.h:108
@ SENSOR_CHAN_MAX
Maximum value describing a sensor channel type.
Definition sensor.h:252
@ SENSOR_CHAN_PM_2_5_COUNT
Number of particles ≥ 2.5 µm per 0.1 liter of air.
Definition sensor.h:137
@ SENSOR_CHAN_POS_DZ
Position change on the Z axis, in points.
Definition sensor.h:179
@ SENSOR_CHAN_RED
Illuminance in red spectrum, in lux.
Definition sensor.h:110
@ SENSOR_CHAN_ALTITUDE
Altitude, in meters.
Definition sensor.h:116
@ SENSOR_CHAN_GAUGE_NOM_AVAIL_CAPACITY
Nominal Available Capacity in mAh.
Definition sensor.h:206
@ SENSOR_CHAN_ACCEL_X
Acceleration on the X axis, in m/s^2.
Definition sensor.h:67
@ SENSOR_CHAN_VOC
VOC level, in parts per billion (ppb).
Definition sensor.h:151
#define IS_ENABLED(config_macro)
Check for macro definition in compiler-visible expressions.
Definition util_macro.h:154
#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
#define BUILD_ASSERT(EXPR, MSG...)
Definition llvm.h:51
Size of off_t must be equal or less than size of size_t
Definition retained_mem.h:29
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:513
A completion queue event.
Definition cqe.h:83
void * userdata
Associated userdata with operation.
Definition cqe.h:87
int32_t result
Result from operation.
Definition cqe.h:86
API that an RTIO IO device should implement.
Definition iodev.h:33
IO device submission queue entry.
Definition sqe.h:394
struct rtio_sqe sqe
Definition sqe.h:395
An IO device with a function table for submitting requests.
Definition iodev.h:48
void * data
Definition iodev.h:53
A submission queue event.
Definition sqe.h:304
void * userdata
User provided data which is returned upon operation completion.
Definition sqe.h:322
uint32_t buf_len
Length of buffer.
Definition sqe.h:328
const struct rtio_iodev * iodev
Device to operation on.
Definition sqe.h:313
const uint8_t * buf
Buffer to write from.
Definition sqe.h:329
An RTIO context containing what can be viewed as a pair of queues.
Definition rtio.h:71
Sensor Channel Specification.
Definition sensor.h:535
uint16_t chan_idx
A sensor channel index.
Definition sensor.h:537
uint16_t chan_type
A sensor channel type.
Definition sensor.h:536
Definition sensor.h:979
uint64_t timestamp_ns
The timestamp at which the data was collected from the sensor.
Definition sensor.h:981
int8_t shift
Shift value for all samples in the frame.
Definition sensor.h:991
uint32_t num_channels
Definition sensor.h:988
struct sensor_chan_spec channels[0]
Channels present in the frame.
Definition sensor.h:997
Used for iterating over the data frames via the sensor_decoder_api.
Definition sensor.h:657
const struct sensor_decoder_api * decoder
Definition sensor.h:658
struct sensor_chan_spec channel
Definition sensor.h:660
const uint8_t * buffer
Definition sensor.h:659
uint32_t fit
Definition sensor.h:661
Decodes a single raw data buffer.
Definition sensor.h:567
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:593
int(* get_frame_count)(const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint16_t *frame_count)
Get the frame_count for a specified chan_spec from the buffer.
Definition sensor.h:578
int(* decode)(const uint8_t *buffer, struct sensor_chan_spec chan_spec, uint32_t *fit, uint16_t max_count, void *data_out)
Decode up to max_count frames specified by chan_spec from the buffer.
Definition sensor.h:620
bool(* has_trigger)(const uint8_t *buffer, enum sensor_trigger_type trigger)
Check if the given trigger type is present.
Definition sensor.h:630
<span class="mlabel">Driver Operations</span> Sensor driver operations
Definition sensor.h:493
sensor_get_decoder_t get_decoder
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition sensor.h:517
sensor_attr_set_t attr_set
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition sensor.h:497
sensor_attr_get_t attr_get
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition sensor.h:501
sensor_trigger_set_t trigger_set
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition sensor.h:505
sensor_sample_fetch_t sample_fetch
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition sensor.h:509
sensor_channel_get_t channel_get
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition sensor.h:513
sensor_submit_t submit
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition sensor.h:521
Definition sensor.h:717
struct sensor_chan_spec *const channels
Definition sensor.h:721
size_t count
Definition sensor.h:724
struct sensor_stream_trigger *const triggers
Definition sensor.h:722
const bool is_streaming
Definition sensor.h:719
const struct device * sensor
Definition sensor.h:718
const size_t max
Definition sensor.h:725
Definition sensor.h:703
enum sensor_stream_data_opt opt
Definition sensor.h:705
enum sensor_trigger_type trigger
Definition sensor.h:704
Sensor trigger spec.
Definition sensor.h:332
enum sensor_trigger_type type
Trigger type.
Definition sensor.h:334
enum sensor_channel chan
Channel the trigger is set on.
Definition sensor.h:336
Representation of a sensor readout value.
Definition sensor.h:55
int32_t val2
Fractional part of the value (in one-millionth parts).
Definition sensor.h:59
int32_t val1
Integer part of the value.
Definition sensor.h:57
#define INT64_C(x)
Definition xcc.h:119