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
29
30enum {
34};
35
37 /* Common logging configuration */
39 /* Algorithm specific arguments */
40 union {
41 /* Chance to emit an event on each buffer (%) */
43 /* Number of samples to compute metric over */
45 } __packed;
46} __packed;
47
52
54void algorithm_demo_event_fn(const struct zbus_channel *chan,
55 const struct algorithm_runner_common_config *common, const void *args,
56 void *data);
57
59void algorithm_demo_state_fn(const struct zbus_channel *chan,
60 const struct algorithm_runner_common_config *common, const void *args,
61 void *data);
62
64void algorithm_demo_metric_fn(const struct zbus_channel *chan,
65 const struct algorithm_runner_common_config *common, const void *args,
66 void *data);
67
79#define ALGORITHM_DEMO_EVENT_DEFINE(name, loggers_, tdfs, event_chance_percent) \
80 static const struct algorithm_runner_common_config name##_config = { \
81 .algorithm_id = 0xFFFFFFF0, \
82 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
83 .arguments_size = sizeof(struct algorithm_demo_common_args), \
84 .state_size = sizeof(union algorithm_demo_common_data), \
85 }; \
86 static struct algorithm_demo_common_args name##_default_args = { \
87 .logging = \
88 { \
89 .loggers = loggers_, \
90 .tdf_mask = tdfs, \
91 }, \
92 .event_gen_chance = event_chance_percent, \
93 }; \
94 static union algorithm_demo_common_data name##_data; \
95 static struct algorithm_runner_algorithm name = { \
96 .impl = algorithm_demo_event_fn, \
97 .config = &name##_config, \
98 .arguments = &name##_default_args, \
99 .runtime_state = &name##_data, \
100 }
101
111#define ALGORITHM_DEMO_STATE_DEFINE(name, loggers_, tdfs) \
112 static const struct algorithm_runner_common_config name##_config = { \
113 .algorithm_id = 0xFFFFFFF1, \
114 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
115 .arguments_size = sizeof(struct algorithm_demo_common_args), \
116 .state_size = sizeof(union algorithm_demo_common_data), \
117 }; \
118 static struct algorithm_demo_common_args name##_default_args = { \
119 .logging = \
120 { \
121 .loggers = loggers_, \
122 .tdf_mask = tdfs, \
123 }, \
124 }; \
125 static union algorithm_demo_common_data name##_data; \
126 static struct algorithm_runner_algorithm name = { \
127 .impl = algorithm_demo_state_fn, \
128 .config = &name##_config, \
129 .arguments = &name##_default_args, \
130 .runtime_state = &name##_data, \
131 }
132
143#define ALGORITHM_DEMO_METRIC_DEFINE(name, loggers_, tdfs, metric_compute_len) \
144 static const struct algorithm_runner_common_config name##_config = { \
145 .algorithm_id = 0xFFFFFFF2, \
146 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
147 .arguments_size = sizeof(struct algorithm_demo_common_args), \
148 .state_size = sizeof(union algorithm_demo_common_data), \
149 }; \
150 static struct algorithm_demo_common_args name##_default_args = { \
151 .logging = \
152 { \
153 .loggers = loggers_, \
154 .tdf_mask = tdfs, \
155 }, \
156 .compute_metric_len = metric_compute_len, \
157 }; \
158 static union algorithm_demo_common_data name##_data; \
159 static struct algorithm_runner_algorithm name = { \
160 .impl = algorithm_demo_metric_fn, \
161 .config = &name##_config, \
162 .arguments = &name##_default_args, \
163 .runtime_state = &name##_data, \
164 }
165
169
170#ifdef __cplusplus
171}
172#endif
173
174#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 algorithm_runner_common_config *common, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_event_fn(const struct zbus_channel *chan, const struct algorithm_runner_common_config *common, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_state_fn(const struct zbus_channel *chan, const struct algorithm_runner_common_config *common, const void *args, void *data)
Algorithm implementation, see algorithm_run_fn.
@ ALGORITHM_DEMO_STATE_LOG
Definition demo.h:32
@ ALGORITHM_DEMO_METRIC_LOG
Definition demo.h:33
@ ALGORITHM_DEMO_EVENT_LOG
Definition demo.h:31
Definition demo.h:36
uint8_t event_gen_chance
Definition demo.h:42
struct kv_algorithm_logging logging
Definition demo.h:38
uint16_t compute_metric_len
Definition demo.h:44
Definition runner.h:31
Algorithm logging configuration.
Definition kv_types.h:87
Definition demo.h:48
uint8_t current_state
Definition demo.h:50
uint32_t processed
Definition demo.h:49