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
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
30enum {
34};
35
39 /* Demo algorithm config */
40 union {
43 };
44} __packed;
45
50
52void algorithm_demo_event_fn(const struct zbus_channel *chan, const void *config, void *data);
53
55void algorithm_demo_state_fn(const struct zbus_channel *chan, const void *config, void *data);
56
58void algorithm_demo_metric_fn(const struct zbus_channel *chan, const void *config, void *data);
59
71#define ALGORITHM_DEMO_EVENT_DEFINE(name, loggers_, tdfs, event_chance_percent) \
72 static const struct algorithm_demo_common_config name##_config = { \
73 .common = \
74 { \
75 .algorithm_id = 0xFFFFFFF0, \
76 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
77 .state_size = sizeof(union algorithm_demo_common_data), \
78 .logging = \
79 { \
80 .loggers = loggers_, \
81 .tdf_mask = tdfs, \
82 }, \
83 }, \
84 .event_gen_chance = event_chance_percent, \
85 }; \
86 static union algorithm_demo_common_data name##_data; \
87 static struct algorithm_runner_algorithm name = { \
88 .impl = algorithm_demo_event_fn, \
89 .config = &name##_config.common, \
90 .runtime_state = &name##_data, \
91 }
92
102#define ALGORITHM_DEMO_STATE_DEFINE(name, loggers_, tdfs) \
103 static const struct algorithm_demo_common_config name##_config = { \
104 .common = \
105 { \
106 .algorithm_id = 0xFFFFFFF1, \
107 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
108 .state_size = sizeof(union algorithm_demo_common_data), \
109 .logging = \
110 { \
111 .loggers = loggers_, \
112 .tdf_mask = tdfs, \
113 }, \
114 }, \
115 }; \
116 static union algorithm_demo_common_data name##_data; \
117 static struct algorithm_runner_algorithm name = { \
118 .impl = algorithm_demo_state_fn, \
119 .config = &name##_config.common, \
120 .runtime_state = &name##_data, \
121 }
122
133#define ALGORITHM_DEMO_METRIC_DEFINE(name, loggers_, tdfs, metric_compute_len) \
134 static const struct algorithm_demo_common_config name##_config = { \
135 .common = \
136 { \
137 .algorithm_id = 0xFFFFFFF2, \
138 .zbus_channel = INFUSE_ZBUS_CHAN_IMU, \
139 .state_size = sizeof(union algorithm_demo_common_data), \
140 .logging = \
141 { \
142 .loggers = loggers_, \
143 .tdf_mask = tdfs, \
144 }, \
145 }, \
146 .compute_metric_len = metric_compute_len, \
147 }; \
148 static union algorithm_demo_common_data name##_data; \
149 static struct algorithm_runner_algorithm name = { \
150 .impl = algorithm_demo_metric_fn, \
151 .config = &name##_config.common, \
152 .runtime_state = &name##_data, \
153 }
154
159#ifdef __cplusplus
160}
161#endif
162
163#endif /* INFUSE_SDK_INCLUDE_INFUSE_ALGORITHM_RUNNER_ALGORITHMS_DEMO_H_ */
Infuse-IoT algorithm runner.
Infuse-IoT zbus channels.
void algorithm_demo_state_fn(const struct zbus_channel *chan, const void *config, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_event_fn(const struct zbus_channel *chan, const void *config, void *data)
Algorithm implementation, see algorithm_run_fn.
void algorithm_demo_metric_fn(const struct zbus_channel *chan, const void *config, 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
struct algorithm_runner_common_config common
Common algorithm configuration.
Definition demo.h:38
uint8_t event_gen_chance
Definition demo.h:41
uint16_t compute_metric_len
Definition demo.h:42
Definition runner.h:29
Definition demo.h:46
uint8_t current_state
Definition demo.h:48
uint32_t processed
Definition demo.h:47