#include "inc/freeEMS.h"
#include "inc/interrupts.h"
#include "inc/ignitionISRs.h"
Include dependency graph for ignitionISRs.c:
Go to the source code of this file.
Defines | |
#define | IGNITIONISRS_C |
Functions | |
void | IgnitionDwellISR (void) |
void | IgnitionFireISR (void) |
#define IGNITIONISRS_C |
Definition at line 24 of file ignitionISRs.c.
void IgnitionDwellISR | ( | void | ) |
Definition at line 47 of file ignitionISRs.c.
References fixedConfig::combustionEventsPerEngineCycle, DWELL_DISABLE, DWELL_ENABLE, dwellQueueLength, dwellStartMasks, fixedConfigs, nextDwellChannel, PITCE, PITINTE, PITLD0, PITTF, PORTS, PORTS_BA, and queuedDwellOffsets.
00048 { 00049 // clear flag 00050 PITTF = DWELL_ENABLE; 00051 00052 // start dwelling asap 00053 PORTS_BA |= dwellStartMasks[nextDwellChannel]; 00054 00055 if(dwellQueueLength == 0){ 00056 // turn off the int 00057 PITINTE &= DWELL_DISABLE; 00058 00059 // disable channels 00060 PITCE &= DWELL_DISABLE; 00061 }else{ 00062 // reduce queue length by one 00063 dwellQueueLength--; 00064 00065 // increment channel counter to next channel 00066 if(nextDwellChannel < (fixedConfigs.combustionEventsPerEngineCycle - 1)){ 00067 nextDwellChannel++; // if not the last channel, increment 00068 }else{ 00069 nextDwellChannel = 0; // if the last channel, reset to zero 00070 } 00071 00072 // 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. 00073 if(dwellQueueLength > 0){ 00074 if(dwellQueueLength > 8){ // TODO ???? why 8 ???? 12 or combustion events per... or ? 00075 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00076 PORTS |= 0x20; 00077 }else{ 00078 // load the timer if the index is good 00079 PITLD0 = queuedDwellOffsets[dwellQueueLength - 1]; 00080 } 00081 } 00082 } 00083 00084 // blink a led 00085 PORTS ^= 0x80; 00086 }
void IgnitionFireISR | ( | void | ) |
Definition at line 89 of file ignitionISRs.c.
References fixedConfig::combustionEventsPerEngineCycle, fixedConfigs, IGNITION_DISABLE, IGNITION_ENABLE, ignitionMasks, ignitionQueueLength, nextIgnitionChannel, PITCE, PITINTE, PITLD0, PITTF, PORTS, PORTS_BA, and queuedIgnitionOffsets.
00090 { 00091 // clear flag 00092 PITTF = IGNITION_ENABLE; 00093 00094 // fire the coil asap 00095 PORTS_BA &= ignitionMasks[nextIgnitionChannel]; 00096 00097 if(ignitionQueueLength == 0){ 00098 // turn off the int 00099 PITINTE &= IGNITION_DISABLE; 00100 00101 // disable channels 00102 PITCE &= IGNITION_DISABLE ; 00103 }else{ 00104 // reduce queue length by one 00105 ignitionQueueLength--; 00106 00107 // increment channel counter to next channel 00108 if(nextIgnitionChannel < (fixedConfigs.combustionEventsPerEngineCycle - 1)){ 00109 nextIgnitionChannel++; // if not the last channel, increment 00110 }else{ 00111 nextIgnitionChannel = 0; // if the last channel, reset to zero 00112 } 00113 00114 // 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. 00115 if(ignitionQueueLength > 0){ 00116 if(ignitionQueueLength > fixedConfigs.combustionEventsPerEngineCycle){ // TODO as above!!!!!!!!!! 00117 //throw a nasty error of some sort for index out of range issue that should never occur (for now just light a LED) 00118 PORTS |= 0x10; 00119 }else{ 00120 // load the timer if the index is good 00121 PITLD0 = queuedIgnitionOffsets[ignitionQueueLength - 1]; 00122 } 00123 } 00124 } 00125 00126 // blink a led 00127 PORTS ^= 0x40; 00128 }