Rearranged headers somewhat, much more still to do.
[freeems-vanilla.git] / src / inc / globalConstants.h
blob3e16b346f4b2457c668ead4d5e8434f4e2e34ece
1 /* globalConstants.h
3 Copyright 2008 Fred Cooke
5 This file is part of the FreeEMS project.
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.
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.
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/>.
20 We ask that if you make any changes to this file you send them upstream to us at admin@diyefi.org
22 Thank you for choosing FreeEMS to run your engine! */
24 /* Header file multiple inclusion protection courtesy eclipse Header Template */
25 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
26 #ifndef FILE_GLOBAL_CONSTANTS_H_SEEN
27 #define FILE_GLOBAL_CONSTANTS_H_SEEN
30 /* Types summary
32 * BEWARE : Be explicit!!
34 * char 8 bit (defaults to unsigned, but always specify signed/unsigned anyway)
35 * short 16 bit (defaults to signed, but always specify signed/unsigned anyway)
36 * int 16 bit DO NOT USE! (current compile flags make this 16 bits, but a change of flags could will change your program if you use this because they will all be 32 bit all of a sudden)
37 * long 32 bit (defaults to signed, but always specify signed/unsigned anyway)
38 * long long 64 bit (inefficient, avoid these, if using : defaults to signed, but always specify signed/unsigned anyway)
39 * float 32 bit IEEE floating point numbers (inefficient, avoid these, used fixed point math)
40 * double 64 bit IEEE floating point numbers (inefficient, avoid these, used fixed point math)
44 #ifdef MAIN_OR_GLOBALS
45 #define EXTERN
46 #else
47 #define EXTERN extern
48 #endif
51 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Arrays here &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
53 #ifndef NO_CONST_ARRAYS
55 /* Thermistor ADC to temperature transfer tables as generated by FreeTherm */
56 EXTERN const volatile unsigned short IATTransferTable[1024]; /* 2k */
57 EXTERN const volatile unsigned short CHTTransferTable[1024]; /* 2k */
58 EXTERN const volatile unsigned short MAFTransferTable[1024]; /* 2k */
59 EXTERN const volatile unsigned char TestTransferTable[2048]; /* 2k */
61 EXTERN const unsigned short memdumplength;
62 EXTERN const unsigned short maxBasicDatalogLength;
64 /* Interface version field 8 bit number, 8 bit number, 8 bit number, string of arbitrary length */
65 EXTERN const unsigned char interfaceVersionAndType[20]; /* Should be unique for serial comms */
67 /* Firmware version string of arbitrary length for display and human ID purposes */
68 EXTERN const unsigned char firmwareVersion[47]; /* Should change with even the slightest code change */
70 EXTERN const unsigned short dwellStartMasks[IGNITION_CHANNELS];
71 EXTERN const unsigned short ignitionMasks[IGNITION_CHANNELS];
73 EXTERN const unsigned char injectorMainOnMasks[INJECTION_CHANNELS];
74 EXTERN const unsigned char injectorMainOffMasks[INJECTION_CHANNELS];
75 EXTERN const unsigned char injectorMainEnableMasks[INJECTION_CHANNELS];
76 EXTERN const unsigned char injectorMainDisableMasks[INJECTION_CHANNELS];
77 EXTERN const unsigned char injectorMainGoHighMasks[INJECTION_CHANNELS];
78 EXTERN const unsigned char injectorMainGoLowMasks[INJECTION_CHANNELS];
81 #endif
84 /*&&&&&&&&&&&&&&&&&&&&&&&&&&& NON Arrays here &&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
86 /* Main lookup tables */ // TODO volatile here or not?
87 EXTERN const volatile mainTable VETableMainFlash;
88 EXTERN const volatile mainTable VETableSecondaryFlash;
89 EXTERN const volatile mainTable VETableTertiaryFlash;
90 EXTERN const volatile mainTable LambdaTableFlash;
92 EXTERN const volatile mainTable IgnitionAdvanceTableMainFlash;
93 EXTERN const volatile mainTable IgnitionAdvanceTableSecondaryFlash;
94 EXTERN const volatile mainTable InjectionAdvanceTableMainFlash;
95 EXTERN const volatile mainTable InjectionAdvanceTableSecondaryFlash;
97 EXTERN const volatile mainTable VETableMainFlash2;
98 EXTERN const volatile mainTable VETableSecondaryFlash2;
99 EXTERN const volatile mainTable VETableTertiaryFlash2;
100 EXTERN const volatile mainTable LambdaTableFlash2;
102 EXTERN const volatile mainTable IgnitionAdvanceTableMainFlash2;
103 EXTERN const volatile mainTable IgnitionAdvanceTableSecondaryFlash2;
104 EXTERN const volatile mainTable InjectionAdvanceTableMainFlash2;
105 EXTERN const volatile mainTable InjectionAdvanceTableSecondaryFlash2;
107 EXTERN const volatile SmallTables1 SmallTablesAFlash;
108 EXTERN const volatile SmallTables2 SmallTablesBFlash;
109 EXTERN const volatile SmallTables3 SmallTablesCFlash;
110 EXTERN const volatile SmallTables4 SmallTablesDFlash;
112 EXTERN const volatile SmallTables1 SmallTablesAFlash2;
113 EXTERN const volatile SmallTables2 SmallTablesBFlash2;
114 EXTERN const volatile SmallTables3 SmallTablesCFlash2;
115 EXTERN const volatile SmallTables4 SmallTablesDFlash2;
117 EXTERN const volatile fixedConfig1 fixedConfigs1;
118 EXTERN const volatile fixedConfig2 fixedConfigs2;
120 //EXTERN const twoDTableUS ; // ?
122 /* Fuel correction tables */
123 EXTERN const volatile twoDTableUS primingVolumeTableFlash; // perhaps micro litres (cubic milli meters) would be good, 5 - 100 seem to be the norm 327.68 = 65535/200
124 EXTERN const volatile twoDTableUS injectorDeadTimeTableFlash; // display as ms, units in native 0.8us ticks
125 EXTERN const volatile twoDTableUS postStartEnrichmentTableFlash; // ?
126 EXTERN const volatile twoDTableUS engineTempEnrichmentTableFixedFlash; // ?
127 EXTERN const volatile twoDTableUS engineTempEnrichmentTablePercentFlash; // ?
130 /* Ignition correction tables */
131 EXTERN const volatile twoDTableUS dwellDesiredVersusVoltageTableFlash; // desired dwell vs voltage
132 EXTERN const volatile twoDTableUS dwellMaxVersusRPMTableFlash; // maximum dwell vs rpm
135 /* Fueling constants */
136 EXTERN const unsigned long masterFuelConstant;
137 EXTERN const unsigned long MAFFuelConstant;
140 /* These need to be changed if the timer period is changed at all */
141 /* The number of timer units it takes for the switch on scheduling code to run */
142 EXTERN const unsigned short injectorSwitchOnCodeTime;
143 /* The number of timer units it takes for the switch off scheduling code to run */
144 EXTERN const unsigned short injectorSwitchOffCodeTime;
145 /* The maximum a requested pulsewidth can be before it is truncated to this amount */
146 EXTERN const unsigned short injectorMaximumPulseWidth;
147 /* The minimum a requested pulsewidth can be before it is not switched on at all */
148 EXTERN const unsigned short injectorMinimumPulseWidth;
151 /* Ignition limits */
152 /* Ignition maximum dwell in timer units */
153 EXTERN const unsigned short ignitionMaximumDwell;
155 /* Ignition minimum dwell in timer units */
156 EXTERN const unsigned short ignitionMinimumDwell;
158 /* Ignition maximum delay post schedule tooth in timer units */
159 EXTERN const unsigned short ignitionMaximumDelayToDwellStartAfterTooth;
162 /* Time in ticks taken to run */
163 EXTERN const unsigned short leadingEdgePrimaryRPMInputCodeTime;
164 EXTERN const unsigned short trailingEdgePrimaryRPMInputCodeTime;
165 EXTERN const unsigned short leadingEdgeSecondaryRPMInputCodeTime;
166 EXTERN const unsigned short trailingEdgeSecondaryRPMInputCodeTime;
169 #undef EXTERN
172 #else
173 /* let us know if we are being untidy with headers */
174 #warning "Header file GLOBAL_CONSTANTS_H seen before, sort it out!"
175 /* end of the wrapper ifdef from the very top */
176 #endif