forked from gopher-motorsports/gophercan-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GopherCAN_structs.h
168 lines (136 loc) · 2.52 KB
/
GopherCAN_structs.h
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
// GopherCAN_structs.h
// structs needed by GopherCAN.c/h and GopherCAN_ring_buffer.c/h
#ifndef GOPHERCAN_STRUCT_H
#define GOPHERCAN_STRUCT_H
#include "base_types.h"
#include "GopherCAN_ids.h"
// float/U32 converter union
typedef union
{
float f;
U32 u32;
} FLOAT_CONVERTER;
// CAN message struct
typedef struct
{
U32 id; // only the least significant 29 bits will be used
U8 rtr_bit; // 0 or 1: DATA_MESSAGE or REQUEST_DATA
U8 dlc; // [0, 8]
U8 data[8]; // not all of these will matter depending on dlc
} CAN_MSG;
// CAN ID struct
typedef struct
{
U8 priority;
U8 dest_module;
U8 source_module;
U8 error;
U16 parameter;
} CAN_ID;
// custom function struct
typedef struct
{
void (*func_ptr)(U8, void*, U8, U8, U8, U8);
U8 func_enabled;
void* param_ptr;
} CUST_FUNC;
// error message struct
typedef struct
{
U32 last_rx;
U8 source_module;
U16 parameter;
U8 error_id;
} ERROR_MSG;
// structs for each parameter type
// custom command struct
typedef struct
{
U32 last_rx;
U8 command_id;
U8 command_parameter;
GCAN_PARAM_ID param_id;
} CAN_COMMAND_STRUCT;
// a struct with only the information about each CAN struct, without the data
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
} CAN_INFO_STRUCT;
// parameter structs
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
U8 data;
} U8_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
U16 data;
} U16_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
U32 data;
} U32_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
U64 data;
} U64_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
S8 data;
} S8_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
S16 data;
} S16_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
S32 data;
} S32_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
S64 data;
} S64_CAN_STRUCT;
typedef struct
{
U32 last_rx;
U8 update_enabled;
U8 pending_response;
GCAN_PARAM_ID param_id;
float data;
} FLOAT_CAN_STRUCT;
#endif
// End of GopherCAN_structs.h