1 /* FreeEMS - the open source engine management system
3 * Copyright 2008-2012 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!
30 * @ingroup globalHeaders
32 * @brief Global hash define literal replacements
34 * This holds general purpose hash defined constants and literals.
36 * @todo TODO Some investigation as to whether it is best to use consts or defines is required
40 /* Header file multiple inclusion protection courtesy eclipse Header Template */
41 /* and http://gcc.gnu.org/onlinedocs/gcc-3.1.1/cpp/ C pre processor manual */
42 #ifndef FILE_GLOBALDEFINES_H_SEEN
43 #define FILE_GLOBALDEFINES_H_SEEN
46 /* TODO perhaps configure various ports and pins etc to have names such that the
47 * code can stay untouched when being ported and just the header changed to suit?
48 * definitely a good idea, but we'll see what karsten says before putting time
49 * into it. something like : #define RPM_IN_MAIN IC0 etc etc
53 /* Definitions for functions used across the project TODO these are unused! */
54 /* http://www.seattlerobotics.org/encoder/200109/encoder.htm section Assembly */
55 #define INLINE_ASSEMBLY(code) __asm__ __volatile__ (code)
56 #define ALWAYS_INLINE __attribute__((always_inline))
58 /* Common macro definitions across the project */
59 /* Booleans from http://c2.com/cgi/wiki?CeePreprocessorStatements */
60 #define FALSE (0!=0) // Note, this evaluates to 0 on this platform
61 #define TRUE !FALSE // Note, this evaluates to 1 on this platform
68 #define ZEROS16 0x0000
71 /* Halves and Maxes */
72 #define LONGHALF 0x80000000UL /* 2147483648 */ // Ned IS awesome! ;-)
73 #define LONGMAX 0xFFFFFFFFUL /* 4294967295 */
74 #define SHORT4TH 0x4000 /* 16384 */
75 #define SHORTHALF 0x8000 /* 32768 */
76 #define SHORTMAX 0xFFFF /* 65535 */
78 /* Individual bits WARNING, do not not these for notted versions, use the notted ones below instead : http://supp.iar.com/Support/?note=12582&from=search+result */
79 #define BIT0 0x01 /* 1st bit = 1 */
80 #define BIT1 0x02 /* 2nd bit = 2 */
81 #define BIT2 0x04 /* 3rd bit = 4 */
82 #define BIT3 0x08 /* 4th bit = 8 */
83 #define BIT4 0x10 /* 5th bit = 16 */
84 #define BIT5 0x20 /* 6th bit = 32 */
85 #define BIT6 0x40 /* 7th bit = 64 */
86 #define BIT7 0x80 /* 8th bit = 128 */
88 #define BIT0_16 0x0001 /* 1st bit = 1 */
89 #define BIT1_16 0x0002 /* 2nd bit = 2 */
90 #define BIT2_16 0x0004 /* 3rd bit = 4 */
91 #define BIT3_16 0x0008 /* 4th bit = 8 */
92 #define BIT4_16 0x0010 /* 5th bit = 16 */
93 #define BIT5_16 0x0020 /* 6th bit = 32 */
94 #define BIT6_16 0x0040 /* 7th bit = 64 */
95 #define BIT7_16 0x0080 /* 8th bit = 128 */
97 #define BIT8_16 0x0100 /* 9th bit = 256 */
98 #define BIT9_16 0x0200 /* 10th bit = 512 */
99 #define BIT10_16 0x0400 /* 11th bit = 1024 */
100 #define BIT11_16 0x0800 /* 12th bit = 2048 */
101 #define BIT12_16 0x1000 /* 13th bit = 4096 */
102 #define BIT13_16 0x2000 /* 14th bit = 8192 */
103 #define BIT14_16 0x4000 /* 15th bit = 16384 */
104 #define BIT15_16 0x8000 /* 16th bit = 32768 */
106 /* Individual bits NOTTED : http://supp.iar.com/Support/?note=12582&from=search+result */
107 #define NBIT0 0xFE /* 1st bit = 1 */
108 #define NBIT1 0xFD /* 2nd bit = 2 */
109 #define NBIT2 0xFB /* 3rd bit = 4 */
110 #define NBIT3 0xF7 /* 4th bit = 8 */
111 #define NBIT4 0xEF /* 5th bit = 16 */
112 #define NBIT5 0xDF /* 6th bit = 32 */
113 #define NBIT6 0xBF /* 7th bit = 64 */
114 #define NBIT7 0x7F /* 8th bit = 128 */
116 #define NBIT0_16 0xFFFE /* 1st bit = 1 */
117 #define NBIT1_16 0xFFFD /* 2nd bit = 2 */
118 #define NBIT2_16 0xFFFB /* 3rd bit = 4 */
119 #define NBIT3_16 0xFFF7 /* 4th bit = 8 */
120 #define NBIT4_16 0xFFEF /* 5th bit = 16 */
121 #define NBIT5_16 0xFFDF /* 6th bit = 32 */
122 #define NBIT6_16 0xFFBF /* 7th bit = 64 */
123 #define NBIT7_16 0xFF7F /* 8th bit = 128 */
125 #define NBIT8_16 0xFEFF /* 9th bit = 256 */
126 #define NBIT9_16 0xFDFF /* 10th bit = 512 */
127 #define NBIT10_16 0xFBFF /* 11th bit = 1024 */
128 #define NBIT11_16 0xF7FF /* 12th bit = 2048 */
129 #define NBIT12_16 0xEFFF /* 13th bit = 4096 */
130 #define NBIT13_16 0xDFFF /* 14th bit = 8192 */
131 #define NBIT14_16 0xBFFF /* 15th bit = 16384 */
132 #define NBIT15_16 0x7FFF /* 16th bit = 32768 */
136 /* let us know if we are being untidy with headers */
137 #warning "Header file GLOBALDEFINES_H seen before, sort it out!"
138 /* end of the wrapper ifdef from the very top */