-
Notifications
You must be signed in to change notification settings - Fork 1
/
can_parser_types.h.mako
68 lines (63 loc) · 2.07 KB
/
can_parser_types.h.mako
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// CODE GENERATED USING MAKOTEMPLATES.ORG, DO NOT EDIT.
#ifndef CAN_PARSER_TYPES_H
#define CAN_PARSER_TYPES_H
#define CAN_VERSION "${db["version"]}"
#include <stdint.h>
%for module in db["modules"]:
%for topic in module["topics"]:
// ${topic["description"]}
#pragma pack(push, 1) /* Ensure struct is packed */
typedef struct
{
union {
uint8_t raw[8];
struct {
%for byte in topic["bytes"]:
%if byte is not None:
%if byte["type"] == "bitfield":
struct { // ${byte["description"]}
%for bit in byte["bits"]:
%if bit is not None:
uint8_t ${bit.lower()} : 1;
%endif
%endfor
%if byte["bits"].count(None) > 0:
uint8_t _unused : ${byte["bits"].count(None)};
%endif
} ${byte["name"].lower()};
%else:
%if byte["type"] == "uint16_t":
%if byte["name"].lower()[-1] == 'l':
<% continue %>
%endif
union { // ${byte["description"].replace(" byte high", " bytes low/high")}. Units: ${byte["units"]}
${byte["type"]} ${byte["name"].lower()[:-2]};
struct {
uint8_t ${byte["name"].lower()[:-2]}_l;
uint8_t ${byte["name"].lower()[:-2]}_h;
};
};
%else:
${byte["type"]} ${byte["name"].lower()}; // ${byte["description"]}. Units: ${byte["units"]}
%endif
%endif
%endif
%endfor
};
};
} can_${module["name"].lower()}_${topic["name"].lower()}_msg_t;
%endfor
%endfor
typedef struct {
uint32_t id;
uint8_t dlc;
union {
uint8_t raw[8];
%for module in db["modules"]:
%for topic in module["topics"]:
can_${module["name"].lower()}_${topic["name"].lower()}_msg_t ${module["name"].lower()}_${topic["name"].lower()};
%endfor
%endfor
};
} can_msg_t;
#endif // CAN_PARSER_TYPES_H