Turn ignition channels on and off. More...
#include "inc/freeEMS.h"
#include "inc/interrupts.h"
Go to the source code of this file.
Defines | |
#define | IGNITIONISRS_C |
Functions | |
void | IgnitionDwellISR (void) |
Ignition dwell control. | |
void | IgnitionFireISR (void) |
Ignition discharge control. |
Turn ignition channels on and off.
This currently semi-working but broken code is intended to one day provide multi-channel ignition capabilities. The basic method will be to turn a pin or set of pins on or another pin or set of pins off during each run of the appropriate handler. Each run will be triggered either by the scheduler and possibly this code itself as well. Currently it does not work correctly and isn't suitable for actual use as an ignition control solution.
Definition in file ignitionISRs.c.
#define IGNITIONISRS_C |
Definition at line 41 of file ignitionISRs.c.
void IgnitionDwellISR | ( | void | ) |
Ignition dwell control.
This function turns ignition pins on to dwell when required.
Definition at line 73 of file ignitionISRs.c.
References engineSetting::combustionEventsPerEngineCycle, DWELL_DISABLE, DWELL_ENABLE, dwellQueueLength, dwellStartMasks, fixedConfig1::engineSettings, fixedConfigs1, nextDwellChannel, PITCE, PITINTE, PITLD0, PITTF, PORTS, PORTS_BA, and queuedDwellOffsets.
00074 { 00075 // clear flag 00076 PITTF = DWELL_ENABLE; 00077 00078 // start dwelling asap 00079 PORTS_BA |= dwellStartMasks[nextDwellChannel]; 00080 00081 if(dwellQueueLength == 0){ 00082 // turn off the int 00083 PITINTE &= DWELL_DISABLE; 00084 00085 // disable channels 00086 PITCE &= DWELL_DISABLE; 00087 }else{ 00088 // reduce queue length by one 00089 dwellQueueLength--; 00090 00091 // increment channel counter to next channel 00092 if(nextDwellChannel < (fixedConfigs1.engineSettings.combustionEventsPerEngineCycle - 1)){ 00093 nextDwellChannel++; // if not the last channel, increment 00094 }else{ 00095 nextDwellChannel = 0; // if the last channel, reset to zero 00096 } 00097 00098 // if the queue length after decrement is greater than 0 then we need to load the timer, if it is zero and we decremented, the timer was already loaded. 00099 if(dwellQueueLength > 0){ 00100 if(dwellQueueLength > 8){ // TODO ???? why 8 ???? 12 or combustion events per... or ? 00101 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00102 PORTS |= 0x20; 00103 }else{ 00104 // load the timer if the index is good 00105 PITLD0 = queuedDwellOffsets[dwellQueueLength - 1]; 00106 } 00107 } 00108 } 00109 00110 // blink a led 00111 PORTS ^= 0x80; 00112 }
void IgnitionFireISR | ( | void | ) |
Ignition discharge control.
This function turns ignition pins off to discharge when required.
Definition at line 123 of file ignitionISRs.c.
References engineSetting::combustionEventsPerEngineCycle, fixedConfig1::engineSettings, fixedConfigs1, IGNITION_DISABLE, IGNITION_ENABLE, ignitionMasks, ignitionQueueLength, nextIgnitionChannel, PITCE, PITINTE, PITLD0, PITTF, PORTS, PORTS_BA, and queuedIgnitionOffsets.
00124 { 00125 // clear flag 00126 PITTF = IGNITION_ENABLE; 00127 00128 // fire the coil asap 00129 PORTS_BA &= ignitionMasks[nextIgnitionChannel]; 00130 00131 if(ignitionQueueLength == 0){ 00132 // turn off the int 00133 PITINTE &= IGNITION_DISABLE; 00134 00135 // disable channels 00136 PITCE &= IGNITION_DISABLE ; 00137 }else{ 00138 // reduce queue length by one 00139 ignitionQueueLength--; 00140 00141 // increment channel counter to next channel 00142 if(nextIgnitionChannel < (fixedConfigs1.engineSettings.combustionEventsPerEngineCycle - 1)){ 00143 nextIgnitionChannel++; // if not the last channel, increment 00144 }else{ 00145 nextIgnitionChannel = 0; // if the last channel, reset to zero 00146 } 00147 00148 // if the queue length after decrement is greater than 0 then we need to load the timer, if it is zero and we decremented, the timer was already loaded. 00149 if(ignitionQueueLength > 0){ 00150 if(ignitionQueueLength > fixedConfigs1.engineSettings.combustionEventsPerEngineCycle){ // TODO as above!!!!!!!!!! 00151 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00152 PORTS |= 0x10; 00153 }else{ 00154 // load the timer if the index is good 00155 PITLD0 = queuedIgnitionOffsets[ignitionQueueLength - 1]; 00156 } 00157 } 00158 } 00159 00160 // blink a led 00161 PORTS ^= 0x40; 00162 }