One Framework
0.1.0
RoboMaster嵌入式框架“一键”解决方案,为你的“创意”服务。
载入中...
搜索中...
未找到
Macro.hpp
浏览该文件的文档.
1
#ifndef OF_LIB_NODE_MACRO_HPP
2
#define OF_LIB_NODE_MACRO_HPP
3
4
#include <zephyr/sys/iterable_sections.h>
5
#include <
OF/utils/CCM.h
>
6
7
#include "
Node.hpp
"
8
#include "
Descriptor.hpp
"
9
#include "
Topic.hpp
"
10
11
12
#define ONE_NODE_REGISTER(UserClass) \
13
static_assert(NodeConcept<UserClass>, \
14
"Your Node must define a full Meta struct and implement init, run and cleanup function! See 'NodeConcept' for more detail. ' " \
15
); \
16
/* stack definition */
\
17
K_THREAD_STACK_DEFINE(_stack_##UserClass, UserClass::Meta::stack_size); \
18
/* thread data */
\
19
static struct k_thread _thread_data_##UserClass;\
20
/* launcher */
\
21
static void _launcher_##UserClass(void) { \
22
UserClass::start_impl(&_thread_data_##UserClass, _stack_##UserClass); \
23
} \
24
/* register it into global linker section */
\
25
STRUCT_SECTION_ITERABLE(node_desc, _desc_##UserClass) ={ \
26
.name = UserClass::Meta::name, \
27
.thread_id_ptr = &UserClass::tid_storage, \
28
.start_func = &_launcher_##UserClass \
29
}
30
31
#define ONE_TOPIC_REGISTER(Type, VarName, TopicNameStr) \
32
\
33
/* CCM Topic instance and reference */
\
34
OF_CCM_ATTR static OF::Topic<Type> _topic_instance_##VarName; \
35
OF::Topic<Type>& VarName = _topic_instance_##VarName;\
36
/* register it into global linker section */
\
37
STRUCT_SECTION_ITERABLE(topic_desc, _topic_desc_##VarName) = { \
38
.name = TopicNameStr, \
39
.topic_instance = &_topic_instance_##VarName, \
40
.type_size = sizeof(Type),\
41
.print_func = OF::Topic<Type>::print_stub \
42
};
43
44
45
#endif
//OF_LIB_NODE_MACRO_HPP
CCM.h
Descriptor.hpp
Node.hpp
Topic.hpp
OF
lib
Node
Macro.hpp
制作者
1.13.2