forked from irvined1982/arduino-megasquirt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MegaSquirt.h
161 lines (134 loc) · 3.29 KB
/
MegaSquirt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/* Copyright 2011 David Irvine
*
* This file is part of Loguino
*
* Loguino is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Loguino is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with Loguino. If not, see <http://www.gnu.org/licenses/>.
* $Rev: 142 $
* $Author: irvined $
* $Date: 2012-04-27 18:13:49 +0100 (Fri, 27 Apr 2012) $
*/
#ifndef MegaSquirt_h
#define MegaSquirt_h
#define LAMBDA 14.1
#define MS_TABLE_LENGTH 112
#define MS_MAX_RETRY_COUNT 30
#define MS_WAIT_TIME 100
#ifndef MS_PORT
#define MS_PORT Serial
#endif
#define MS_COMM_SUCCESS 0
#define MS_ERR_COMM_TIMEOUT 1
#define MS_ERR_COMM_OVERFLOW 2
#include "Arduino.h"
class MegaSquirtData
{
bool get_bit(byte b, int p);
byte reg[MS_TABLE_LENGTH];
public:
bool loadData(byte newReg[MS_TABLE_LENGTH]);
uint16_t seconds();
uint16_t pulseWidth1();
uint16_t pulseWidth2();
uint16_t rpm();
int16_t advance();
uint8_t squirt();
bool firing1();
bool firing2();
bool sched1();
bool inj1();
bool sched2();
bool inj2();
uint8_t engine();
bool ready();
bool crank();
bool startw();
bool warmup();
bool tpsaen();
bool tpsden();
bool mapaen();
uint8_t afrtgt1();
uint8_t afrtgt2();
uint8_t wbo2_en1();
uint8_t wbo2_en2();
int16_t barometer();
int16_t map();
int16_t mat();
int16_t coolant();
int16_t tps();
int16_t batteryVoltage();
int16_t afr1();
int16_t afr2();
int16_t lambda1();
int16_t lambda2();
int16_t knock();
int16_t egoCorrection1();
int16_t egoCorrection();
int16_t egoCorrection2();
int16_t airCorrection();
int16_t warmupEnrich();
int16_t accelEnrich();
int16_t tpsfuelcut();
int16_t baroCorrection();
int16_t gammaEnrich();
int16_t veCurr1();
int16_t veCurr2();
int16_t veCurr();
int16_t iacstep();
int16_t coldAdvDeg();
int16_t tpsDOT();
int16_t mapDOT();
int16_t dwell();
int16_t maf();
int16_t calcMAP();
int16_t fuelCorrection();
uint16_t portStatus();
bool port0();
bool port1();
bool port2();
bool port3();
bool port4();
bool port5();
bool port6();
uint8_t knockRetard();;
int16_t xTauFuelCorr1();
int16_t egoV1();
int16_t egoV2();
int16_t amcUpdates();
int16_t kpaix();
int16_t xTauFuelCorr2();
int16_t spare1();
int16_t spare2();
int16_t trig_fix();
int16_t spare4();
int16_t spare5();
int16_t spare6();
int16_t spare7();
int16_t spare8();
int16_t spare9();
int16_t spare10();
uint16_t tachCount();
uint8_t ospare();
uint8_t cksum();
uint32_t deltaT();
};
class MegaSquirt
{
public:
static byte begin();
static byte runCommand(byte cmd[], byte cmdLength, byte data[], byte dataLength);
static byte signature(String *sig);
static byte seconds(uint16_t *secs);
static byte revision(String *rev);
static byte getData(byte table[MS_TABLE_LENGTH]);
};
#endif