Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
demo.h
Go to the documentation of this file.
1
9
10#ifndef INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_
11#define INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_
12
13#include <stdint.h>
14
15#include <zephyr/toolchain.h>
16
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
30
31enum {
35};
36
41 /* Algorithm specific arguments */
42 union {
47 } __packed;
48} __packed;
49
50/* Algorithm runtime state */
52union algorithm_demo_common_data {
53 uint32_t processed;
54 uint8_t current_state;
55};
57
59void algorithm_demo_event_fn(const struct zbus_channel *chan,
60 const struct infuse_algorithm *algorithm, const void *args,
61 void *data);
62
64void algorithm_demo_state_fn(const struct zbus_channel *chan,
65 const struct infuse_algorithm *algorithm, const void *args,
66 void *data);
67
69void algorithm_demo_metric_fn(const struct zbus_channel *chan,
70 const struct infuse_algorithm *algorithm, const void *args,
71 void *data);
72
84#define ALGORITHM_DEMO_EVENT_DEFINE(name, loggers_, tdfs, event_chance_percent) \
85 static void name##_wrapper(const struct zbus_channel *chan, \
86 const struct infuse_algorithm *algorithm, const void *args) \
87 { \
88 static union algorithm_demo_common_data data; \
89 algorithm_demo_event_fn(chan, algorithm, args, &data); \
90 } \
91 static struct algorithm_demo_common_args name##_default_args = { \
92 .logging = \
93 { \
94 .loggers = loggers_, \
95 .tdf_mask = tdfs, \
96 }, \
97 .event_gen_chance = event_chance_percent, \
98 }; \
99 static const struct infuse_algorithm name = { \
100 .fn = name##_wrapper, \
101 .algorithm_id = 0xFFFFFFF0, \
102 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
103 .arguments = &name##_default_args, \
104 .arguments_size = sizeof(struct algorithm_demo_common_args), \
105 }
106
116#define ALGORITHM_DEMO_STATE_DEFINE(name, loggers_, tdfs) \
117 static void name##_wrapper(const struct zbus_channel *chan, \
118 const struct infuse_algorithm *algorithm, const void *args) \
119 { \
120 static union algorithm_demo_common_data data; \
121 algorithm_demo_state_fn(chan, algorithm, args, &data); \
122 } \
123 static struct algorithm_demo_common_args name##_default_args = { \
124 .logging = \
125 { \
126 .loggers = loggers_, \
127 .tdf_mask = tdfs, \
128 }, \
129 }; \
130 static const struct infuse_algorithm name = { \
131 .fn = name##_wrapper, \
132 .algorithm_id = 0xFFFFFFF1, \
133 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
134 .arguments = &name##_default_args, \
135 .arguments_size = sizeof(struct algorithm_demo_common_args), \
136 }
137
148#define ALGORITHM_DEMO_METRIC_DEFINE(name, loggers_, tdfs, metric_compute_len) \
149 static void name##_wrapper(const struct zbus_channel *chan, \
150 const struct infuse_algorithm *algorithm, const void *args) \
151 { \
152 static union algorithm_demo_common_data data; \
153 algorithm_demo_metric_fn(chan, algorithm, args, &data); \
154 } \
155 static struct algorithm_demo_common_args name##_default_args = { \
156 .logging = \
157 { \
158 .loggers = loggers_, \
159 .tdf_mask = tdfs, \
160 }, \
161 .compute_metric_len = metric_compute_len, \
162 }; \
163 static const struct infuse_algorithm name = { \
164 .fn = name##_wrapper, \
165 .algorithm_id = 0xFFFFFFF2, \
166 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
167 .arguments = &name##_default_args, \
168 .arguments_size = sizeof(struct algorithm_demo_common_args), \
169 }
170
174
175#ifdef __cplusplus
176}
177#endif
178
179#endif /* INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_ */
Infuse-IoT algorithm runner.
Infuse-IoT zbus channels.
void algorithm_demo_metric_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_state_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_event_fn(const struct zbus_channel *chan, const struct infuse_algorithm *algorithm, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
@ ALGORITHM_DEMO_STATE_LOG
Definition demo.h:33
@ ALGORITHM_DEMO_METRIC_LOG
Definition demo.h:34
@ ALGORITHM_DEMO_EVENT_LOG
Definition demo.h:32
Arguments common to the demonstration algorithms.
Definition demo.h:38
uint8_t event_gen_chance
Chance to emit an event on each buffer (%)
Definition demo.h:44
struct kv_algorithm_logging logging
Common logging configuration.
Definition demo.h:40
uint16_t compute_metric_len
Number of samples to compute metric over.
Definition demo.h:46
Algorithm definition.
Definition implementation.h:47
Algorithm logging configuration.
Definition kv_types.h:97