Add new build-all directory to ignore file. Add one missing firmware type to test...
[freeems-vanilla.git] / src / miscISRs.c
blob3c30a91b066594b4d7aaee0de04f7b2a89fcf4d1
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2012 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.
38 #include "inc/freeEMS.h"
39 #include "inc/interrupts.h"
42 /** @brief Unimplemented Interrupt Handler
44 * Unimplemented interrupt service routine for calls we weren't expecting.
45 * Currently this simply counts bad calls like any other event type.
47 * @todo TODO Split this into its own file, create one for each, and clear flags for all, and increment shared counter as is.
48 * @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...
50 void UISR(void){
51 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
52 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
53 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
57 /** @brief Port P pins ISR
59 * Interrupt handler for edge events on port P pins. Not currently used.
61 void PortPISR(void){
62 /* Clear all port P flags (we only want one at a time) */
63 PIFP = ONES;
64 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
65 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
66 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
70 /** @brief Port J pins ISR
72 * Interrupt handler for edge events on port J pins. Not currently used.
74 void PortJISR(void){
75 /* Clear all port H flags (we only want one at a time) */
76 PIFJ = ONES;
77 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
78 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
79 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
83 /** @brief Port H pins ISR
85 * Interrupt handler for edge events on port H pins. Not currently used.
87 void PortHISR(void)
89 // // read the interrupt flags to a variable
90 // unsigned char portHFlags = PIFH;
91 // portHFlags &= 0xF8; // mask out the other bits
93 // /* Clear all port H flags (we only want one at a time) */
94 PIFH = ONES;
95 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
97 // Bump this for the time being as this should not be occurring.
98 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
100 // // Toggle a LED so we can see if the code ran
101 // PO-don't use this-RTA ^= 0x80; // Fuel pump pin (A7)
103 // debounce
104 if(portHDebounce == 0){
105 portHDebounce = 2;
106 }else{
107 return;
110 // // find out which pin triggered it, clear the flag, perform the action.
111 // switch(portHFlags)
112 // {
113 // case 0x80 : // Increment cylinder count and set port count appropriately.
114 // switch (configs.combustionEventsPerEngineCycle) {
115 // case 1 :
116 // configs.combustionEventsPerEngineCycle = 2;
117 // configs.ports = 2;
118 // break;
119 // case 2 :
120 // configs.combustionEventsPerEngineCycle = 3;
121 // configs.ports = 3;
122 // break;
123 // case 3 :
124 // configs.combustionEventsPerEngineCycle = 4;
125 // configs.ports = 4;
126 // break;
127 // case 4 :
128 // configs.combustionEventsPerEngineCycle = 5;
129 // configs.ports = 5;
130 // break;
131 // case 5 :
132 // configs.combustionEventsPerEngineCycle = 6;
133 // configs.ports = 6;
134 // break;
135 // case 6 :
136 // configs.combustionEventsPerEngineCycle = 8;
137 // configs.ports = 4;
138 // break;
139 // case 8 :
140 // configs.combustionEventsPerEngineCycle = 10;
141 // configs.ports = 5;
142 // break;
143 // case 10 :
144 // configs.combustionEventsPerEngineCycle = 12;
145 // configs.ports = 6;
146 // break;
147 // case 12 :
148 // configs.combustionEventsPerEngineCycle = 1;
149 // configs.ports = 1;
150 // break;
151 // }
152 // break;
153 // case 0x40 : // Injection output enable/disable
154 // break;
155 // case 0x20 : // Ignition output enable/disable
156 // break;
157 // case 0x10 : // Staged injection enable/disable
158 // break;
159 // case 0x08 : // Staged injection start sched/fixed
160 // break;
161 // case 0x04 : // Staged injection end sched/fixed
162 // break;
163 // case 0x02 : // free input
164 // break;
165 // case 0x01 : // free input
166 // break;
167 // default : // Two or more pressed, nothing to do except wait for another button press
168 // break;
169 // }
170 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
174 /** @brief IRQ/PE1 pin ISR
176 * Interrupt handler for edge events on the IRQ/PE1 pin. Not currently used.
178 void IRQISR(void){
179 /* Clear the flag */
180 // ?? TODO
181 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
182 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
183 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
187 /** @brief XIRQ/PE0 pin ISR
189 * Interrupt handler for edge events on the XIRQ/PE0 pin. Not currently used.
191 void XIRQISR(void){
192 /* Clear the flag */
193 // ?? TODO
194 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT7, PORTB);
195 FLAG_AND_INC_FLAGGABLE(FLAG_CALLS_TO_UISRS_OFFSET);
196 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT7, PORTB);
200 /** @brief Low Voltage Counter
202 * Count how often our voltage drops lower than it should without resetting.
204 void LowVoltageISR(void){
205 /* Clear the flag */
206 VREGCTRL |= 0x01;
207 DEBUG_TURN_PIN_ON(DECODER_BENCHMARKS, BIT6, PORTB);
208 FLAG_AND_INC_FLAGGABLE(FLAG_LOW_VOLTATE_CONDITION_OFFSET);
209 DEBUG_TURN_PIN_OFF(DECODER_BENCHMARKS, NBIT6, PORTB);