FreeEMS
0.2.0-SNAPSHOT-282-g9efc524
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
src
main
decoders
inc
EvenTeeth-Xand1.h
Go to the documentation of this file.
1
/* FreeEMS - the open source engine management system
2
*
3
* Copyright 2011-2014 Fred Cooke
4
*
5
* This file is part of the FreeEMS project.
6
*
7
* FreeEMS software is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation, either version 3 of the License, or
10
* (at your option) any later version.
11
*
12
* FreeEMS software is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
19
*
20
* We ask that if you make any changes to this file you email them upstream to
21
* us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
22
*
23
* Thank you for choosing FreeEMS to run your engine!
24
*/
25
26
27
/** @file
28
*
29
* @ingroup interruptHandlers
30
* @ingroup enginePositionRPMDecoders
31
*
32
* @brief For evenly spaced teeth on the cam or crank with a single second input.
33
*
34
* Fill out a data reverse header and include this file. Sync is provided by the
35
* second input allowing a sequential and/or COP/CNP setup to be used.
36
*
37
* VR edition with only one edge used!
38
*/
39
40
41
#define DECODER_MAX_CODE_TIME 150 // To be optimised (shortened)!
42
43
44
#include "../../inc/freeEMS.h"
45
#include "../../inc/utils.h"
46
#include "../../inc/interrupts.h"
47
48
49
#if defined(WITH_COMBUSTION_SYNC) // ###########################################
50
#ifndef NUMBER_OF_EVENTS_PER_SYNC
51
#error "Number of events per sync not defined!"
52
#endif
53
#ifndef CYLINDER_COUNT
54
#error "Cylinder count must be defined!"
55
#elif CYLINDER_COUNT > 12 || CYLINDER_COUNT < 1
56
#error "Cylinder count must be in the range 1 to 12!"
57
#endif
58
#define CONFIGURED_SYNC COMBUSTION_SYNC
59
#define NUMBER_OF_REAL_EVENTS NUMBER_OF_EVENTS_PER_SYNC
60
#define NUMBER_OF_VIRTUAL_EVENTS (CYLINDER_COUNT * NUMBER_OF_REAL_EVENTS)
61
#define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 720.0) / NUMBER_OF_VIRTUAL_EVENTS)
62
#if NUMBER_OF_VIRTUAL_EVENTS != TOTAL_EVENT_COUNT
63
#error "Total, per sync and cylinder count don't match!"
64
#endif
65
#elif defined(WITH_CRANK_SYNC) // ##############################################
66
#ifndef NUMBER_OF_EVENTS_ON_CRANK
67
#error "Number of events on crank not defined!"
68
#endif
69
#define CONFIGURED_SYNC CRANK_SYNC
70
#define NUMBER_OF_REAL_EVENTS NUMBER_OF_EVENTS_ON_CRANK
71
#define NUMBER_OF_VIRTUAL_EVENTS (2 * NUMBER_OF_REAL_EVENTS)
72
#define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 360.0) / NUMBER_OF_EVENTS_ON_CRANK)
73
#elif defined(WITH_CAM_SYNC) // ################################################
74
#ifndef NUMBER_OF_EVENTS_ON_CAM
75
#error "Number of events on cam not defined!"
76
#endif
77
#define CONFIGURED_SYNC CAM_SYNC
78
#define NUMBER_OF_REAL_EVENTS NUMBER_OF_EVENTS_ON_CAM
79
#define NUMBER_OF_VIRTUAL_EVENTS NUMBER_OF_REAL_EVENTS
80
#define ANGLE_BETWEEN_EVENTS ((ANGLE_FACTOR * 720.0) / NUMBER_OF_EVENTS_ON_CAM)
81
#else // #######################################################################
82
#error "You MUST configure the style of this decoder!"
83
#endif
84
85
86
#if NUMBER_OF_VIRTUAL_EVENTS > 64
87
#error "Currently only 64 real events are handled! Request an upgrade!"
88
#endif
89
90
91
#include "../../inc/decoderInterface.h"
92
93
94
// Evenly spaced event angles defined recursively and ready for use
95
#define E0 0
96
#define E1 ANGLE_BETWEEN_EVENTS
97
#define E2 ( E1 + ANGLE_BETWEEN_EVENTS)
98
#define E3 ( E2 + ANGLE_BETWEEN_EVENTS)
99
#define E4 ( E3 + ANGLE_BETWEEN_EVENTS)
100
#define E5 ( E4 + ANGLE_BETWEEN_EVENTS)
101
#define E6 ( E5 + ANGLE_BETWEEN_EVENTS)
102
#define E7 ( E6 + ANGLE_BETWEEN_EVENTS)
103
#define E8 ( E7 + ANGLE_BETWEEN_EVENTS)
104
#define E9 ( E8 + ANGLE_BETWEEN_EVENTS)
105
#define E10 ( E9 + ANGLE_BETWEEN_EVENTS)
106
#define E11 ( E10 + ANGLE_BETWEEN_EVENTS)
107
#define E12 ( E11 + ANGLE_BETWEEN_EVENTS)
108
#define E13 ( E12 + ANGLE_BETWEEN_EVENTS)
109
#define E14 ( E13 + ANGLE_BETWEEN_EVENTS)
110
#define E15 ( E14 + ANGLE_BETWEEN_EVENTS)
111
#define E16 ( E15 + ANGLE_BETWEEN_EVENTS)
112
#define E17 ( E16 + ANGLE_BETWEEN_EVENTS)
113
#define E18 ( E17 + ANGLE_BETWEEN_EVENTS)
114
#define E19 ( E18 + ANGLE_BETWEEN_EVENTS)
115
#define E20 ( E19 + ANGLE_BETWEEN_EVENTS)
116
#define E21 ( E20 + ANGLE_BETWEEN_EVENTS)
117
#define E22 ( E21 + ANGLE_BETWEEN_EVENTS)
118
#define E23 ( E22 + ANGLE_BETWEEN_EVENTS)
119
#define E24 ( E23 + ANGLE_BETWEEN_EVENTS)
120
#define E25 ( E24 + ANGLE_BETWEEN_EVENTS)
121
#define E26 ( E25 + ANGLE_BETWEEN_EVENTS)
122
#define E27 ( E26 + ANGLE_BETWEEN_EVENTS)
123
#define E28 ( E27 + ANGLE_BETWEEN_EVENTS)
124
#define E29 ( E28 + ANGLE_BETWEEN_EVENTS)
125
#define E30 ( E29 + ANGLE_BETWEEN_EVENTS)
126
#define E31 ( E30 + ANGLE_BETWEEN_EVENTS)
127
#define E32 ( E31 + ANGLE_BETWEEN_EVENTS)
128
#define E33 ( E32 + ANGLE_BETWEEN_EVENTS)
129
#define E34 ( E33 + ANGLE_BETWEEN_EVENTS)
130
#define E35 ( E34 + ANGLE_BETWEEN_EVENTS)
131
#define E36 ( E35 + ANGLE_BETWEEN_EVENTS)
132
#define E37 ( E36 + ANGLE_BETWEEN_EVENTS)
133
#define E38 ( E37 + ANGLE_BETWEEN_EVENTS)
134
#define E39 ( E38 + ANGLE_BETWEEN_EVENTS)
135
#define E40 ( E39 + ANGLE_BETWEEN_EVENTS)
136
#define E41 ( E40 + ANGLE_BETWEEN_EVENTS)
137
#define E42 ( E41 + ANGLE_BETWEEN_EVENTS)
138
#define E43 ( E42 + ANGLE_BETWEEN_EVENTS)
139
#define E44 ( E43 + ANGLE_BETWEEN_EVENTS)
140
#define E45 ( E44 + ANGLE_BETWEEN_EVENTS)
141
#define E46 ( E45 + ANGLE_BETWEEN_EVENTS)
142
#define E47 ( E46 + ANGLE_BETWEEN_EVENTS)
143
#define E48 ( E47 + ANGLE_BETWEEN_EVENTS)
144
#define E49 ( E48 + ANGLE_BETWEEN_EVENTS)
145
#define E50 ( E49 + ANGLE_BETWEEN_EVENTS)
146
#define E51 ( E50 + ANGLE_BETWEEN_EVENTS)
147
#define E52 ( E51 + ANGLE_BETWEEN_EVENTS)
148
#define E53 ( E52 + ANGLE_BETWEEN_EVENTS)
149
#define E54 ( E53 + ANGLE_BETWEEN_EVENTS)
150
#define E55 ( E54 + ANGLE_BETWEEN_EVENTS)
151
#define E56 ( E55 + ANGLE_BETWEEN_EVENTS)
152
#define E57 ( E56 + ANGLE_BETWEEN_EVENTS)
153
#define E58 ( E57 + ANGLE_BETWEEN_EVENTS)
154
#define E59 ( E58 + ANGLE_BETWEEN_EVENTS)
155
#define E60 ( E59 + ANGLE_BETWEEN_EVENTS)
156
#define E61 ( E60 + ANGLE_BETWEEN_EVENTS)
157
#define E62 ( E61 + ANGLE_BETWEEN_EVENTS)
158
#define E63 ( E62 + ANGLE_BETWEEN_EVENTS)
159
160
// Simply including all of them and only using the first N is acceptable
161
const
unsigned
short
eventAngles
[] = {
162
E0
// Always this event...
163
164
#if (NUMBER_OF_VIRTUAL_EVENTS > 1)
165
,
E1
166
#if (NUMBER_OF_VIRTUAL_EVENTS > 2)
167
,
E2
168
#if (NUMBER_OF_VIRTUAL_EVENTS > 3)
169
,
E3
170
#if (NUMBER_OF_VIRTUAL_EVENTS > 4)
171
,
E4
172
#if (NUMBER_OF_VIRTUAL_EVENTS > 5)
173
,
E5
174
#if (NUMBER_OF_VIRTUAL_EVENTS > 6)
175
,
E6
176
#if (NUMBER_OF_VIRTUAL_EVENTS > 7)
177
,
E7
178
#if (NUMBER_OF_VIRTUAL_EVENTS > 8)
179
,
E8
180
#if (NUMBER_OF_VIRTUAL_EVENTS > 9)
181
,
E9
182
#if (NUMBER_OF_VIRTUAL_EVENTS > 10)
183
,
E10
184
#if (NUMBER_OF_VIRTUAL_EVENTS > 11)
185
,
E11
186
#if (NUMBER_OF_VIRTUAL_EVENTS > 12)
187
,
E12
188
#if (NUMBER_OF_VIRTUAL_EVENTS > 13)
189
,
E13
190
#if (NUMBER_OF_VIRTUAL_EVENTS > 14)
191
,
E14
192
#if (NUMBER_OF_VIRTUAL_EVENTS > 15)
193
,
E15
194
#if (NUMBER_OF_VIRTUAL_EVENTS > 16)
195
,
E16
196
#if (NUMBER_OF_VIRTUAL_EVENTS > 17)
197
,
E17
198
#if (NUMBER_OF_VIRTUAL_EVENTS > 18)
199
,
E18
200
#if (NUMBER_OF_VIRTUAL_EVENTS > 19)
201
,
E19
202
#if (NUMBER_OF_VIRTUAL_EVENTS > 20)
203
,
E20
204
#if (NUMBER_OF_VIRTUAL_EVENTS > 21)
205
,
E21
206
#if (NUMBER_OF_VIRTUAL_EVENTS > 22)
207
,
E22
208
#if (NUMBER_OF_VIRTUAL_EVENTS > 23)
209
,
E23
210
#if (NUMBER_OF_VIRTUAL_EVENTS > 24)
211
,
E24
212
#if (NUMBER_OF_VIRTUAL_EVENTS > 25)
213
,
E25
214
#if (NUMBER_OF_VIRTUAL_EVENTS > 26)
215
,
E26
216
#if (NUMBER_OF_VIRTUAL_EVENTS > 27)
217
,
E27
218
#if (NUMBER_OF_VIRTUAL_EVENTS > 28)
219
,
E28
220
#if (NUMBER_OF_VIRTUAL_EVENTS > 29)
221
,
E29
222
#if (NUMBER_OF_VIRTUAL_EVENTS > 30)
223
,
E30
224
#if (NUMBER_OF_VIRTUAL_EVENTS > 31)
225
,
E31
226
#if (NUMBER_OF_VIRTUAL_EVENTS > 32)
227
,
E32
228
#if (NUMBER_OF_VIRTUAL_EVENTS > 33)
229
,
E33
230
#if (NUMBER_OF_VIRTUAL_EVENTS > 34)
231
,
E34
232
#if (NUMBER_OF_VIRTUAL_EVENTS > 35)
233
,
E35
234
#if (NUMBER_OF_VIRTUAL_EVENTS > 36)
235
,
E36
236
#if (NUMBER_OF_VIRTUAL_EVENTS > 37)
237
,
E37
238
#if (NUMBER_OF_VIRTUAL_EVENTS > 38)
239
,
E38
240
#if (NUMBER_OF_VIRTUAL_EVENTS > 39)
241
,
E39
242
#if (NUMBER_OF_VIRTUAL_EVENTS > 40)
243
,
E40
244
#if (NUMBER_OF_VIRTUAL_EVENTS > 41)
245
,
E41
246
#if (NUMBER_OF_VIRTUAL_EVENTS > 42)
247
,
E42
248
#if (NUMBER_OF_VIRTUAL_EVENTS > 43)
249
,
E43
250
#if (NUMBER_OF_VIRTUAL_EVENTS > 44)
251
,
E44
252
#if (NUMBER_OF_VIRTUAL_EVENTS > 45)
253
,
E45
254
#if (NUMBER_OF_VIRTUAL_EVENTS > 46)
255
,
E46
256
#if (NUMBER_OF_VIRTUAL_EVENTS > 47)
257
,
E47
258
#if (NUMBER_OF_VIRTUAL_EVENTS > 48)
259
,
E48
260
#if (NUMBER_OF_VIRTUAL_EVENTS > 49)
261
,
E49
262
#if (NUMBER_OF_VIRTUAL_EVENTS > 50)
263
,
E50
264
#if (NUMBER_OF_VIRTUAL_EVENTS > 51)
265
,
E51
266
#if (NUMBER_OF_VIRTUAL_EVENTS > 52)
267
,
E52
268
#if (NUMBER_OF_VIRTUAL_EVENTS > 53)
269
,
E53
270
#if (NUMBER_OF_VIRTUAL_EVENTS > 54)
271
,
E54
272
#if (NUMBER_OF_VIRTUAL_EVENTS > 55)
273
,
E55
274
#if (NUMBER_OF_VIRTUAL_EVENTS > 56)
275
,
E56
276
#if (NUMBER_OF_VIRTUAL_EVENTS > 57)
277
,
E57
278
#if (NUMBER_OF_VIRTUAL_EVENTS > 58)
279
,
E58
280
#if (NUMBER_OF_VIRTUAL_EVENTS > 59)
281
,
E59
282
#if (NUMBER_OF_VIRTUAL_EVENTS > 60)
283
,
E60
284
#if (NUMBER_OF_VIRTUAL_EVENTS > 61)
285
,
E61
286
#if (NUMBER_OF_VIRTUAL_EVENTS > 62)
287
,
E62
288
#if (NUMBER_OF_VIRTUAL_EVENTS > 63)
289
,
E63
290
#endif
291
#endif
292
#endif
293
#endif
294
#endif
295
#endif
296
#endif
297
#endif
298
#endif
299
#endif
300
#endif
301
#endif
302
#endif
303
#endif
304
#endif
305
#endif
306
#endif
307
#endif
308
#endif
309
#endif
310
#endif
311
#endif
312
#endif
313
#endif
314
#endif
315
#endif
316
#endif
317
#endif
318
#endif
319
#endif
320
#endif
321
#endif
322
#endif
323
#endif
324
#endif
325
#endif
326
#endif
327
#endif
328
#endif
329
#endif
330
#endif
331
#endif
332
#endif
333
#endif
334
#endif
335
#endif
336
#endif
337
#endif
338
#endif
339
#endif
340
#endif
341
#endif
342
#endif
343
#endif
344
#endif
345
#endif
346
#endif
347
#endif
348
#endif
349
#endif
350
#endif
351
#endif
352
#endif
353
};
Generated on Fri May 22 2015 10:24:04 for FreeEMS by
1.8.1.2