#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. |
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 40 of file ignitionISRs.c.
void IgnitionDwellISR | ( | void | ) |
Ignition dwell control.
This function turns ignition pins on to dwell when required.
Definition at line 72 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.
00073 { 00074 // clear flag 00075 PITTF = DWELL_ENABLE; 00076 00077 // start dwelling asap 00078 PORTS_BA |= dwellStartMasks[nextDwellChannel]; 00079 00080 if(dwellQueueLength == 0){ 00081 // turn off the int 00082 PITINTE &= DWELL_DISABLE; 00083 00084 // disable channels 00085 PITCE &= DWELL_DISABLE; 00086 }else{ 00087 // reduce queue length by one 00088 dwellQueueLength--; 00089 00090 // increment channel counter to next channel 00091 if(nextDwellChannel < (fixedConfigs1.engineSettings.combustionEventsPerEngineCycle - 1)){ 00092 nextDwellChannel++; // if not the last channel, increment 00093 }else{ 00094 nextDwellChannel = 0; // if the last channel, reset to zero 00095 } 00096 00097 // 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. 00098 if(dwellQueueLength > 0){ 00099 if(dwellQueueLength > 8){ // TODO ???? why 8 ???? 12 or combustion events per... or ? 00100 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00101 PORTS |= 0x20; 00102 }else{ 00103 // load the timer if the index is good 00104 PITLD0 = queuedDwellOffsets[dwellQueueLength - 1]; 00105 } 00106 } 00107 } 00108 00109 // blink a led 00110 PORTS ^= 0x80; 00111 }
void IgnitionFireISR | ( | void | ) |
Ignition discharge control.
This function turns ignition pins off to discharge when required.
Definition at line 122 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.
00123 { 00124 // clear flag 00125 PITTF = IGNITION_ENABLE; 00126 00127 // fire the coil asap 00128 PORTS_BA &= ignitionMasks[nextIgnitionChannel]; 00129 00130 if(ignitionQueueLength == 0){ 00131 // turn off the int 00132 PITINTE &= IGNITION_DISABLE; 00133 00134 // disable channels 00135 PITCE &= IGNITION_DISABLE ; 00136 }else{ 00137 // reduce queue length by one 00138 ignitionQueueLength--; 00139 00140 // increment channel counter to next channel 00141 if(nextIgnitionChannel < (fixedConfigs1.engineSettings.combustionEventsPerEngineCycle - 1)){ 00142 nextIgnitionChannel++; // if not the last channel, increment 00143 }else{ 00144 nextIgnitionChannel = 0; // if the last channel, reset to zero 00145 } 00146 00147 // 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. 00148 if(ignitionQueueLength > 0){ 00149 if(ignitionQueueLength > fixedConfigs1.engineSettings.combustionEventsPerEngineCycle){ // TODO as above!!!!!!!!!! 00150 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00151 PORTS |= 0x10; 00152 }else{ 00153 // load the timer if the index is good 00154 PITLD0 = queuedIgnitionOffsets[ignitionQueueLength - 1]; 00155 } 00156 } 00157 } 00158 00159 // blink a led 00160 PORTS ^= 0x40; 00161 }