00001 /* FreeEMS - the open source engine management system 00002 * 00003 * Copyright 2008, 2009 Fred Cooke 00004 * 00005 * This file is part of the FreeEMS project. 00006 * 00007 * FreeEMS software is free software: you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation, either version 3 of the License, or 00010 * (at your option) any later version. 00011 * 00012 * FreeEMS software is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ 00019 * 00020 * We ask that if you make any changes to this file you email them upstream to 00021 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! 00022 * 00023 * Thank you for choosing FreeEMS to run your engine! 00024 */ 00025 00026 00039 #include "inc/freeEMS.h" 00040 #include "inc/interrupts.h" 00041 00042 00050 void UISR(void){ 00051 /* Increment the unimplemented ISR execution counter */ 00052 Counters.callsToUISRs++; 00053 } 00054 00055 00062 void PortPISR(void){ 00063 /* Clear all port P flags (we only want one at a time) */ 00064 PIFP = ONES; 00065 /* Increment the unimplemented ISR execution counter */ 00066 Counters.callsToUISRs++; 00067 } /* Port P interrupt service routine */ 00068 00069 00076 void PortJISR(void){ 00077 /* Clear all port H flags (we only want one at a time) */ 00078 PIFJ = ONES; 00079 /* Increment the unimplemented ISR execution counter */ 00080 Counters.callsToUISRs++; 00081 } 00082 00083 00090 void PortHISR(void) 00091 { 00092 // // read the interrupt flags to a variable 00093 // unsigned char portHFlags = PIFH; 00094 // portHFlags &= 0xF8; // mask out the other bits 00095 // 00096 // /* Clear all port H flags (we only want one at a time) */ 00097 PIFH = ONES; 00098 // 00099 // // Toggle a LED so we can see if the code ran 00100 PORTA ^= 0x80; // Fuel pump pin (A7) 00101 // 00102 // debounce 00103 if(portHDebounce == 0){ 00104 portHDebounce = 2; 00105 }else{ 00106 return; 00107 } 00108 // 00109 // // find out which pin triggered it, clear the flag, perform the action. 00110 // switch(portHFlags) 00111 // { 00112 // case 0x80 : // Increment cylinder count and set port count appropriately. 00113 // switch (configs.combustionEventsPerEngineCycle) { 00114 // case 1 : 00115 // configs.combustionEventsPerEngineCycle = 2; 00116 // configs.ports = 2; 00117 // break; 00118 // case 2 : 00119 // configs.combustionEventsPerEngineCycle = 3; 00120 // configs.ports = 3; 00121 // break; 00122 // case 3 : 00123 // configs.combustionEventsPerEngineCycle = 4; 00124 // configs.ports = 4; 00125 // break; 00126 // case 4 : 00127 // configs.combustionEventsPerEngineCycle = 5; 00128 // configs.ports = 5; 00129 // break; 00130 // case 5 : 00131 // configs.combustionEventsPerEngineCycle = 6; 00132 // configs.ports = 6; 00133 // break; 00134 // case 6 : 00135 // configs.combustionEventsPerEngineCycle = 8; 00136 // configs.ports = 4; 00137 // break; 00138 // case 8 : 00139 // configs.combustionEventsPerEngineCycle = 10; 00140 // configs.ports = 5; 00141 // break; 00142 // case 10 : 00143 // configs.combustionEventsPerEngineCycle = 12; 00144 // configs.ports = 6; 00145 // break; 00146 // case 12 : 00147 // configs.combustionEventsPerEngineCycle = 1; 00148 // configs.ports = 1; 00149 // break; 00150 // } 00151 // break; 00152 // case 0x40 : // Injection output enable/disable 00153 // if(coreSettingsA & FUEL_CUT){ 00154 // coreSettingsA &= FUEL_CUT_OFF; 00155 // }else{ 00156 // coreSettingsA |= FUEL_CUT; 00157 // } 00158 // break; 00159 // case 0x20 : // Ignition output enable/disable 00160 // if(coreSettingsA & HARD_SPARK_CUT){ 00161 // coreSettingsA &= HARD_SPARK_CUT_OFF; 00162 // }else{ 00163 // coreSettingsA |= HARD_SPARK_CUT; 00164 // } 00165 // break; 00166 // case 0x10 : // Staged injection enable/disable 00167 // if(coreSettingsA & STAGED_ON){ 00168 // coreSettingsA &= STAGED_OFF; 00169 // }else{ 00170 // coreSettingsA |= STAGED_ON; 00171 // } 00172 // break; 00173 // case 0x08 : // Staged injection start sched/fixed 00174 // if(coreSettingsA & STAGED_START){ 00175 // coreSettingsA &= CLEAR_STAGED_START; 00176 // }else{ 00177 // coreSettingsA |= STAGED_START; 00178 // } 00179 // break; 00180 // case 0x04 : // Staged injection end sched/fixed 00181 // if(coreSettingsA & STAGED_END){ 00182 // coreSettingsA &= CLEAR_STAGED_END; 00183 // }else{ 00184 // coreSettingsA |= STAGED_END; 00185 // } 00186 // break; 00187 // case 0x02 : // free input 00188 // break; 00189 // case 0x01 : // free input 00190 // break; 00191 // default : // Two or more pressed, nothing to do except wait for another button press 00192 // break; 00193 // } 00194 } 00195 00196 00203 void IRQISR(void){ 00204 /* Clear the flag */ 00205 // ?? TODO 00206 00207 /* Increment the unimplemented ISR execution counter */ 00208 Counters.callsToUISRs++; 00209 } 00210 00211 00218 void XIRQISR(void){ 00219 /* Clear the flag */ 00220 // ?? TODO 00221 00222 /* Increment the unimplemented ISR execution counter */ 00223 Counters.callsToUISRs++; 00224 } 00225 00226 00233 void LowVoltageISR(void){ 00234 /* Clear the flag */ 00235 VREGCTRL |= 0x01; 00236 00237 /* Increment the counter */ 00238 Counters.lowVoltageConditions++; 00239 }