Ruthlessly remove old commented out and unused crap. Can get it back from history...
[freeems-vanilla.git] / src / miscISRs.c
blob0165ec82b0f7eb57b000700dbe8708a076920c90
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008 Fred Cooke
5 * This file is part of the FreeEMS project.
7 * FreeEMS software is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * FreeEMS software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 * We ask that if you make any changes to this file you email them upstream to
21 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 * Thank you for choosing FreeEMS to run your engine!
27 /** @file miscISRs.c
28 * @ingroup interruptHandlers
30 * @brief Miscellaneous Interrupt Handlers
32 * Various non-descript interrupt handlers that don't really fit anywhere else
33 * and aren't big enough to live on their own just yet.
35 * @author Fred Cooke
39 #include "inc/freeEMS.h"
40 #include "inc/interrupts.h"
43 /** @brief Unimplemented Interrupt Handler
45 * Unimplemented interrupt service routine for calls we weren't expecting.
46 * Currently this simply counts bad calls like any other event type.
48 * @author Fred Cooke
50 void UISR(void){
51 /* Increment the unimplemented ISR execution counter */
52 Counters.callsToUISRs++;
56 /** @brief Port P pins ISR
58 * Interrupt handler for edge events on port P pins. Not currently used.
60 * @author Fred Cooke
62 void PortPISR(void){
63 /* Clear all port P flags (we only want one at a time) */
64 PIFP = ONES;
65 /* Increment the unimplemented ISR execution counter */
66 Counters.callsToUISRs++;
67 } /* Port P interrupt service routine */
70 /** @brief Port J pins ISR
72 * Interrupt handler for edge events on port J pins. Not currently used.
74 * @author Fred Cooke
76 void PortJISR(void){
77 /* Clear all port H flags (we only want one at a time) */
78 PIFJ = ONES;
79 /* Increment the unimplemented ISR execution counter */
80 Counters.callsToUISRs++;
84 /** @brief Port H pins ISR
86 * Interrupt handler for edge events on port H pins. Not currently used.
88 * @author Fred Cooke
90 void PortHISR(void)
92 // // read the interrupt flags to a variable
93 // unsigned char portHFlags = PIFH;
94 // portHFlags &= 0xF8; // mask out the other bits
96 // /* Clear all port H flags (we only want one at a time) */
97 PIFH = ONES;
99 // // Toggle a LED so we can see if the code ran
100 PORTA ^= 0x80; // Fuel pump pin (A7)
102 // debounce
103 if(portHDebounce == 0){
104 portHDebounce = 2;
105 }else{
106 return;
109 // // find out which pin triggered it, clear the flag, perform the action.
110 // switch(portHFlags)
111 // {
112 // case 0x80 : // Increment cylinder count and set port count appropriately.
113 // switch (configs.combustionEventsPerEngineCycle) {
114 // case 1 :
115 // configs.combustionEventsPerEngineCycle = 2;
116 // configs.ports = 2;
117 // break;
118 // case 2 :
119 // configs.combustionEventsPerEngineCycle = 3;
120 // configs.ports = 3;
121 // break;
122 // case 3 :
123 // configs.combustionEventsPerEngineCycle = 4;
124 // configs.ports = 4;
125 // break;
126 // case 4 :
127 // configs.combustionEventsPerEngineCycle = 5;
128 // configs.ports = 5;
129 // break;
130 // case 5 :
131 // configs.combustionEventsPerEngineCycle = 6;
132 // configs.ports = 6;
133 // break;
134 // case 6 :
135 // configs.combustionEventsPerEngineCycle = 8;
136 // configs.ports = 4;
137 // break;
138 // case 8 :
139 // configs.combustionEventsPerEngineCycle = 10;
140 // configs.ports = 5;
141 // break;
142 // case 10 :
143 // configs.combustionEventsPerEngineCycle = 12;
144 // configs.ports = 6;
145 // break;
146 // case 12 :
147 // configs.combustionEventsPerEngineCycle = 1;
148 // configs.ports = 1;
149 // break;
150 // }
151 // break;
152 // case 0x40 : // Injection output enable/disable
153 // if(coreSettingsA & FUEL_CUT){
154 // coreSettingsA &= FUEL_CUT_OFF;
155 // }else{
156 // coreSettingsA |= FUEL_CUT;
157 // }
158 // break;
159 // case 0x20 : // Ignition output enable/disable
160 // if(coreSettingsA & HARD_SPARK_CUT){
161 // coreSettingsA &= HARD_SPARK_CUT_OFF;
162 // }else{
163 // coreSettingsA |= HARD_SPARK_CUT;
164 // }
165 // break;
166 // case 0x10 : // Staged injection enable/disable
167 // if(coreSettingsA & STAGED_ON){
168 // coreSettingsA &= STAGED_OFF;
169 // }else{
170 // coreSettingsA |= STAGED_ON;
171 // }
172 // break;
173 // case 0x08 : // Staged injection start sched/fixed
174 // if(coreSettingsA & STAGED_START){
175 // coreSettingsA &= CLEAR_STAGED_START;
176 // }else{
177 // coreSettingsA |= STAGED_START;
178 // }
179 // break;
180 // case 0x04 : // Staged injection end sched/fixed
181 // if(coreSettingsA & STAGED_END){
182 // coreSettingsA &= CLEAR_STAGED_END;
183 // }else{
184 // coreSettingsA |= STAGED_END;
185 // }
186 // break;
187 // case 0x02 : // free input
188 // break;
189 // case 0x01 : // free input
190 // break;
191 // default : // Two or more pressed, nothing to do except wait for another button press
192 // break;
193 // }
197 /** @brief IRQ/PE1 pin ISR
199 * Interrupt handler for edge events on the IRQ/PE1 pin. Not currently used.
201 * @author Fred Cooke
203 void IRQISR(void){
204 /* Clear the flag */
205 // ?? TODO
207 /* Increment the unimplemented ISR execution counter */
208 Counters.callsToUISRs++;
212 /** @brief XIRQ/PE0 pin ISR
214 * Interrupt handler for edge events on the XIRQ/PE0 pin. Not currently used.
216 * @author Fred Cooke
218 void XIRQISR(void){
219 /* Clear the flag */
220 // ?? TODO
222 /* Increment the unimplemented ISR execution counter */
223 Counters.callsToUISRs++;
227 /** @brief Low Voltage Counter
229 * Count how often our voltage drops lower than it should without resetting.
231 * @author Fred Cooke
233 void LowVoltageISR(void){
234 /* Clear the flag */
235 VREGCTRL |= 0x01;
237 /* Increment the counter */
238 Counters.lowVoltageConditions++;