FreeEMS  0.2.0-SNAPSHOT-285-g028e24c
MitsiAndMazda-CAS-4and2.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2012-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 allHeaders
30  * @ingroup enginePositionRPMDecoders
31  *
32  * @brief Unique MitsiCAS-4and2 setup data and variables
33  *
34  * Development thread: http://forum.diyefi.org/viewtopic.php?f=56&t=1110
35  */
36 
37 
38 #define DECODER_MAX_CODE_TIME 150 // To be optimised (shortened)!
39 #define NUMBER_OF_REAL_EVENTS 12
40 #define NUMBER_OF_VIRTUAL_EVENTS 12
41 
42 
43 #include "../../inc/freeEMS.h"
44 #include "../../inc/utils.h"
45 #include "../../inc/interrupts.h"
46 #include "../../inc/decoderInterface.h"
47 
48 
49 // Variables unique to this decoder, should be kept to a minimum!
50 static unsigned short edgeTimeStamp; /// @todo TODO why is this here, and why is it static/shared, investigate
51 static LongTime timeStamp; /// @todo TODO why is this here, and why is it static/shared, investigate
52 unsigned char doubleHighSeen = 0;
53 
54 
55 // Slot angles used below
56 #define OuterSlotAngle ANGLE( 69.74)
57 #define LargeInnerSlotAngle ANGLE(140.00)
58 #define SmallInnerSlotAngle ANGLE(70.00) // TODO @todo fine tune!
59 
60 // Outer slot fixed events - these are, by definition, correct!
61 #define E0 ANGLE( 0)
62 #define E3 ANGLE(180)
63 #define E6 ANGLE(360)
64 #define E9 ANGLE(540)
65 
66 // These are offset from the fixed ones by the angle of the slot
67 #define E1 (E0 + OuterSlotAngle)
68 #define E5 (E3 + OuterSlotAngle)
69 #define E7 (E6 + OuterSlotAngle)
70 #define E10 (E9 + OuterSlotAngle)
71 
72 // Large inner slot events
73 #define E8 ANGLE(525.50)
74 #define E11 (E8 + LargeInnerSlotAngle)
75 
76 // Small inner slot events
77 #define E2 E8 - ANGLE(360) // TODO verify this is really exactly 360 including diffraction effects
78 #define E4 (E2 + SmallInnerSlotAngle)
79 
80 
81 // Definitions of decoder interface constants
82 const unsigned short eventAngles[] = {E0, E1, E2, E3, E4, E5, E6, E7, E8, E9, E10, E11};
83 const unsigned char eventValidForCrankSync[] = {1,1,1,1,1,1,0,1,1,0}; // Unused for now, but correct anyway.