00001 /* Copyright 2008 Fred Cooke 00002 00003 This file is part of the FreeEMS project. 00004 00005 FreeEMS software is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 FreeEMS software is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with any FreeEMS software. If not, see http://www.gnu.org/licenses/ 00017 00018 We ask that if you make any changes to this file you email them upstream to 00019 us at admin(at)diyefi(dot)org or, even better, fork the code on github.com! 00020 00021 Thank you for choosing FreeEMS to run your engine! */ 00022 00023 00029 /* Header file multiple inclusion protection courtesy eclipse Header Template */ 00030 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */ 00031 #ifndef FILE_INIT_H_SEEN 00032 #define FILE_INIT_H_SEEN 00033 00034 00035 #ifdef EXTERN 00036 #warning "EXTERN already defined by another header, please sort it out!" 00037 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */ 00038 #endif 00039 00040 00041 #ifdef INIT_C 00042 #define EXTERN 00043 /* For private internal use of init.c init() function only, hence wrapped in this ifdef */ 00044 void initPLL(void) FPAGE_FE; 00045 void initIO(void) FPAGE_FE; 00046 void initAllPagedRAM(void) FPAGE_FE; 00047 void initAllPagedAddresses(void) FPAGE_FE; 00048 void initVariables(void) FPAGE_FE; 00049 void initFlash(void) FPAGE_FE; 00050 void initECTTimer(void) FPAGE_FE; 00051 void initPITTimer(void) FPAGE_FE; 00052 void initSCIStuff(void) FPAGE_FE; 00053 void initConfiguration(void) FPAGE_FE; 00054 void initInterrupts(void) FPAGE_FE; 00055 void initLookupAddresses(void) LOOKUPF; 00056 void initFuelAddresses(void) FUELTABLESF; 00057 void initTimingAddresses(void) TIMETABLESF; 00058 void initTunableAddresses(void) TUNETABLESF; 00059 void initPagedRAMFuel(void) FUELTABLESF; 00060 void initPagedRAMTime(void) TIMETABLESF; 00061 void initPagedRAMTune(void) TUNETABLESF; 00062 #else 00063 #define EXTERN extern 00064 #endif 00065 00066 00067 /* Other function declarations are private and present in the C */ 00068 /* source file purely to assign them to a particular memory region. */ 00069 EXTERN void init(void) FPAGE_FE; 00070 00071 00072 /* Various masks and values used for initialising the contents of control registers. */ 00073 /* For information on how these are being used, try this link : */ 00074 /* http://www.vipan.com/htdocs/bitwisehelp.html */ 00075 00076 00077 // PLL control values 00078 #define PLLLOCK 0x08 /* Mask for checking to see when the PLL loop is locked onto its target */ 00079 #define PLLSELOFF 0x7F /* Mask for switching to base external OSCCLK clock 0b_0111_1111 */ 00080 #define PLLSELON 0x80 /* Mask for switching to internally multiplied PLL clock 0b_1000_0000 */ 00081 #define PLLOFF 0xBF /* Mask for turning the PLLON bit to ZERO 0b_1011_1111, IE, turning PLL off */ 00082 #define PLLON 0x40 /* Mask for setting PLLON bit to ONE 0b_0100_0000, IE, turning PLL on */ 00083 #define PLLDIVISOR 0x03 /* Input crystal frequency is divided by this number */ 00084 #define PLLMULTIPLIER 0x09 /* The result of the above is multiplied by this number to give the bus frequency */ 00085 00086 // Flash control values 00087 #define PRDIV8 0x40 /* Mask for flash module to divide the oscillator clock by 8 */ 00088 00091 00092 00093 #undef EXTERN 00094 00095 00096 #else 00097 /* let us know if we are being untidy with headers */ 00098 #warning "Header file INIT_H seen before, sort it out!" 00099 /* end of the wrapper ifdef from the very top */ 00100 #endif