Update all files committed against this year with additional copyright years.
[freeems-vanilla.git] / src / inc / init.h
blob41b0c8030efa37bef18cdb5f19fb1577b3990273
1 /* FreeEMS - the open source engine management system
3 * Copyright 2008, 2009, 2010 Fred Cooke
5 * This file is part of the FreeEMS project.
7 * FreeEMS software is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * FreeEMS software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with any FreeEMS software. If not, see http://www.gnu.org/licenses/
20 * We ask that if you make any changes to this file you email them upstream to
21 * us at admin(at)diyefi(dot)org or, even better, fork the code on github.com!
23 * Thank you for choosing FreeEMS to run your engine!
27 /** @file init.h
28 * @ingroup allHeaders
32 /* Header file multiple inclusion protection courtesy eclipse Header Template */
33 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
34 #ifndef FILE_INIT_H_SEEN
35 #define FILE_INIT_H_SEEN
38 #ifdef EXTERN
39 #warning "EXTERN already defined by another header, please sort it out!"
40 #undef EXTERN /* If fail on warning is off, remove the definition such that we can redefine correctly. */
41 #endif
44 #ifdef INIT_C
45 #define EXTERN
46 /* For private internal use of init.c init() function only, hence wrapped in this ifdef */
48 /* Keep this non ISR stuff out of linear flash space */
49 void initPLL(void) FPAGE_FE;
50 void initIO(void) FPAGE_FE;
51 void initAllPagedRAM(void) FPAGE_FE;
52 void initAllPagedAddresses(void) FPAGE_FE;
53 void initVariables(void) FPAGE_FE;
54 void initFlash(void) FPAGE_FE;
55 void initECTTimer(void) FPAGE_FE;
56 void initPITTimer(void) FPAGE_FE;
57 void initSCIStuff(void) FPAGE_FE;
58 void initConfiguration(void) FPAGE_FE;
59 void initInterrupts(void) FPAGE_FE;
61 /* Place these functions in the same block of flash as the data upon which they operate! */
62 void initLookupAddresses(void) LOOKUPF;
63 void initFuelAddresses(void) FUELTABLESF;
64 void initTimingAddresses(void) TIMETABLESF;
65 void initTunableAddresses(void) TUNETABLESF;
66 void initPagedRAMFuel(void) FUELTABLESF;
67 void initPagedRAMTime(void) TIMETABLESF;
68 void initPagedRAMTune(void) TUNETABLESF;
70 #else
71 #define EXTERN extern
72 #endif
75 /* Other function declarations are private and present in the C */
76 /* source file purely to assign them to a particular memory region. */
77 EXTERN void init(void) FPAGE_FE;
80 /* Various masks and values used for initialising the contents of control registers. */
81 /* For information on how these are being used, try this link : */
82 /* http://www.vipan.com/htdocs/bitwisehelp.html */
85 // PLL control values
86 #define PLLLOCK 0x08 /* Mask for checking to see when the PLL loop is locked onto its target */
87 #define PLLSELOFF 0x7F /* Mask for switching to base external OSCCLK clock 0b_0111_1111 */
88 #define PLLSELON 0x80 /* Mask for switching to internally multiplied PLL clock 0b_1000_0000 */
89 #define PLLOFF 0xBF /* Mask for turning the PLLON bit to ZERO 0b_1011_1111, IE, turning PLL off */
90 #define PLLON 0x40 /* Mask for setting PLLON bit to ONE 0b_0100_0000, IE, turning PLL on */
91 #define PLLDIVISOR 0x03 /* Input crystal frequency is divided by this number */
92 #define PLLMULTIPLIER 0x09 /* The result of the above is multiplied by this number to give the bus frequency */
94 // Flash control values
95 #define PRDIV8 0x40 /* Mask for flash module to divide the oscillator clock by 8 */
97 /// @todo TODO define other macros such that raw values aren't used in the code
98 /// @todo TODO move all the reg masks to a header of their own for general use.
101 #undef EXTERN
104 #else
105 /* let us know if we are being untidy with headers */
106 #warning "Header file INIT_H seen before, sort it out!"
107 /* end of the wrapper ifdef from the very top */
108 #endif