00001 /* FreeEMS - the open source engine management system 00002 00003 Copyright 2008 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 00038 #include "inc/freeEMS.h" 00039 #include "inc/interrupts.h" 00040 00041 00049 void UISR(void){ 00050 /* Increment the unimplemented ISR execution counter */ 00051 Counters.callsToUISRs++; 00052 } 00053 00054 00061 void PortPISR(void){ 00062 /* Clear all port P flags (we only want one at a time) */ 00063 PIFP = ONES; 00064 /* Increment the unimplemented ISR execution counter */ 00065 Counters.callsToUISRs++; 00066 } /* Port P interrupt service routine */ 00067 00068 00075 void PortJISR(void){ 00076 /* Clear all port H flags (we only want one at a time) */ 00077 PIFJ = ONES; 00078 /* Increment the unimplemented ISR execution counter */ 00079 Counters.callsToUISRs++; 00080 } 00081 00082 00089 void PortHISR(void) 00090 { 00091 // // read the interrupt flags to a variable 00092 // unsigned char portHFlags = PIFH; 00093 // portHFlags &= 0xF8; // mask out the other bits 00094 // 00095 // /* Clear all port H flags (we only want one at a time) */ 00096 PIFH = ONES; 00097 // 00098 // // Toggle a LED so we can see if the code ran 00099 PORTA ^= 0x80; // Fuel pump pin (A7) 00100 // 00101 // debounce 00102 if(portHDebounce == 0){ 00103 portHDebounce = 2; 00104 }else{ 00105 return; 00106 } 00107 // 00108 // // find out which pin triggered it, clear the flag, perform the action. 00109 // switch(portHFlags) 00110 // { 00111 // case 0x80 : // Increment cylinder count and set port count appropriately. 00112 // switch (configs.combustionEventsPerEngineCycle) { 00113 // case 1 : 00114 // configs.combustionEventsPerEngineCycle = 2; 00115 // configs.ports = 2; 00116 // break; 00117 // case 2 : 00118 // configs.combustionEventsPerEngineCycle = 3; 00119 // configs.ports = 3; 00120 // break; 00121 // case 3 : 00122 // configs.combustionEventsPerEngineCycle = 4; 00123 // configs.ports = 4; 00124 // break; 00125 // case 4 : 00126 // configs.combustionEventsPerEngineCycle = 5; 00127 // configs.ports = 5; 00128 // break; 00129 // case 5 : 00130 // configs.combustionEventsPerEngineCycle = 6; 00131 // configs.ports = 6; 00132 // break; 00133 // case 6 : 00134 // configs.combustionEventsPerEngineCycle = 8; 00135 // configs.ports = 4; 00136 // break; 00137 // case 8 : 00138 // configs.combustionEventsPerEngineCycle = 10; 00139 // configs.ports = 5; 00140 // break; 00141 // case 10 : 00142 // configs.combustionEventsPerEngineCycle = 12; 00143 // configs.ports = 6; 00144 // break; 00145 // case 12 : 00146 // configs.combustionEventsPerEngineCycle = 1; 00147 // configs.ports = 1; 00148 // break; 00149 // } 00150 // break; 00151 // case 0x40 : // Injection output enable/disable 00152 // if(coreSettingsA & FUEL_CUT){ 00153 // coreSettingsA &= FUEL_CUT_OFF; 00154 // }else{ 00155 // coreSettingsA |= FUEL_CUT; 00156 // } 00157 // break; 00158 // case 0x20 : // Ignition output enable/disable 00159 // if(coreSettingsA & HARD_SPARK_CUT){ 00160 // coreSettingsA &= HARD_SPARK_CUT_OFF; 00161 // }else{ 00162 // coreSettingsA |= HARD_SPARK_CUT; 00163 // } 00164 // break; 00165 // case 0x10 : // Staged injection enable/disable 00166 // if(coreSettingsA & STAGED_ON){ 00167 // coreSettingsA &= STAGED_OFF; 00168 // }else{ 00169 // coreSettingsA |= STAGED_ON; 00170 // } 00171 // break; 00172 // case 0x08 : // Staged injection start sched/fixed 00173 // if(coreSettingsA & STAGED_START){ 00174 // coreSettingsA &= CLEAR_STAGED_START; 00175 // }else{ 00176 // coreSettingsA |= STAGED_START; 00177 // } 00178 // break; 00179 // case 0x04 : // Staged injection end sched/fixed 00180 // if(coreSettingsA & STAGED_END){ 00181 // coreSettingsA &= CLEAR_STAGED_END; 00182 // }else{ 00183 // coreSettingsA |= STAGED_END; 00184 // } 00185 // break; 00186 // case 0x02 : // free input 00187 // break; 00188 // case 0x01 : // free input 00189 // break; 00190 // default : // Two or more pressed, nothing to do except wait for another button press 00191 // break; 00192 // } 00193 } 00194 00195 00202 void IRQISR(void){ 00203 /* Clear the flag */ 00204 // ?? TODO 00205 00206 /* Increment the unimplemented ISR execution counter */ 00207 Counters.callsToUISRs++; 00208 } 00209 00210 00217 void XIRQISR(void){ 00218 /* Clear the flag */ 00219 // ?? TODO 00220 00221 /* Increment the unimplemented ISR execution counter */ 00222 Counters.callsToUISRs++; 00223 } 00224 00225 00232 void LowVoltageISR(void){ 00233 /* Clear the flag */ 00234 VREGCTRL |= 0x01; 00235 00236 /* Increment the counter */ 00237 Counters.lowVoltageConditions++; 00238 }