00001 /* FreeEMS - the open source engine management system 00002 * 00003 * Copyright 2010 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 00026 00039 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00040 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00041 #ifndef FILE_DECODER_INTERFACE_H_SEEN 00042 #define FILE_DECODER_INTERFACE_H_SEEN 00043 00044 00045 // RPM Calculations: 00046 // 00047 // Either need a per decoder function that is called from the main loop OR... 00048 // RPM calculation is done in real time inside one of the RPM interrupts OR... 00049 // The choice of either, up to the decoder to decide how it is done, in this 00050 // case the function can either do nothing, or swap some pointers/var values 00051 // around or similar. 00052 00053 // MAP Sampling: 00054 // 00055 // Max number of samples = max number of cylinders, has to be handled by decoder due to 00056 // potential mismatch between wheel pattern and cylinder firing pattern. 00057 00058 // Scheduling: 00059 // 00060 // arrays of output channels, iterate and check for wheel event number, if matched, fire: 00061 // doesn't allow for firing a pin more than once a cycle!! no use. 00062 // allows multi channel on a single wheel event (virtually useless) but is slow, one loop 00063 // and array per type of output channel. 00064 // 00065 // array of wheel events, do lookup for wheel event, then if output channel valid, schedule it. 00066 // single channel per tooth event (acceptable, wire in parallel if required), fast, memory hog, 00067 // need one array per type of channel, array length = max expected tooth count! do we need to 00068 // support every single tooth on a nissan 360 style decoder or just cyl event count, what about 00069 // porsche 130? next stop is 60, seems good. can we use bit-fields to save memory, 1 bit = 00070 // 2 possible pins, 2 bits = 4, etc, this will be slower, though. probably just an unsigned char[] 00071 00072 00073 // TODO @todo the below vars are just drafts so far, nothing is used, except the RPM stuff which I migrated here from the main header. More work to come. 00074 #define numberOfWheelEvents 1 // not teeth, teeth is misleading - could be leading or trailing edge or both 00075 unsigned char currentWheelEvent; // Current or last wheel event index. 00076 unsigned long wheelEventTimeStamps[numberOfWheelEvents]; // For logging wheel patterns as observed. LOTS of memory :-/ may not be possible except by sending lastStamp rapidly at low RPM 00077 unsigned short* RPM; // final output variable, probably move into inputVars struct? 00078 unsigned short* RPMRecord; // intermediate storage variable, do something with this? 00079 unsigned char ignitionEvents[6]; 00080 unsigned char injectionEvents[12]; 00081 unsigned char ADCSampleEvents[12]; // ??? 00082 unsigned char stagedInjectionEvents; // ??? 00083 unsigned char chickenCookerEvents; // ??? 00084 00085 00086 // Init routine: 00087 // 00088 // Allow configuration of timer details? tick size? If so, need to introduce scaling to calcs to 00089 // produce correct tick count and therefore pulsewidth. Migrate dead time to time units and scale 00090 // to get ticks to add to final pw. 00091 // 00092 // We require some configuration to allow the Nissan style decoder to use the pulse accumulators to 00093 // count those one degree slots accurately to a high rpm without excessive cpu load. 00094 00095 00096 // move the following to fuel calcs or sched code header, it doesn't belong here... 00097 // 00098 // stuff to do with timing and sync etc. ie, figuring out upon which 00099 00100 00101 00102 #else 00103 /* let us know if we are being untidy with headers */ 00104 #warning "Header file DECODER_INTERFACE_H seen before, sort it out!" 00105 /* end of the wrapper ifdef from the very top */ 00106 #endif