Ditch a bunch of superfluous lines that were always unused and made hex interpretatio...
[freeems-vanilla.git] / src / miscISRs.c
blob6b26631f0872ddf7656b5a399c7efbc8e46922e1
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2011 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
29 * @ingroup interruptHandlers
31 * @brief Miscellaneous Interrupt Handlers
33 * Various non-descript interrupt handlers that don't really fit anywhere else
34 * and aren't big enough to live on their own just yet.
36 * @author Fred Cooke
40 #include "inc/freeEMS.h"
41 #include "inc/interrupts.h"
44 /** @brief Unimplemented Interrupt Handler
46 * Unimplemented interrupt service routine for calls we weren't expecting.
47 * Currently this simply counts bad calls like any other event type.
49 * @author Fred Cooke
50 * @todo TODO Split this into its own file, create one for each, and clear flags for all, and increment shared counter as is.
51 * @todo TODO Currently not a problem, but as indirectly pointed out by johntramp, if no flag clearing is being done, then this code will run continuously, which is not a good idea...
53 void UISR(void){
54 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
55 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
56 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
60 /** @brief Port P pins ISR
62 * Interrupt handler for edge events on port P pins. Not currently used.
64 * @author Fred Cooke
66 void PortPISR(void){
67 /* Clear all port P flags (we only want one at a time) */
68 PIFP = ONES;
69 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
70 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
71 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
75 /** @brief Port J pins ISR
77 * Interrupt handler for edge events on port J pins. Not currently used.
79 * @author Fred Cooke
81 void PortJISR(void){
82 /* Clear all port H flags (we only want one at a time) */
83 PIFJ = ONES;
84 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
85 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
86 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
90 /** @brief Port H pins ISR
92 * Interrupt handler for edge events on port H pins. Not currently used.
94 * @author Fred Cooke
96 void PortHISR(void)
98 // // read the interrupt flags to a variable
99 // unsigned char portHFlags = PIFH;
100 // portHFlags &= 0xF8; // mask out the other bits
102 // /* Clear all port H flags (we only want one at a time) */
103 PIFH = ONES;
104 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
106 // Bump this for the time being as this should not be occurring.
107 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
109 // // Toggle a LED so we can see if the code ran
110 // PO-don't use this-RTA ^= 0x80; // Fuel pump pin (A7)
112 // debounce
113 if(portHDebounce == 0){
114 portHDebounce = 2;
115 }else{
116 return;
119 // // find out which pin triggered it, clear the flag, perform the action.
120 // switch(portHFlags)
121 // {
122 // case 0x80 : // Increment cylinder count and set port count appropriately.
123 // switch (configs.combustionEventsPerEngineCycle) {
124 // case 1 :
125 // configs.combustionEventsPerEngineCycle = 2;
126 // configs.ports = 2;
127 // break;
128 // case 2 :
129 // configs.combustionEventsPerEngineCycle = 3;
130 // configs.ports = 3;
131 // break;
132 // case 3 :
133 // configs.combustionEventsPerEngineCycle = 4;
134 // configs.ports = 4;
135 // break;
136 // case 4 :
137 // configs.combustionEventsPerEngineCycle = 5;
138 // configs.ports = 5;
139 // break;
140 // case 5 :
141 // configs.combustionEventsPerEngineCycle = 6;
142 // configs.ports = 6;
143 // break;
144 // case 6 :
145 // configs.combustionEventsPerEngineCycle = 8;
146 // configs.ports = 4;
147 // break;
148 // case 8 :
149 // configs.combustionEventsPerEngineCycle = 10;
150 // configs.ports = 5;
151 // break;
152 // case 10 :
153 // configs.combustionEventsPerEngineCycle = 12;
154 // configs.ports = 6;
155 // break;
156 // case 12 :
157 // configs.combustionEventsPerEngineCycle = 1;
158 // configs.ports = 1;
159 // break;
160 // }
161 // break;
162 // case 0x40 : // Injection output enable/disable
163 // break;
164 // case 0x20 : // Ignition output enable/disable
165 // break;
166 // case 0x10 : // Staged injection enable/disable
167 // break;
168 // case 0x08 : // Staged injection start sched/fixed
169 // break;
170 // case 0x04 : // Staged injection end sched/fixed
171 // break;
172 // case 0x02 : // free input
173 // break;
174 // case 0x01 : // free input
175 // break;
176 // default : // Two or more pressed, nothing to do except wait for another button press
177 // break;
178 // }
179 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
183 /** @brief IRQ/PE1 pin ISR
185 * Interrupt handler for edge events on the IRQ/PE1 pin. Not currently used.
187 * @author Fred Cooke
189 void IRQISR(void){
190 /* Clear the flag */
191 // ?? TODO
192 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
193 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
194 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
198 /** @brief XIRQ/PE0 pin ISR
200 * Interrupt handler for edge events on the XIRQ/PE0 pin. Not currently used.
202 * @author Fred Cooke
204 void XIRQISR(void){
205 /* Clear the flag */
206 // ?? TODO
207 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
208 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
209 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
213 /** @brief Low Voltage Counter
215 * Count how often our voltage drops lower than it should without resetting.
217 * @author Fred Cooke
219 void LowVoltageISR(void){
220 /* Clear the flag */
221 VREGCTRL |= 0x01;
222 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT6, PORTB);
223 FLAG_AND_INC_FLAGGABLE(FLAG_LOW_VOLTATE_CONDITION_OFFSET);
224 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT6, PORTB);