00001 /* FreeEMS - the open source engine management system 00002 * 00003 * Copyright 2008, 2009, 2010 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 00032 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00033 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00034 #ifndef FILE_INIT_H_SEEN 00035 #define FILE_INIT_H_SEEN 00036 00037 00038 #ifdef EXTERN 00039 #warning "EXTERN already defined by another header, please sort it out!" 00040 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */ 00041 #endif 00042 00043 00044 #ifdef INIT_C 00045 #define EXTERN 00046 /* For private internal use of init.c init() function only, hence wrapped in this ifdef */ 00047 00048 /* Keep this non ISR stuff out of linear flash space */ 00049 void initPLL(void) FPAGE_FE; 00050 void initIO(void) FPAGE_FE; 00051 void initAllPagedRAM(void) FPAGE_FE; 00052 void initAllPagedAddresses(void) FPAGE_FE; 00053 void initVariables(void) FPAGE_FE; 00054 void initFlash(void) FPAGE_FE; 00055 void initECTTimer(void) FPAGE_FE; 00056 void initPITTimer(void) FPAGE_FE; 00057 void initSCIStuff(void) FPAGE_FE; 00058 void initConfiguration(void) FPAGE_FE; 00059 void initInterrupts(void) FPAGE_FE; 00060 00061 /* Place these functions in the same block of flash as the data upon which they operate! */ 00062 void initLookupAddresses(void) LOOKUPF; 00063 void initFuelAddresses(void) FUELTABLESF; 00064 void initTimingAddresses(void) TIMETABLESF; 00065 void initTunableAddresses(void) TUNETABLESF; 00066 void initPagedRAMFuel(void) FUELTABLESF; 00067 void initPagedRAMTime(void) TIMETABLESF; 00068 void initPagedRAMTune(void) TUNETABLESF; 00069 00070 #else 00071 #define EXTERN extern 00072 #endif 00073 00074 00075 /* Other function declarations are private and present in the C */ 00076 /* source file purely to assign them to a particular memory region. */ 00077 EXTERN void init(void) FPAGE_FE; 00078 00079 00080 /* Various masks and values used for initialising the contents of control registers. */ 00081 /* For information on how these are being used, try this link : */ 00082 /* http://www.vipan.com/htdocs/bitwisehelp.html */ 00083 00084 00085 // PLL control values 00086 #define PLLLOCK 0x08 /* Mask for checking to see when the PLL loop is locked onto its target */ 00087 #define PLLSELOFF 0x7F /* Mask for switching to base external OSCCLK clock 0b_0111_1111 */ 00088 #define PLLSELON 0x80 /* Mask for switching to internally multiplied PLL clock 0b_1000_0000 */ 00089 #define PLLOFF 0xBF /* Mask for turning the PLLON bit to ZERO 0b_1011_1111, IE, turning PLL off */ 00090 #define PLLON 0x40 /* Mask for setting PLLON bit to ONE 0b_0100_0000, IE, turning PLL on */ 00091 #define PLLDIVISOR 0x03 /* Input crystal frequency is divided by this number */ 00092 #define PLLMULTIPLIER 0x09 /* The result of the above is multiplied by this number to give the bus frequency */ 00093 00094 // Flash control values 00095 #define PRDIV8 0x40 /* Mask for flash module to divide the oscillator clock by 8 */ 00096 00099 00100 00101 #undef EXTERN 00102 00103 00104 #else 00105 /* let us know if we are being untidy with headers */ 00106 #warning "Header file INIT_H seen before, sort it out!" 00107 /* end of the wrapper ifdef from the very top */ 00108 #endif