-
Notifications
You must be signed in to change notification settings - Fork 2
/
mpddec.h
197 lines (168 loc) · 3.07 KB
/
mpddec.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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#ifndef __MPDDEC__
#define __MPDDEC__
#include <stdint.h>
typedef struct
{
uint32_t data:21;
uint32_t data_type_tag:3;
uint32_t undef:8;
} generic_data_word;
typedef union
{
uint32_t raw;
generic_data_word bf;
} generic_data_word_t;
/* 0: BLOCK HEADER */
typedef struct
{
uint32_t block_count:8;
uint32_t event_per_block:8;
uint32_t module_id:5;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_block_header;
typedef union
{
uint32_t raw;
mpd_block_header bf;
} mpd_block_header_t;
/* 1: BLOCK TRAILER */
typedef struct
{
uint32_t n_words_in_block:20;
uint32_t blank:1;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_block_trailer;
typedef union
{
uint32_t raw;
mpd_block_trailer bf;
} mpd_block_trailer_t;
/* 2: EVENT HEADER */
typedef struct
{
uint32_t event_count:20;
uint32_t blank:1;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_event_header;
typedef union
{
uint32_t raw;
mpd_event_header bf;
} mpd_event_header_t;
/* 3: TRIGGER TIME */
typedef struct
{
uint32_t coarse_trigger_time:20;
uint32_t cont:1;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_trigger_time;
typedef union
{
uint32_t raw;
mpd_trigger_time bf;
} mpd_trigger_time_t;
/* 4: APV CHANNEL DATA */
typedef struct
{
uint32_t processed_data:19;
uint32_t proc_data_type:2;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_apv_channel_data;
typedef union
{
uint32_t raw;
mpd_apv_channel_data bf;
} mpd_apv_channel_data_t;
/* 4.0: HEADER */
typedef struct
{
uint32_t apv_id:4;
uint32_t apv_header:13;
uint32_t what:1;
uint32_t blank:1;
uint32_t proc_data_type:2;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_data_header;
typedef union
{
uint32_t raw;
mpd_data_header bf;
} mpd_data_header_t;
/* 4.1: Reduced Data */
typedef struct
{
uint32_t data:12;
uint32_t channel_number:7;
uint32_t proc_data_type:2;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_reduced_data;
typedef union
{
uint32_t raw;
mpd_reduced_data bf;
} mpd_reduced_data_t;
/* 4.2: ApvTrailer */
typedef struct
{
uint32_t frame_counter:8;
uint32_t sample_count:4;
uint32_t mod_id:6;
uint32_t blank:1;
uint32_t proc_data_type:2;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_apv_trailer;
typedef union
{
uint32_t raw;
mpd_apv_trailer bf;
} mpd_apv_trailer_t;
/* 4.3: Trailer */
typedef struct
{
uint32_t word_count:8;
uint32_t baseline_value:11;
uint32_t proc_data_type:2;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_data_trailer;
typedef union
{
uint32_t raw;
mpd_data_trailer bf;
} mpd_data_trailer_t;
/* 5: EVENT TRAILER */
typedef struct
{
uint32_t fine_trigger_time:8;
uint32_t n_words_in_event:12;
uint32_t blank:1;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_event_trailer;
typedef union
{
uint32_t raw;
mpd_event_trailer bf;
} mpd_event_trailer_t;
/* 7: FILLER */
typedef struct
{
uint32_t zero:21;
uint32_t data_type_tag:3;
uint32_t undef:8;
} mpd_filler;
typedef union
{
uint32_t raw;
mpd_filler bf;
} mpd_filler_t;
void mpdDataDecode(uint32_t data);
#endif /* __MPDDEC__ */