Revamp documentation.
[bertos.git] / cpu_detect.h
1 /*!
2  * \file
3  * <!--
4  * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5  * Copyright 2004 Giovanni Bajo
6  * This file is part of DevLib - See devlib/README for information.
7  * -->
8  *
9  * \brief CPU detection through special preprocessor macros
10  *
11  */
12
13 /*#*
14  *#* $Log$
15  *#* Revision 1.2  2004/08/25 14:12:08  rasky
16  *#* Aggiornato il comment block dei log RCS
17  *#*
18  *#* Revision 1.1  2004/07/30 17:14:49  rasky
19  *#* File sfuggito al commit precedente (nuova gestione unificata del detect della CPU
20  *#*
21  *#* Revision 1.2  2004/07/30 10:31:07  rasky
22  *#* Aggiunto detect per ATmega128
23  *#*
24  *#* Revision 1.1  2004/07/22 16:37:34  rasky
25  *#* Nuovo file cpu_detect.h per il detect della CPU
26  *#* Nuova macro CPU_HEADER per includere l'header cpu-specific di ogni modulo
27  *#* Razionalizzazione dei principali #ifdef per piattaforma con le nuove macro
28  *#* Nuove macro-utility PP_STRINGIZE e PP_CATn
29  *#*
30  *#*/
31
32 #ifndef CPU_DETECT_H
33 #define CPU_DETECT_H
34
35 #if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__)
36         #define CPU_I196                1
37         #define CPU_ID                  i196
38 #else
39         #define CPU_I196                0
40 #endif
41
42 #if defined(__i386__) || defined(_MSC_VER)
43         #define CPU_X86                 1
44         #define CPU_ID                  x86
45 #else
46         #define CPU_X86                 0
47 #endif
48
49 #if defined(__m56800E__) || defined(__m56800__)
50         #define CPU_DSP56K              1
51         #define CPU_ID                  dsp56k
52 #else
53         #define CPU_DSP56K              0
54 #endif
55
56 #if defined (__AVR__)
57         #define CPU_AVR                 1
58         #define CPU_ID                  avr
59
60         #if defined(__AVR_ATmega64__)
61                 #define CPU_AVR_ATMEGA64    1
62         #else
63                 #define CPU_AVR_ATMEGA64    0
64         #endif
65
66         #if defined(__AVR_ATmega103__)
67                 #define CPU_AVR_ATMEGA103   1
68         #else
69                 #define CPU_AVR_ATMEGA103   0
70         #endif
71
72         #if defined(__AVR_ATmega128__)
73                 #define CPU_AVR_ATMEGA128   1
74         #else
75                 #define CPU_AVR_ATMEGA128   0
76         #endif
77
78         #if defined(__AVR_ATmega8__)
79                 #define CPU_AVR_ATMEGA8     1
80         #else
81                 #define CPU_AVR_ATMEGA8     0
82         #endif
83 #else
84         #define CPU_AVR                 0
85         #define CPU_AVR_ATMEGA8         0
86         #define CPU_AVR_ATMEGA64        0
87         #define CPU_AVR_ATMEGA103       0
88         #define CPU_AVR_ATMEGA128       0
89 #endif
90
91
92 // Self-check for the detection: only one CPU must be detected
93 #if CPU_I196 + CPU_X86 + CPU_DSP56K + CPU_AVR == 0
94         #error Unknown CPU
95 #elif !defined(CPU_ID)
96         #error CPU_ID not defined
97 #elif CPU_I196 + CPU_X86 + CPU_DSP56K + CPU_AVR != 1
98         #error Internal CPU configuration error
99 #endif
100
101
102 #endif /* CPU_DETECT_H */