00001 /* FreeEMS - the open source engine management system 00002 00003 Copyright 2008 Fred Cooke 00004 00005 This file is part of the FreeEMS project. 00006 00007 FreeEMS software is free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 FreeEMS software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ 00019 00020 We ask that if you make any changes to this file you email them upstream to 00021 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! 00022 00023 Thank you for choosing FreeEMS to run your engine! */ 00024 00025 00037 #define GLOBAL_CONSTANTS_C 00038 #define NO_CONST_ARRAYS 00039 #include "inc/freeEMS.h" 00040 00041 00042 /* Types summary 00043 * 00044 * BEWARE : Be explicit!! 00045 * 00046 * char 8 bit (defaults to unsigned, but always specify signed/unsigned anyway) 00047 * short 16 bit (defaults to signed, but always specify signed/unsigned anyway) 00048 * 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) 00049 * long 32 bit (defaults to signed, but always specify signed/unsigned anyway) 00050 * long long 64 bit (inefficient, avoid these, if using : defaults to signed, but always specify signed/unsigned anyway) 00051 * float 32 bit IEEE floating point numbers (inefficient, avoid these, used fixed point math) 00052 * double 64 bit IEEE floating point numbers (inefficient, avoid these, used fixed point math) 00053 */ 00054 00055 00056 const unsigned short memdumplength = 0x100; 00057 const unsigned short maxBasicDatalogLength = sizeof(CoreVar) + sizeof(DerivedVar) + sizeof(ADCArray); 00058 00059 00060 /* Constants */ 00061 /* &&&&&&&&&& WARNING &&&&&&&&&& These need to be changed if the timer period is changed at all!! &&&&&&&&&& WARNING &&&&&&&&&& */ 00062 /* 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. */ 00063 00071 const unsigned char interfaceVersionAndType[20] = {0,0,2,'I','F','r','e','e','E','M','S',' ','V','a','n','i','l','l','a',0}; 00072 00077 const unsigned char firmwareVersion[45] = {"FreeEMS Vanilla 0.0.19 Doxygenated pre-alpha"}; 00078 00099 const unsigned long masterFuelConstant = 139371764; 00100 00105 const unsigned long MAFFuelConstant = 0; 00106 00107 /* Injection limits */ 00108 /* The number of timer units it takes for the switch on scheduling code to run */ 00109 const unsigned short injectorSwitchOnCodeTime = 100; /* Measured 4 timer cycles, going on the safe side by a lot, and limiting minimum pulse to 0.02ms which is well below any dead time I've heard of */ 00110 00111 /* The number of timer units it takes for the switch off scheduling code to run */ 00112 const unsigned short injectorSwitchOffCodeTime = 100; /* This is actually shorter than the switch on time above as measured between 0.0.8 and 0.0.9 */ 00113 00114 /* The maximum a requested pulsewidth can be before it is truncated to this amount */ 00115 const unsigned short injectorMaximumPulseWidth = 0xF424; /* 62500 clock cycles, = exactly 50ms, which is an arbitrary limit but I like round numbers :-) */ 00116 00117 /* The minimum a requested pulsewidth can be before it is not switched on at all */ 00118 const unsigned short injectorMinimumPulseWidth = 100; 00119 00120 00121 /* Ignition limits */ 00122 /* Ignition maximum dwell in timer units */ 00123 const unsigned short ignitionMaximumDwell = 50000; /* meaningless us value for now, currently unused */ 00124 00125 /* Ignition minimum dwell in timer units */ 00126 const unsigned short ignitionMinimumDwell = 500; /* meaningless us value for now, currently unused */ 00127 00128 /* Ignition maximum delay post schedule tooth in timer units */ 00129 const unsigned short ignitionMaximumDelayToDwellStartAfterTooth = 50000; /* (max retard) meaningless us value for now, currently unused */ 00130 00131 /* Ignition maximum delay post schedule tooth in timer units */ 00132 const unsigned short ignitionMinimumDelayToDwellStartAfterTooth = 500; /* (max advance) meaningless us value for now, currently unused */ 00133 00134 00135 /* Engine position/RPM decoder limits */ 00136 /* */ 00137 const unsigned short leadingEdgePrimaryRPMInputCodeTime = 100; /* random large safe value */ 00138 00139 /* */ 00140 const unsigned short trailingEdgePrimaryRPMInputCodeTime = 100; /* random large safe value */ 00141 00142 /* */ 00143 const unsigned short leadingEdgeSecondaryRPMInputCodeTime = 100; /* random large safe value */ 00144 00145 /* */ 00146 const unsigned short trailingEdgeSecondaryRPMInputCodeTime = 100; /* random large safe value */ 00147 00148 // TODO put these where they belong, just dumped from other file for now... 00149 /* Main injector channel bit masks and registers for use in both injection_isrs.c and engine_position_isrs.c */ 00150 /* Masks for setting mainOn flags and checking state of pin and therefore which change of state just occured */ 00151 /* Masks for clearing mainOn flags */ 00152 /* Masks for setting mainOn flags and checking state of pin and therefore which change of state just occured */ 00153 /* Masks to be used with |= to switch a channel to "turn on compare" mode */ 00154 /* Masks to be used dissable with &= to switch a channel to "turn off compare" mode */ 00155 /* Masks to be used with |= to switch a channel to "turn on on compare" mode from "turn off on compare" mode */ 00156 /* Masks to be used with &= to switch a channel to "turn off on compare" mode from "turn on on compare" mode */ 00157 /* Ignition channel bit masks for use in both PIT timer ISRs and engine_position_isrs.c */ 00158 /* Masks for setting ignition status bits and turning on the channels themselves */ 00159 /* Masks for clearing ignition status bits and turning off the channels themselves */ 00160 00161 00162 /* Dwell masks { CYL1 B0, CYL2 B1, CYL3 B2, CYL4 B3, CYL5 B4, CYL6 B5, CYL7 B6, CYL8 B7, CYL9 A0,CYL10 A1,CYL11 A2,CYL12 A3}; */ 00163 const unsigned short dwellStartMasks[IGNITION_CHANNELS] = { BIT8_16, BIT9_16, BIT10_16, BIT11_16, BIT12_16, BIT13_16, BIT14_16, BIT15_16, BIT0_16, BIT1_16, BIT2_16, BIT3_16}; /* Set of masks such that a cylinder can be dwelled with a single line of code */ 00164 const unsigned short ignitionMasks[IGNITION_CHANNELS] = {NBIT8_16,NBIT9_16,NBIT10_16,NBIT11_16,NBIT12_16,NBIT13_16,NBIT14_16,NBIT15_16,NBIT0_16,NBIT1_16,NBIT2_16,NBIT3_16}; /* Set of masks such that a cylinder can be fired with a single line of code */ 00165 00166 /* Injection masks */ 00167 const unsigned char injectorMainOnMasks[INJECTION_CHANNELS] = {BIT2, BIT3, BIT4, BIT5, BIT6, BIT7}; 00168 const unsigned char injectorMainOffMasks[INJECTION_CHANNELS] = {NBIT2, NBIT3, NBIT4, NBIT5, NBIT6, NBIT7}; 00169 const unsigned char injectorMainEnableMasks[INJECTION_CHANNELS] = {0x30, 0xC0, 0x03, 0x0C, 0x30, 0xC0}; 00170 const unsigned char injectorMainDisableMasks[INJECTION_CHANNELS] = {0xCF, 0x3F, 0xFC, 0xF3, 0xCF, 0x3F}; 00171 const unsigned char injectorMainGoHighMasks[INJECTION_CHANNELS] = {BIT4, BIT6, BIT0, BIT2, BIT4, BIT6}; 00172 const unsigned char injectorMainGoLowMasks[INJECTION_CHANNELS] = {NBIT4, NBIT6, NBIT0, NBIT2, NBIT4, NBIT6};