Remove custom datalog file and search path hack now redundant due to fully customisab...
[freeems-vanilla.git] / src / globalConstants.c
blobfed04a1be9e851cdc4fa5e98fd10054846579035
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 dataInitialisers
31 * @brief Global constant values
33 * All global constants values are, and should be, defined here.
37 #define GLOBAL_CONSTANTS_C
38 #define NO_CONST_ARRAYS
39 #include "inc/freeEMS.h"
42 /* Constants */
43 /* &&&&&&&&&& WARNING &&&&&&&&&& These need to be changed if the timer period is changed at all!! &&&&&&&&&& WARNING &&&&&&&&&& */
44 /* TODO It may be better to make these actual times and calculate the number of timer units such that a change in time base of the timer doesn't affect the code. */
46 /** Serial interface unique identifier
48 * This should only change when the serial interface changes (even a little)
50 * This field consists of 3 chars for a 3 part version number and a free form string. For any unique string the version
51 * number is also unique. In this way tools can easily support a range of versions for a specific unique string ID
53 const unsigned char interfaceVersion[INTERFACE_VERSION_LENGTH] = { INTERFACE_VERSION }; // TODO change spec to not have numerics and to parse from string, maybe pull from somewhere?
55 /** Displayable firmware version identifier
57 * This should change every time the code is changed at all (even a little) before each release.
59 const unsigned char firmwareVersion[FIRMWARE_VERSION_LENGTH] = { FIRMWARE_VERSION "-" BUILD_CONFIG }; // TODO shorten the comments here, add docs and refer to them
60 const unsigned char buildTimeAndDate[FIRMWARE_BUILD_DATE_LENGTH] = { FIRMWARE_BUILD_DATE }; ///< GCC supplied compiler version
61 const unsigned char compilerVersion[COMPILER_VERSION_LENGTH] = { __VERSION__ }; ///< GCC supplied compiler version
62 const unsigned char operatingSystem[OPERATING_SYSTEM_LENGTH] = { OPERATING_SYSTEM }; ///< Operating system type
64 /** Divisors and untunable physical constants combined into a single master fuel constant
66 * const unsigned short molarMassOfAir = 2897; // in grams per 100 moles, so divide by 100 to get gm/mol
67 * const unsigned short msToTicks = 1250; // constant to bring ms into 0.8us chunks
68 * const unsigned short universalGasConstant = 34056; // 8.314472 * 4096, so divide by 4096 to get real number
70 * hash define injectorFlowDivisor 1024
71 * hash define injectorFlowUnitDivisor 1000 - to get it into litres/second
72 * hash define injectorFlowTotalDivisor 1024000
73 * hash define stoichiometricAFRDivisor 1024
74 * hash define universalGasConstantDivisor 4096
75 * hash define molarMassOfAirDivisor 100
76 * hash define perCylinderVolumeDivisor 32768
78 * TODO hash define the fuel constant for different clock tick setups (msToTicks will vary)
80 * master = (msToTicks * molarMassOfAir * universalGasConstantDivisor * stoichiometricAFRDivisor * injectorFlowTotalDivisor) / (universalGasConstant * molarMassOfAirDivisor * perCylinderVolumeDivisor);
81 * master = (1250 * 2897 * 4096 * 1024 * 1024000 ) / (34056 * 100 * 32768 );
82 * http://duckduckgo.com/?q=%28%281250+*+2897+*+4096+*+1024+*+1024000%29+%2F+%2834056+*++100+*+32768%29
84 * ((1250 * 2897 * 4096 * 1024 * 1024000) / (34056 * 100 * 32768) = 139371764
86 const unsigned long masterFuelConstant = 139371764;
88 /** MAF fuel constant
90 * @todo TODO Determine what the value of MAF fuel constant should be
92 const unsigned long MAFFuelConstant = 0;
94 /// @todo TODO Move these to decoder interface AND rename to be more generic/meaningful/accurate, and make set by each decoder where appropriate
95 ///* Injection limits */
96 /* The number of timer units it takes for the switch on scheduling code to run + latencies */
97 const unsigned short injectorSwitchOnCodeTime = 250; /* Used to set min pw in output ISR. 250 is based on worst of decoders causing latencies. */
98 /* The number of timer units it takes for the switch off scheduling code to run + latencies */
99 const unsigned short injectorSwitchOffCodeTime = 250; /* Used to see if we should set self sched or not. 250 is based on worst of decoders causing latencies. */
101 // TODO put these where they belong, just dumped from other file for now...
102 /* Main injector channel bit masks and registers for use in both injection_isrs.c and engine_position_isrs.c */
103 /* Masks for setting mainOn flags and checking state of pin and therefore which change of state just occured */
104 /* Masks for clearing mainOn flags */
105 /* Masks for setting mainOn flags and checking state of pin and therefore which change of state just occured */
106 /* Masks to be used with |= to switch a channel to "turn on compare" mode */
107 /* Masks to be used dissable with &= to switch a channel to "turn off compare" mode */
108 /* Masks to be used with |= to switch a channel to "turn on on compare" mode from "turn off on compare" mode */
109 /* Masks to be used with &= to switch a channel to "turn off on compare" mode from "turn on on compare" mode */
110 /* Ignition channel bit masks for use in both PIT timer ISRs and engine_position_isrs.c */
111 /* Masks for setting ignition status bits and turning on the channels themselves */
112 /* Masks for clearing ignition status bits and turning off the channels themselves */
115 /* Injection masks */
117 // To be used with flag vars and TIE and TFLG
118 const unsigned char injectorMainOnMasks[INJECTION_CHANNELS] = {BIT2, BIT3, BIT4, BIT5, BIT6, BIT7};
119 const unsigned char injectorMainOffMasks[INJECTION_CHANNELS] = {NBIT2, NBIT3, NBIT4, NBIT5, NBIT6, NBIT7};
121 // To be used in conjunction with injectorMainControlRegisters
122 const unsigned char injectorMainActiveMasks[INJECTION_CHANNELS] = {BIT5, BIT7, BIT1, BIT3, BIT5, BIT7}; // Is this enabled for go high OR go low?
123 const unsigned char injectorMainEnableMasks[INJECTION_CHANNELS] = {0x30, 0xC0, 0x03, 0x0C, 0x30, 0xC0}; // Regardless of state, mask to enable and cause to go high
124 const unsigned char injectorMainDisableMasks[INJECTION_CHANNELS] = {0xCF, 0x3F, 0xFC, 0xF3, 0xCF, 0x3F}; // Regardless of state, mask to disable completely
125 const unsigned char injectorMainGoHighMasks[INJECTION_CHANNELS] = {BIT4, BIT6, BIT0, BIT2, BIT4, BIT6}; // Already enabled, mask to change from go low to go high
126 const unsigned char injectorMainGoLowMasks[INJECTION_CHANNELS] = {NBIT4, NBIT6, NBIT0, NBIT2, NBIT4, NBIT6}; // Already enabled, mask to change from go high to go low