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 initXgate(void) TEXT1; // Can't be paged because it has to burn to a page, for now... 00056 void initECTTimer(void) FPAGE_FE; 00057 void initPITTimer(void) FPAGE_FE; 00058 void initSCIStuff(void) FPAGE_FE; 00059 void initConfiguration(void) FPAGE_FE; 00060 void initInterrupts(void) FPAGE_FE; 00061 00062 // XGATE assembly symbols, only used for address/size 00063 extern void xgateThread0(void); 00064 extern void xgateThread0End(void); 00065 00066 /* Place these functions in the same block of flash as the data upon which they operate! */ 00067 void initLookupAddresses(void) LOOKUPF; 00068 void initFuelAddresses(void) FUELTABLESF; 00069 void initTimingAddresses(void) TIMETABLESF; 00070 void initTunableAddresses(void) TUNETABLESF; 00071 void initPagedRAMFuel(void) FUELTABLESF; 00072 void initPagedRAMTime(void) TIMETABLESF; 00073 void initPagedRAMTune(void) TUNETABLESF; 00074 00075 #else 00076 #define EXTERN extern 00077 #endif 00078 00079 00080 /* Other function declarations are private and present in the C */ 00081 /* source file purely to assign them to a particular memory region. */ 00082 EXTERN void init(void) FPAGE_FE; 00083 00084 00085 /* Various masks and values used for initialising the contents of control registers. */ 00086 /* For information on how these are being used, try this link : */ 00087 /* http://www.vipan.com/htdocs/bitwisehelp.html */ 00088 00089 00090 // PLL control values 00091 #define PLLLOCK 0x08 /* Mask for checking to see when the PLL loop is locked onto its target */ 00092 #define PLLSELOFF 0x7F /* Mask for switching to base external OSCCLK clock 0b_0111_1111 */ 00093 #define PLLSELON 0x80 /* Mask for switching to internally multiplied PLL clock 0b_1000_0000 */ 00094 #define PLLOFF 0xBF /* Mask for turning the PLLON bit to ZERO 0b_1011_1111, IE, turning PLL off */ 00095 #define PLLON 0x40 /* Mask for setting PLLON bit to ONE 0b_0100_0000, IE, turning PLL on */ 00096 #define PLLDIVISOR 0x03 /* Input crystal frequency is divided by this number */ 00097 #define PLLMULTIPLIER 0x09 /* The result of the above is multiplied by this number to give the bus frequency */ 00098 00099 // Flash control values 00100 #define PRDIV8 0x40 /* Mask for flash module to divide the oscillator clock by 8 */ 00101 00102 00105 00106 00107 #undef EXTERN 00108 00109 00110 #else 00111 /* let us know if we are being untidy with headers */ 00112 #warning "Header file INIT_H seen before, sort it out!" 00113 /* end of the wrapper ifdef from the very top */ 00114 #endif