Add PLL lock lost/gained interrupt handler, sync loss reason, ign/inj cuts, and flagg...
[freeems-vanilla.git] / src / main / inc / globalConstants.h
blob0b241536bd339c1157cc3cadbb1c82df01afbd07
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2012 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 email them upstream to
21 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 * Thank you for choosing FreeEMS to run your engine!
27 /** @file
29 * @ingroup allHeaders
30 * @ingroup globalHeaders
32 * @brief Global constant declarations
34 * All global constants are declared in this file for use throughout the program.
38 /* Header file multiple inclusion protection courtesy eclipse Header Template */
39 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
40 #ifndef FILE_GLOBAL_CONSTANTS_H_SEEN
41 #define FILE_GLOBAL_CONSTANTS_H_SEEN
44 #ifdef EXTERN
45 #warning "EXTERN already defined by another header, please sort it out!"
46 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
47 #endif
50 #ifdef GLOBAL_CONSTANTS_C
51 #define EXTERN
52 #else
53 #define EXTERN extern
54 #endif
57 #define INTERFACE_VERSION "IFreeEMS Vanilla 0.0.0" // Migrate to come from the makefile where it can be extracted from any file with any tool.
59 // Sizes for array must be outside ifndef block
60 #define INTERFACE_VERSION_LENGTH sizeof(INTERFACE_VERSION)
61 #define FIRMWARE_VERSION_LENGTH sizeof(FIRMWARE_VERSION) + sizeof(BUILD_CONFIG) + 1
62 #define FIRMWARE_BUILD_DATE_LENGTH sizeof(FIRMWARE_BUILD_DATE)
63 #define COMPILER_VERSION_LENGTH sizeof(__VERSION__)
64 #define OPERATING_SYSTEM_LENGTH sizeof(OPERATING_SYSTEM)
67 /*&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Arrays here &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
69 #ifndef NO_CONST_ARRAYS
71 /* Thermistor ADC to temperature transfer tables as generated by FreeTherm */
72 EXTERN const volatile unsigned short IATTransferTable[1024]; /* 2k */
73 EXTERN const volatile unsigned short CHTTransferTable[1024]; /* 2k */
74 EXTERN const volatile unsigned short MAFTransferTable[1024]; /* 2k */
75 EXTERN const volatile unsigned char TestTransferTable[2048]; /* 2k */
78 EXTERN const unsigned char interfaceVersion[INTERFACE_VERSION_LENGTH];
79 EXTERN const unsigned char firmwareVersion[FIRMWARE_VERSION_LENGTH];
80 EXTERN const unsigned char buildTimeAndDate[FIRMWARE_BUILD_DATE_LENGTH];
81 EXTERN const unsigned char compilerVersion[COMPILER_VERSION_LENGTH];
82 EXTERN const unsigned char operatingSystem[OPERATING_SYSTEM_LENGTH];
85 /* Injection (currently used for both inj and ign) */
86 EXTERN const unsigned char injectorMainOnMasks[INJECTION_CHANNELS];
87 EXTERN const unsigned char injectorMainOffMasks[INJECTION_CHANNELS];
88 EXTERN const unsigned char injectorMainActiveMasks[INJECTION_CHANNELS];
89 EXTERN const unsigned char injectorMainEnableMasks[INJECTION_CHANNELS];
90 EXTERN const unsigned char injectorMainDisableMasks[INJECTION_CHANNELS];
91 EXTERN const unsigned char injectorMainGoHighMasks[INJECTION_CHANNELS];
92 EXTERN const unsigned char injectorMainGoLowMasks[INJECTION_CHANNELS];
94 #endif
97 /*&&&&&&&&&&&&&&&&&&&&&&&&&&& NON Arrays here &&&&&&&&&&&&&&&&&&&&&&&&&&&&*/
99 /* Main lookup tables */ // TODO volatile here or not?
100 EXTERN const volatile mainTable VETableMainFlash;
101 EXTERN const volatile mainTable VETableSecondaryFlash;
102 EXTERN const volatile mainTable VETableTertiaryFlash;
103 EXTERN const volatile mainTable LambdaTableFlash;
105 EXTERN const volatile mainTable IgnitionAdvanceTableMainFlash;
106 EXTERN const volatile mainTable IgnitionAdvanceTableSecondaryFlash;
107 EXTERN const volatile mainTable InjectionAdvanceTableMainFlash;
108 EXTERN const volatile mainTable InjectionAdvanceTableSecondaryFlash;
110 EXTERN const volatile mainTable VETableMainFlash2;
111 EXTERN const volatile mainTable VETableSecondaryFlash2;
112 EXTERN const volatile mainTable VETableTertiaryFlash2;
113 EXTERN const volatile mainTable LambdaTableFlash2;
115 EXTERN const volatile mainTable IgnitionAdvanceTableMainFlash2;
116 EXTERN const volatile mainTable IgnitionAdvanceTableSecondaryFlash2;
117 EXTERN const volatile mainTable InjectionAdvanceTableMainFlash2;
118 EXTERN const volatile mainTable InjectionAdvanceTableSecondaryFlash2;
120 EXTERN const volatile SmallTables1 SmallTablesAFlash;
121 EXTERN const volatile SmallTables2 SmallTablesBFlash;
122 EXTERN const volatile SmallTables3 SmallTablesCFlash;
123 EXTERN const volatile SmallTables4 SmallTablesDFlash;
125 EXTERN const volatile SmallTables1 SmallTablesAFlash2;
126 EXTERN const volatile SmallTables2 SmallTablesBFlash2;
127 EXTERN const volatile SmallTables3 SmallTablesCFlash2;
128 EXTERN const volatile SmallTables4 SmallTablesDFlash2;
130 EXTERN const volatile fixedConfig1 fixedConfigs1;
131 EXTERN const volatile fixedConfig2 fixedConfigs2;
134 /* Fueling constants */
135 EXTERN const unsigned long masterFuelConstant;
136 EXTERN const unsigned long MAFFuelConstant;
139 /// @todo TODO Move these to decoder interface AND rename to be more generic/meaningful/accurate, and make set by each decoder where appropriate
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;
147 #undef EXTERN
150 #else
151 /* let us know if we are being untidy with headers */
152 #warning "Header file GLOBAL_CONSTANTS_H seen before, sort it out!"
153 /* end of the wrapper ifdef from the very top */
154 #endif