FreeEMS  0.2.0-SNAPSHOT-282-g9efc524
MitsiAndMazda-CAS-4and1.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 allHeaders
30  * @ingroup enginePositionRPMDecoders
31  *
32  * @brief Unique MitsiCAS-4and1 setup data and variables
33  */
34 
35 
36 #define DECODER_MAX_CODE_TIME 150 // To be optimised (shortened)!
37 #define NUMBER_OF_REAL_EVENTS 10
38 #define NUMBER_OF_VIRTUAL_EVENTS 10
39 
40 
41 #include "../../inc/freeEMS.h"
42 #include "../../inc/utils.h"
43 #include "../../inc/interrupts.h"
44 #include "../../inc/decoderInterface.h"
45 
46 
47 // Variables unique to this decoder, should be kept to a minimum!
48 static unsigned short edgeTimeStamp; /// @todo TODO why is this here, and why is it static/shared, investigate
49 static LongTime timeStamp; /// @todo TODO why is this here, and why is it static/shared, investigate
50 unsigned char unknownLeadingEdges = 0;
51 
52 
53 // Event angle setup via defines to minimise the opportunity for human error when changing values
54 #define OuterSlotAngle ANGLE( 69.74) // BUT 69 is too high, and 68 is even more too low = need to refactor to specify these angles accurately enough for perfect RPM/scheduling
55 #define InnerSlotAngle ANGLE(140.00) // WAS 138 // WAS 139 // WAS 137 // Speculation: 140? Close to it... ignore my affection for round numbers... :-) HA! I was close to right this time, the other was right first guess and wants to be a little lower.
56 
57 // Outer slot fixed events - these are, by definition, correct!
58 #define E0 ANGLE( 0)
59 #define E2 ANGLE(180)
60 #define E4 ANGLE(360)
61 #define E7 ANGLE(540)
62 
63 // These are offset from the fixed ones by the angle of the slot
64 #define E1 (E0 + OuterSlotAngle)
65 #define E3 (E2 + OuterSlotAngle)
66 #define E5 (E4 + OuterSlotAngle)
67 #define E8 (E7 + OuterSlotAngle)
68 
69 // Inner slot events
70 #define E6 ANGLE(525.50) // WAS 527 // WAS 526 // Start position measured, just like outer on/off duty.
71 #define E9 (E6 + InnerSlotAngle)
72 
73 
74 // Definitions of decoder interface constants
75 const unsigned short eventAngles[] = {E0, E1, E2, E3, E4, E5, E6, E7, E8, E9}; // needs to be shared with other decoders, defined here and referenced by the scheduler or similar
76 const unsigned char eventValidForCrankSync[] = {1,1,1,1,1,1,0,1,1,0}; // Unused for now, but correct anyway.