forked from speeduino/speeduino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inject the coil & injector control functions into the scheduled I/O m…
…odule. Much cleaner than the module trying to figure it out itself. Costs 14 bytes RAM
- Loading branch information
1 parent
ff222d5
commit 8d85c5e
Showing
3 changed files
with
121 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,41 @@ | ||
#include "scheduledIO.h" | ||
|
||
#include "scheduledIO_direct.h" | ||
/** @file | ||
* Injector and Coil (toggle/open/close) control (under various situations, eg with particular cylinder count, rotary engine type or wasted spark ign, etc.). | ||
* Also accounts for presence of MC33810 injector/ignition (dwell, etc.) control circuit. | ||
* Functions here are typically assigned (at initialisation) to callback function variables (e.g. inj1StartFunction or inj1EndFunction) | ||
* form where they are called (by scheduler.ino). | ||
*/ | ||
|
||
#if defined(OUTPUT_CONTROL_SUPPORTED) | ||
ScheduleOutputControl ignitionOutputControl; | ||
#endif | ||
|
||
#if defined(OUTPUT_CONTROL_SUPPORTED) | ||
ScheduleOutputControl injectorOutputControl; | ||
#endif | ||
|
||
static inline ioPort registerIOPin(uint8_t pin, ScheduleOutputControl ioType) { | ||
if(ioType == OUTPUT_CONTROL_DIRECT) { | ||
return pinToOutputPort(pin); | ||
} else { | ||
return nullIoPort(); | ||
} | ||
} | ||
|
||
static inline void registerPins(ioPort toRegister[], uint8_t toRegisterSize, const uint8_t pins[], ScheduleOutputControl ioType) { | ||
static inline void registerPins(ioPort toRegister[], uint8_t toRegisterSize, const uint8_t pins[]) { | ||
for (uint8_t index=0U; index<toRegisterSize; ++index) { | ||
toRegister[index] = registerIOPin(pins[index], ioType); | ||
} | ||
#if defined(OUTPUT_CONTROL_SUPPORTED) | ||
if (ioType==OUTPUT_CONTROL_MC33810) { | ||
initMC33810(); | ||
toRegister[index] = pinToOutputPort(pins[index]); | ||
} | ||
#endif | ||
} | ||
|
||
void initialiseInjectorPins(const uint8_t pins[]) { | ||
#if defined(OUTPUT_CONTROL_SUPPORTED) | ||
injectorOutputControl = isValidPin(pinMC33810_1_CS) ? OUTPUT_CONTROL_MC33810 : OUTPUT_CONTROL_DIRECT; | ||
registerPins(injectorPins, _countof(injectorPins), pins, injectorOutputControl); | ||
#else | ||
registerPins(injectorPins, _countof(injectorPins), pins, OUTPUT_CONTROL_DIRECT); | ||
#endif | ||
registerPins(injectorPins, _countof(injectorPins), pins); | ||
} | ||
|
||
void initialiseIgnitionPins(const uint8_t pins[]) { | ||
#if defined(OUTPUT_CONTROL_SUPPORTED) | ||
ignitionOutputControl = isValidPin(pinMC33810_2_CS) ? OUTPUT_CONTROL_MC33810 : OUTPUT_CONTROL_DIRECT; | ||
registerPins(ignitionPins, _countof(ignitionPins), pins, ignitionOutputControl); | ||
#else | ||
registerPins(ignitionPins, _countof(ignitionPins), pins, OUTPUT_CONTROL_DIRECT); | ||
#endif | ||
registerPins(ignitionPins, _countof(ignitionPins), pins); | ||
} | ||
|
||
static inline void nullAction(uint8_t index) { | ||
UNUSED(index); | ||
// Do nothing | ||
} | ||
|
||
// cppcheck-suppress misra-c2012-8.4 | ||
injector_control_t injectorControl = { nullAction, nullAction, nullAction }; | ||
|
||
void setInjectorControlActions(const injector_control_t &control) { | ||
injectorControl = control; | ||
} | ||
|
||
// cppcheck-suppress misra-c2012-8.4 | ||
coil_control_t coilControl = { nullAction, nullAction }; | ||
|
||
void setIgnitionControlActions(const coil_control_t &control) { | ||
coilControl = control; | ||
} |
Oops, something went wrong.