Speeduino
Loading...
Searching...
No Matches
scheduledIO.h
Go to the documentation of this file.
1#ifndef SCHEDULEDIO_H
2#define SCHEDULEDIO_H
3
4#include <Arduino.h>
5
6void openInjector1(void);
7void closeInjector1(void);
8
9void openInjector2(void);
10void closeInjector2(void);
11
12void openInjector3(void);
13void closeInjector3(void);
14
15void openInjector4(void);
16void closeInjector4(void);
17
18void openInjector5(void);
19void closeInjector5(void);
20
21void openInjector6(void);
22void closeInjector6(void);
23
24void openInjector7(void);
25void closeInjector7(void);
26
27void openInjector8(void);
28void closeInjector8(void);
29
30// These are for Semi-Sequential and 5 Cylinder injection
31void openInjector1and3(void);
32void closeInjector1and3(void);
33void openInjector2and4(void);
34void closeInjector2and4(void);
35void openInjector1and4(void);
36void closeInjector1and4(void);
37void openInjector2and3(void);
38void closeInjector2and3(void);
39
40void openInjector3and5(void);
41void closeInjector3and5(void);
42
43void openInjector2and5(void);
44void closeInjector2and5(void);
45void openInjector3and6(void);
46void closeInjector3and6(void);
47
48void openInjector1and5(void);
49void closeInjector1and5(void);
50void openInjector2and6(void);
51void closeInjector2and6(void);
52void openInjector3and7(void);
53void closeInjector3and7(void);
54void openInjector4and8(void);
55void closeInjector4and8(void);
56
57void injector1Toggle(void);
58void injector2Toggle(void);
59void injector3Toggle(void);
60void injector4Toggle(void);
61void injector5Toggle(void);
62void injector6Toggle(void);
63void injector7Toggle(void);
64void injector8Toggle(void);
65
66void beginCoil1Charge(void);
67void endCoil1Charge(void);
68
69void beginCoil2Charge(void);
70void endCoil2Charge(void);
71
72void beginCoil3Charge(void);
73void endCoil3Charge(void);
74
75void beginCoil4Charge(void);
76void endCoil4Charge(void);
77
78void beginCoil5Charge(void);
79void endCoil5Charge(void);
80
81void beginCoil6Charge(void);
82void endCoil6Charge(void);
83
84void beginCoil7Charge(void);
85void endCoil7Charge(void);
86
87void beginCoil8Charge(void);
88void endCoil8Charge(void);
89
90//The following functions are used specifically for the trailing coil on rotary engines. They are separate as they also control the switching of the trailing select pin
92void endTrailingCoilCharge1(void);
93void endTrailingCoilCharge2(void);
94
95//And the combined versions of the above for simplicity
96void beginCoil1and3Charge(void);
97void endCoil1and3Charge(void);
98void beginCoil2and4Charge(void);
99void endCoil2and4Charge(void);
100
101//For 6-cyl cop
102void beginCoil1and4Charge(void);
103void endCoil1and4Charge(void);
104void beginCoil2and5Charge(void);
105void endCoil2and5Charge(void);
106void beginCoil3and6Charge(void);
107void endCoil3and6Charge(void);
108
109//For 8-cyl cop
110void beginCoil1and5Charge(void);
111void endCoil1and5Charge(void);
112void beginCoil2and6Charge(void);
113void endCoil2and6Charge(void);
114void beginCoil3and7Charge(void);
115void endCoil3and7Charge(void);
116void beginCoil4and8Charge(void);
117void endCoil4and8Charge(void);
118
119void coil1Toggle(void);
120void coil2Toggle(void);
121void coil3Toggle(void);
122void coil4Toggle(void);
123void coil5Toggle(void);
124void coil6Toggle(void);
125void coil7Toggle(void);
126void coil8Toggle(void);
127
128void tachoOutputOn(void);
129void tachoOutputOff(void);
130
131/*
132#ifndef USE_MC33810
133#define openInjector1() *inj1_pin_port |= (inj1_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ1)
134#define closeInjector1() *inj1_pin_port &= ~(inj1_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ1)
135#define openInjector2() *inj2_pin_port |= (inj2_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ2)
136#define closeInjector2() *inj2_pin_port &= ~(inj2_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ2)
137#define openInjector3() *inj3_pin_port |= (inj3_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ3)
138#define closeInjector3() *inj3_pin_port &= ~(inj3_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ3)
139#define openInjector4() *inj4_pin_port |= (inj4_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ4)
140#define closeInjector4() *inj4_pin_port &= ~(inj4_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ4)
141#define openInjector5() *inj5_pin_port |= (inj5_pin_mask);
142#define closeInjector5() *inj5_pin_port &= ~(inj5_pin_mask);
143#define openInjector6() *inj6_pin_port |= (inj6_pin_mask);
144#define closeInjector6() *inj6_pin_port &= ~(inj6_pin_mask);
145#define openInjector7() *inj7_pin_port |= (inj7_pin_mask);
146#define closeInjector7() *inj7_pin_port &= ~(inj7_pin_mask);
147#define openInjector8() *inj8_pin_port |= (inj8_pin_mask);
148#define closeInjector8() *inj8_pin_port &= ~(inj8_pin_mask);
149
150#else
151#include "acc_mc33810.h"
152#define openInjector1() openInjector1_MC33810()
153#define closeInjector1() closeInjector1_MC33810()
154#define openInjector2() openInjector2_MC33810()
155#define closeInjector2() closeInjector2_MC33810()
156#define openInjector3() openInjector3_MC33810()
157#define closeInjector3() closeInjector3_MC33810()
158#define openInjector4() openInjector4_MC33810()
159#define closeInjector4() closeInjector4_MC33810()
160#define openInjector5() openInjector5_MC33810()
161#define closeInjector5() closeInjector5_MC33810()
162#define openInjector6() openInjector6_MC33810()
163#define closeInjector6() closeInjector6_MC33810()
164#define openInjector7() openInjector7_MC33810()
165#define closeInjector7() closeInjector7_MC33810()
166#define openInjector8() openInjector8_MC33810()
167#define closeInjector8() closeInjector8_MC33810()
168
169#endif
170
171#define openInjector1and4() openInjector1(); openInjector4()
172#define closeInjector1and4() closeInjector1(); closeInjector4()
173#define openInjector2and3() openInjector2(); openInjector3()
174#define closeInjector2and3() closeInjector2(); closeInjector3()
175
176//5 cylinder support doubles up injector 3 as being closese to inj 5 (Crank angle)
177#define openInjector3and5() openInjector3(); openInjector5()
178#define closeInjector3and5() closeInjector3(); closeInjector5()
179*/
180
181//Macros are used to define how each injector control system functions. These are then called by the master openInjectx() function.
182//The DIRECT macros (ie individual pins) are defined below. Others should be defined in their relevant acc_x.h file
183#define openInjector1_DIRECT() { *inj1_pin_port |= (inj1_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ1); }
184#define closeInjector1_DIRECT() { *inj1_pin_port &= ~(inj1_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ1); }
185#define openInjector2_DIRECT() { *inj2_pin_port |= (inj2_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ2); }
186#define closeInjector2_DIRECT() { *inj2_pin_port &= ~(inj2_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ2); }
187#define openInjector3_DIRECT() { *inj3_pin_port |= (inj3_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ3); }
188#define closeInjector3_DIRECT() { *inj3_pin_port &= ~(inj3_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ3); }
189#define openInjector4_DIRECT() { *inj4_pin_port |= (inj4_pin_mask); BIT_SET(currentStatus.status1, BIT_STATUS1_INJ4); }
190#define closeInjector4_DIRECT() { *inj4_pin_port &= ~(inj4_pin_mask); BIT_CLEAR(currentStatus.status1, BIT_STATUS1_INJ4); }
191#define openInjector5_DIRECT() { *inj5_pin_port |= (inj5_pin_mask); }
192#define closeInjector5_DIRECT() { *inj5_pin_port &= ~(inj5_pin_mask); }
193#define openInjector6_DIRECT() { *inj6_pin_port |= (inj6_pin_mask); }
194#define closeInjector6_DIRECT() { *inj6_pin_port &= ~(inj6_pin_mask); }
195#define openInjector7_DIRECT() { *inj7_pin_port |= (inj7_pin_mask); }
196#define closeInjector7_DIRECT() { *inj7_pin_port &= ~(inj7_pin_mask); }
197#define openInjector8_DIRECT() { *inj8_pin_port |= (inj8_pin_mask); }
198#define closeInjector8_DIRECT() { *inj8_pin_port &= ~(inj8_pin_mask); }
199
200#define coil1Low_DIRECT() (*ign1_pin_port &= ~(ign1_pin_mask))
201#define coil1High_DIRECT() (*ign1_pin_port |= (ign1_pin_mask))
202#define coil2Low_DIRECT() (*ign2_pin_port &= ~(ign2_pin_mask))
203#define coil2High_DIRECT() (*ign2_pin_port |= (ign2_pin_mask))
204#define coil3Low_DIRECT() (*ign3_pin_port &= ~(ign3_pin_mask))
205#define coil3High_DIRECT() (*ign3_pin_port |= (ign3_pin_mask))
206#define coil4Low_DIRECT() (*ign4_pin_port &= ~(ign4_pin_mask))
207#define coil4High_DIRECT() (*ign4_pin_port |= (ign4_pin_mask))
208#define coil5Low_DIRECT() (*ign5_pin_port &= ~(ign5_pin_mask))
209#define coil5High_DIRECT() (*ign5_pin_port |= (ign5_pin_mask))
210#define coil6Low_DIRECT() (*ign6_pin_port &= ~(ign6_pin_mask))
211#define coil6High_DIRECT() (*ign6_pin_port |= (ign6_pin_mask))
212#define coil7Low_DIRECT() (*ign7_pin_port &= ~(ign7_pin_mask))
213#define coil7High_DIRECT() (*ign7_pin_port |= (ign7_pin_mask))
214#define coil8Low_DIRECT() (*ign8_pin_port &= ~(ign8_pin_mask))
215#define coil8High_DIRECT() (*ign8_pin_port |= (ign8_pin_mask))
216
217//Set the value of the coil pins to the coilHIGH or coilLOW state
218#define coil1Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil1Low_DIRECT() : coil1High_DIRECT())
219#define coil1StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil1High_DIRECT() : coil1Low_DIRECT())
220#define coil2Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil2Low_DIRECT() : coil2High_DIRECT())
221#define coil2StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil2High_DIRECT() : coil2Low_DIRECT())
222#define coil3Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil3Low_DIRECT() : coil3High_DIRECT())
223#define coil3StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil3High_DIRECT() : coil3Low_DIRECT())
224#define coil4Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil4Low_DIRECT() : coil4High_DIRECT())
225#define coil4StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil4High_DIRECT() : coil4Low_DIRECT())
226#define coil5Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil5Low_DIRECT() : coil5High_DIRECT())
227#define coil5StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil5High_DIRECT() : coil5Low_DIRECT())
228#define coil6Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil6Low_DIRECT() : coil6High_DIRECT())
229#define coil6StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil6High_DIRECT() : coil6Low_DIRECT())
230#define coil7Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil7Low_DIRECT() : coil7High_DIRECT())
231#define coil7StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil7High_DIRECT() : coil7Low_DIRECT())
232#define coil8Charging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil8Low_DIRECT() : coil8High_DIRECT())
233#define coil8StopCharging_DIRECT() (configPage4.IgInv == GOING_HIGH ? coil8High_DIRECT() : coil8Low_DIRECT())
234
235#define coil1Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil1Low_MC33810(); } else { coil1High_MC33810(); }
236#define coil1StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil1High_MC33810(); } else { coil1Low_MC33810(); }
237#define coil2Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil2Low_MC33810(); } else { coil2High_MC33810(); }
238#define coil2StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil2High_MC33810(); } else { coil2Low_MC33810(); }
239#define coil3Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil3Low_MC33810(); } else { coil3High_MC33810(); }
240#define coil3StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil3High_MC33810(); } else { coil3Low_MC33810(); }
241#define coil4Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil4Low_MC33810(); } else { coil4High_MC33810(); }
242#define coil4StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil4High_MC33810(); } else { coil4Low_MC33810(); }
243#define coil5Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil5Low_MC33810(); } else { coil5High_MC33810(); }
244#define coil5StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil5High_MC33810(); } else { coil5Low_MC33810(); }
245#define coil6Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil6Low_MC33810(); } else { coil6High_MC33810(); }
246#define coil6StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil6High_MC33810(); } else { coil6Low_MC33810(); }
247#define coil7Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil7Low_MC33810(); } else { coil7High_MC33810(); }
248#define coil7StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil7High_MC33810(); } else { coil7Low_MC33810(); }
249#define coil8Charging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil8Low_MC33810(); } else { coil8High_MC33810(); }
250#define coil8StopCharging_MC33810() if(configPage4.IgInv == GOING_HIGH) { coil8High_MC33810(); } else { coil8Low_MC33810(); }
251
252#define coil1Toggle_DIRECT() (*ign1_pin_port ^= ign1_pin_mask )
253#define coil2Toggle_DIRECT() (*ign2_pin_port ^= ign2_pin_mask )
254#define coil3Toggle_DIRECT() (*ign3_pin_port ^= ign3_pin_mask )
255#define coil4Toggle_DIRECT() (*ign4_pin_port ^= ign4_pin_mask )
256#define coil5Toggle_DIRECT() (*ign5_pin_port ^= ign5_pin_mask )
257#define coil6Toggle_DIRECT() (*ign6_pin_port ^= ign6_pin_mask )
258#define coil7Toggle_DIRECT() (*ign7_pin_port ^= ign7_pin_mask )
259#define coil8Toggle_DIRECT() (*ign8_pin_port ^= ign8_pin_mask )
260
261#define injector1Toggle_DIRECT() (*inj1_pin_port ^= inj1_pin_mask )
262#define injector2Toggle_DIRECT() (*inj2_pin_port ^= inj2_pin_mask )
263#define injector3Toggle_DIRECT() (*inj3_pin_port ^= inj3_pin_mask )
264#define injector4Toggle_DIRECT() (*inj4_pin_port ^= inj4_pin_mask )
265#define injector5Toggle_DIRECT() (*inj5_pin_port ^= inj5_pin_mask )
266#define injector6Toggle_DIRECT() (*inj6_pin_port ^= inj6_pin_mask )
267#define injector7Toggle_DIRECT() (*inj7_pin_port ^= inj7_pin_mask )
268#define injector8Toggle_DIRECT() (*inj8_pin_port ^= inj8_pin_mask )
269
270void nullCallback(void);
271
273
274#endif
static uint32_t rshift(uint32_t a)
Bitwise right shift - generic, unoptimized, case.
Definition bit_shifts.h:349
void closeInjector3(void)
Definition scheduledIO.cpp:17
void endCoil4and8Charge(void)
Definition scheduledIO.cpp:127
void closeInjector2and4(void)
Definition scheduledIO.cpp:52
void closeInjector8(void)
Definition scheduledIO.cpp:27
void beginCoil1and3Charge(void)
Definition scheduledIO.cpp:106
void beginCoil3and6Charge(void)
Definition scheduledIO.cpp:116
void coil8Toggle(void)
Definition scheduledIO.cpp:45
void endCoil1Charge(void)
Definition scheduledIO.cpp:77
void endCoil3Charge(void)
Definition scheduledIO.cpp:83
void beginCoil2and6Charge(void)
Definition scheduledIO.cpp:122
void openInjector4(void)
Definition scheduledIO.cpp:18
void closeInjector2and5(void)
Definition scheduledIO.cpp:63
void endTrailingCoilCharge2(void)
Definition scheduledIO.cpp:103
void openInjector3and7(void)
Definition scheduledIO.cpp:71
void beginCoil2Charge(void)
Definition scheduledIO.cpp:79
void closeInjector4and8(void)
Definition scheduledIO.cpp:74
void injector3Toggle(void)
Definition scheduledIO.cpp:31
void beginCoil5Charge(void)
Definition scheduledIO.cpp:88
void injector6Toggle(void)
Definition scheduledIO.cpp:34
void closeInjector3and6(void)
Definition scheduledIO.cpp:65
void openInjector3and5(void)
Definition scheduledIO.cpp:59
void beginCoil2and4Charge(void)
Definition scheduledIO.cpp:108
void openInjector2and4(void)
Definition scheduledIO.cpp:51
void injector8Toggle(void)
Definition scheduledIO.cpp:36
void endCoil6Charge(void)
Definition scheduledIO.cpp:92
void endCoil7Charge(void)
Definition scheduledIO.cpp:95
void openInjector2and5(void)
Definition scheduledIO.cpp:62
void openInjector5(void)
Definition scheduledIO.cpp:20
void beginTrailingCoilCharge(void)
Definition scheduledIO.cpp:101
void endTrailingCoilCharge1(void)
Definition scheduledIO.cpp:102
void closeInjector3and7(void)
Definition scheduledIO.cpp:72
void openInjector1and5(void)
Definition scheduledIO.cpp:67
void coil5Toggle(void)
Definition scheduledIO.cpp:42
void endCoil1and4Charge(void)
Definition scheduledIO.cpp:113
void beginCoil1and5Charge(void)
Definition scheduledIO.cpp:120
void tachoOutputOn(void)
Definition scheduledIO.cpp:129
void closeInjector3and5(void)
Definition scheduledIO.cpp:60
void coil3Toggle(void)
Definition scheduledIO.cpp:40
void openInjector3(void)
Definition scheduledIO.cpp:16
void closeInjector1(void)
Definition scheduledIO.cpp:13
void endCoil5Charge(void)
Definition scheduledIO.cpp:89
void tachoOutputOff(void)
Definition scheduledIO.cpp:130
void closeInjector1and3(void)
Definition scheduledIO.cpp:50
void endCoil1and3Charge(void)
Definition scheduledIO.cpp:107
void beginCoil3and7Charge(void)
Definition scheduledIO.cpp:124
void beginCoil1and4Charge(void)
Definition scheduledIO.cpp:112
void openInjector8(void)
Definition scheduledIO.cpp:26
void injector1Toggle(void)
Definition scheduledIO.cpp:29
void endCoil2and5Charge(void)
Definition scheduledIO.cpp:115
void closeInjector4(void)
Definition scheduledIO.cpp:19
void closeInjector6(void)
Definition scheduledIO.cpp:23
void coil2Toggle(void)
Definition scheduledIO.cpp:39
void nullCallback(void)
Definition scheduledIO.cpp:132
void injector2Toggle(void)
Definition scheduledIO.cpp:30
void endCoil2and6Charge(void)
Definition scheduledIO.cpp:123
void beginCoil4Charge(void)
Definition scheduledIO.cpp:85
void openInjector6(void)
Definition scheduledIO.cpp:22
void endCoil3and7Charge(void)
Definition scheduledIO.cpp:125
void coil4Toggle(void)
Definition scheduledIO.cpp:41
void endCoil2Charge(void)
Definition scheduledIO.cpp:80
void beginCoil7Charge(void)
Definition scheduledIO.cpp:94
void closeInjector5(void)
Definition scheduledIO.cpp:21
void injector7Toggle(void)
Definition scheduledIO.cpp:35
void openInjector2and3(void)
Definition scheduledIO.cpp:56
void closeInjector2and3(void)
Definition scheduledIO.cpp:57
void(* voidVoidCallback)(void)
Definition scheduledIO.h:272
void openInjector1and3(void)
Definition scheduledIO.cpp:49
void closeInjector1and4(void)
Definition scheduledIO.cpp:55
void beginCoil4and8Charge(void)
Definition scheduledIO.cpp:126
void endCoil1and5Charge(void)
Definition scheduledIO.cpp:121
void beginCoil1Charge(void)
Definition scheduledIO.cpp:76
void closeInjector2(void)
Definition scheduledIO.cpp:15
void beginCoil3Charge(void)
Definition scheduledIO.cpp:82
void openInjector1and4(void)
Definition scheduledIO.cpp:54
void beginCoil6Charge(void)
Definition scheduledIO.cpp:91
void beginCoil2and5Charge(void)
Definition scheduledIO.cpp:114
void closeInjector1and5(void)
Definition scheduledIO.cpp:68
void endCoil3and6Charge(void)
Definition scheduledIO.cpp:117
void openInjector4and8(void)
Definition scheduledIO.cpp:73
void coil7Toggle(void)
Definition scheduledIO.cpp:44
void injector4Toggle(void)
Definition scheduledIO.cpp:32
void openInjector3and6(void)
Definition scheduledIO.cpp:64
void beginCoil8Charge(void)
Definition scheduledIO.cpp:97
void endCoil8Charge(void)
Definition scheduledIO.cpp:98
void closeInjector7(void)
Definition scheduledIO.cpp:25
void openInjector1(void)
Definition scheduledIO.cpp:12
void closeInjector2and6(void)
Definition scheduledIO.cpp:70
void openInjector7(void)
Definition scheduledIO.cpp:24
void endCoil2and4Charge(void)
Definition scheduledIO.cpp:109
void openInjector2and6(void)
Definition scheduledIO.cpp:69
void coil6Toggle(void)
Definition scheduledIO.cpp:43
void coil1Toggle(void)
Definition scheduledIO.cpp:38
void openInjector2(void)
Definition scheduledIO.cpp:14
void endCoil4Charge(void)
Definition scheduledIO.cpp:86
void injector5Toggle(void)
Definition scheduledIO.cpp:33