Refactored fixed confs 1 into modular chunks and added to llookup function to make...
[freeems-vanilla.git] / src / miscISRs.c
blob78f372c01db1036430da45ffd5f2ff508bd23232
1 /* miscISRs.c
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! */
26 #include "inc/freeEMS.h"
27 #include "inc/interrupts.h"
30 /* Unimplemented interrupt service routine */
31 void UISR(void){
32 /* Increment the unimplemented ISR execution counter */
33 Counters.callsToUISRs++;
37 void PortPISR(void){
38 /* Clear all port P flags (we only want one at a time) */
39 PIFP = ONES;
40 /* Increment the unimplemented ISR execution counter */
41 Counters.callsToUISRs++;
42 } /* Port P interrupt service routine */
45 /* Port J interrupt service routine */
46 void PortJISR(void){
47 /* Clear all port H flags (we only want one at a time) */
48 PIFJ = ONES;
49 /* Increment the unimplemented ISR execution counter */
50 Counters.callsToUISRs++;
54 /* Port H interrupt service routine */
55 void PortHISR(void)
57 // // read the interrupt flags to a variable
58 // unsigned char portHFlags = PIFH;
59 // portHFlags &= 0xF8; // mask out the other bits
61 // /* Clear all port H flags (we only want one at a time) */
62 PIFH = ONES;
64 // // Toggle a LED so we can see if the code ran
65 PORTA ^= 0x80; // Fuel pump pin (A7)
67 // debounce
68 if(portHDebounce == 0){
69 portHDebounce = 2;
70 }else{
71 return;
74 // // find out which pin triggered it, clear the flag, perform the action.
75 // switch(portHFlags)
76 // {
77 // case 0x80 : // Increment cylinder count and set port count appropriately.
78 // switch (configs.combustionEventsPerEngineCycle) {
79 // case 1 :
80 // configs.combustionEventsPerEngineCycle = 2;
81 // configs.ports = 2;
82 // break;
83 // case 2 :
84 // configs.combustionEventsPerEngineCycle = 3;
85 // configs.ports = 3;
86 // break;
87 // case 3 :
88 // configs.combustionEventsPerEngineCycle = 4;
89 // configs.ports = 4;
90 // break;
91 // case 4 :
92 // configs.combustionEventsPerEngineCycle = 5;
93 // configs.ports = 5;
94 // break;
95 // case 5 :
96 // configs.combustionEventsPerEngineCycle = 6;
97 // configs.ports = 6;
98 // break;
99 // case 6 :
100 // configs.combustionEventsPerEngineCycle = 8;
101 // configs.ports = 4;
102 // break;
103 // case 8 :
104 // configs.combustionEventsPerEngineCycle = 10;
105 // configs.ports = 5;
106 // break;
107 // case 10 :
108 // configs.combustionEventsPerEngineCycle = 12;
109 // configs.ports = 6;
110 // break;
111 // case 12 :
112 // configs.combustionEventsPerEngineCycle = 1;
113 // configs.ports = 1;
114 // break;
115 // }
116 // break;
117 // case 0x40 : // Injection output enable/disable
118 // if(coreSettingsA & FUEL_CUT){
119 // coreSettingsA &= FUEL_CUT_OFF;
120 // }else{
121 // coreSettingsA |= FUEL_CUT;
122 // }
123 // break;
124 // case 0x20 : // Ignition output enable/disable
125 // if(coreSettingsA & HARD_SPARK_CUT){
126 // coreSettingsA &= HARD_SPARK_CUT_OFF;
127 // }else{
128 // coreSettingsA |= HARD_SPARK_CUT;
129 // }
130 // break;
131 // case 0x10 : // Staged injection enable/disable
132 // if(coreSettingsA & STAGED_ON){
133 // coreSettingsA &= STAGED_OFF;
134 // }else{
135 // coreSettingsA |= STAGED_ON;
136 // }
137 // break;
138 // case 0x08 : // Staged injection start sched/fixed
139 // if(coreSettingsA & STAGED_START){
140 // coreSettingsA &= CLEAR_STAGED_START;
141 // }else{
142 // coreSettingsA |= STAGED_START;
143 // }
144 // break;
145 // case 0x04 : // Staged injection end sched/fixed
146 // if(coreSettingsA & STAGED_END){
147 // coreSettingsA &= CLEAR_STAGED_END;
148 // }else{
149 // coreSettingsA |= STAGED_END;
150 // }
151 // break;
152 // case 0x02 : // free input
153 // break;
154 // case 0x01 : // free input
155 // break;
156 // default : // Two or more pressed, nothing to do except wait for another button press
157 // break;
158 // }
162 /* IRQ/PE1 interrupt service routine */
163 void IRQISR(void){
164 /* Clear the flag */
165 // ?? TODO
167 /* Increment the unimplemented ISR execution counter */
168 Counters.callsToUISRs++;
172 /* XIRQ/PE0 interrupt service routine */
173 void XIRQISR(void){
174 /* Clear the flag */
175 // ?? TODO
177 /* Increment the unimplemented ISR execution counter */
178 Counters.callsToUISRs++;
182 /* Count how often our voltage goes too low without resetting */
183 void LowVoltageISR(void){
184 /* Clear the flag */
185 VREGCTRL |= 0x01;
187 /* Increment the counter */
188 Counters.lowVoltageConditions++;