FreeEMS  0.2.0-SNAPSHOT-285-g028e24c
TunableConfigs.h
Go to the documentation of this file.
1 /* FreeEMS - the open source engine management system
2  *
3  * Copyright 2008-2013 Fred Cooke
4  *
5  * This file is part of the FreeEMS project.
6  *
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.
11  *
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.
16  *
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/
19  *
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!
22  *
23  * Thank you for choosing FreeEMS to run your engine!
24  */
25 
26 
27 /** @file
28  *
29  * @ingroup allHeaders
30  * @ingroup globalHeaders
31  * @ingroup dataStructures
32  *
33  * @brief Struct typedefs for tunable configuration
34  *
35  * This file contains both the struct data type definitions and the arrays of
36  * default values for small tables. Place reusable definitions of default table
37  * values in here such that they can be used in multiple tunable table definitions.
38  *
39  * You should add your configuration item here if it is best that it is adjusted with
40  * instant results on a running engine. For everything else, please consider placing
41  * it in one of the fixed configuration structs.
42  */
43 
44 
45 /* Header file multiple inclusion protection courtesy eclipse Header Template */
46 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
47 #ifndef FILE_TUNABLE_CONFIGS_H_SEEN
48 #define FILE_TUNABLE_CONFIGS_H_SEEN
49 
50 
51 /** Holds a datalog chunk configuration pair.
52  *
53  * A datalog configuration pair consists of an address and a size.
54  */
55 typedef struct {
56  void* address;
57  unsigned short size;
58 } logChunk;
59 
60 
61 #define MAX_LOG_CHUNKS 16
62 /** Holds all configuration for logging.
63  *
64  * These are in tunable config such that the system can pick up where it left
65  * off if reset with settings burned to flash, or simply switch back to default
66  * if changed in ram and not burned and then reset.
67  */
68 typedef struct {
69  unsigned char datalogStreamType; ///< Which type of datalog to pump out as fast as we can. @see commsCore.h
70  unsigned char datalogPollingType; ///< Which type of datalog to pump out as fast as we can. @see commsCore.h
71  unsigned char firstChunk; ///< The index of the first chunk to send.
72  unsigned char numberOfChunks; ///< How many chunks to send.
73  logChunk logChunks[MAX_LOG_CHUNKS]; ///< Array of chunk sets so as to have on-board presets available to quickly swap to.
74  void* datalogByteStreamSourceAddress; ///< Where to grab our data from.
75  void* datalogWordStreamSourceAddress; ///< Where to grab our data from.
76  void* datalogLongStreamSourceAddressFirst; ///< Where to grab our data from. If the second address is set to zero, get 4 bytes from this address.
77  void* datalogLongStreamSourceAddressSecond; ///< Where to grab our data from. If this is non-zero, get 2 bytes from the first address and 2 from this address.
78  // TODO scratch pad configs
80 
81 
82 #define SMALL_TABLES_1_FILLER_SIZE (flashSectorSize - (sizeof(twoDTableUS) * 9)) // Update this if adding another table!
83 /**
84  * One of four structs of live tunable data such as small tables and fuel trims
85  * etc. If you add something here, please ensure you update all of the following :
86  * - Default values in the initial definitions in TunableConfig.c and TunableConfig2.c
87  * - The address values within the initPagedRAMTune() function in init.c
88  * - The lookupBlockDetails() function in blockDetailsLookup.c
89  * - The JSON data map and other related firmware interface definition files
90  *
91  */
92 typedef struct {
93  twoDTableUS dwellDesiredVersusVoltageTable; ///< Standard dwell curve dependent on voltage.
94  twoDTableUS injectorDeadTimeTable; ///< Injector dead time curve dependent on voltage.
95  twoDTableUS postStartEnrichmentTable; ///< Unused at this time.
96  twoDTableUS postStartTaperTimeTable; ///< Unused at this time.
97  twoDTableUS engineTempEnrichmentTableFixed; ///< Unused at this time.
98  twoDTableUS primingVolumeTable; ///< @todo TODO define units. perhaps micro litres (cubic milli meters) would be good, 5 - 100 seem to be the norm 327.68 = 65535/200
99  twoDTableUS engineTempEnrichmentTablePercent; ///< Engine temperature enrichment by percent, AKA warmup curve.
100  twoDTableUS dwellVersusRPMTable; ///< Useful for certain setups, will generalise later.
101  twoDTableUS blendVersusRPMTable; ///< Used to combine Speed Density and Alpha-N algorithms based on RPM
102  unsigned char filler[SMALL_TABLES_1_FILLER_SIZE];
103 } SmallTables1;
104 
105 
106 #define SMALL_TABLES_2_FILLER_SIZE (flashSectorSize - (sizeof(loggingSetting) + 12)) // Update this if adding another table/struct!
107 /** @copydoc SmallTables1 */
108 typedef struct {
109  loggingSetting loggingSettings; ///< @copydoc loggingSetting
110  unsigned short perCylinderFuelTrims[ECT_CHANNELS]; ///< Trims for injection, from 0% to 200% of base.
111  unsigned char filler[SMALL_TABLES_2_FILLER_SIZE]; ///< Padding data.
112 } SmallTables2;
113 
114 
115 #define SMALL_TABLES_3_FILLER_SIZE flashSectorSize // Update this if adding a table!
116 /** @copydoc SmallTables1 */
117 typedef struct {
118  unsigned char filler[SMALL_TABLES_3_FILLER_SIZE]; ///< Padding data.
119 } SmallTables3;
120 
121 
122 #define SMALL_TABLES_4_FILLER_SIZE flashSectorSize // Update this if adding a table!
123 /** @copydoc SmallTables1 */
124 typedef struct {
125  unsigned char filler[SMALL_TABLES_4_FILLER_SIZE]; ///< Padding data.
126 } SmallTables4;
127 
128 
129 #else
130  /* let us know if we are being untidy with headers */
131  #warning "Header file TUNABLE_CONFIGS_H seen before, sort it out!"
132 /* end of the wrapper ifdef from the very top */
133 #endif