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!
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.
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.
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.
63 /* Clear all port P flags (we only want one at a time) */
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.
77 /* Clear all port H flags (we only want one at a time) */
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.
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) */
99 // // Toggle a LED so we can see if the code ran
100 PORTA
^= 0x80; // Fuel pump pin (A7)
103 if(portHDebounce
== 0){
109 // // find out which pin triggered it, clear the flag, perform the action.
110 // switch(portHFlags)
112 // case 0x80 : // Increment cylinder count and set port count appropriately.
113 // switch (configs.combustionEventsPerEngineCycle) {
115 // configs.combustionEventsPerEngineCycle = 2;
116 // configs.ports = 2;
119 // configs.combustionEventsPerEngineCycle = 3;
120 // configs.ports = 3;
123 // configs.combustionEventsPerEngineCycle = 4;
124 // configs.ports = 4;
127 // configs.combustionEventsPerEngineCycle = 5;
128 // configs.ports = 5;
131 // configs.combustionEventsPerEngineCycle = 6;
132 // configs.ports = 6;
135 // configs.combustionEventsPerEngineCycle = 8;
136 // configs.ports = 4;
139 // configs.combustionEventsPerEngineCycle = 10;
140 // configs.ports = 5;
143 // configs.combustionEventsPerEngineCycle = 12;
144 // configs.ports = 6;
147 // configs.combustionEventsPerEngineCycle = 1;
148 // configs.ports = 1;
152 // case 0x40 : // Injection output enable/disable
153 // if(coreSettingsA & FUEL_CUT){
154 // coreSettingsA &= FUEL_CUT_OFF;
156 // coreSettingsA |= FUEL_CUT;
159 // case 0x20 : // Ignition output enable/disable
160 // if(coreSettingsA & HARD_SPARK_CUT){
161 // coreSettingsA &= HARD_SPARK_CUT_OFF;
163 // coreSettingsA |= HARD_SPARK_CUT;
166 // case 0x10 : // Staged injection enable/disable
167 // if(coreSettingsA & STAGED_ON){
168 // coreSettingsA &= STAGED_OFF;
170 // coreSettingsA |= STAGED_ON;
173 // case 0x08 : // Staged injection start sched/fixed
174 // if(coreSettingsA & STAGED_START){
175 // coreSettingsA &= CLEAR_STAGED_START;
177 // coreSettingsA |= STAGED_START;
180 // case 0x04 : // Staged injection end sched/fixed
181 // if(coreSettingsA & STAGED_END){
182 // coreSettingsA &= CLEAR_STAGED_END;
184 // coreSettingsA |= STAGED_END;
187 // case 0x02 : // free input
189 // case 0x01 : // free input
191 // default : // Two or more pressed, nothing to do except wait for another button press
197 /** @brief IRQ/PE1 pin ISR
199 * Interrupt handler for edge events on the IRQ/PE1 pin. Not currently used.
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.
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.
233 void LowVoltageISR(void){
237 /* Increment the counter */
238 Counters
.lowVoltageConditions
++;