CM3: use a distinct stack for handler-mode and thread-mode.
[bertos.git] / bertos / cpu / cortex-m3 / io / lm3s_types.h
1 /**
2  * \file
3  * <!--
4  * This file is part of BeRTOS.
5  *
6  * Bertos is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  *
20  * As a special exception, you may use this file as part of a free software
21  * library without restriction.  Specifically, if other files instantiate
22  * templates or use macros or inline functions from this file, or you compile
23  * this file and link it with other files to produce an executable, this
24  * file does not by itself cause the resulting executable to be covered by
25  * the GNU General Public License.  This exception does not however
26  * invalidate any other reasons why the executable file might be covered by
27  * the GNU General Public License.
28  *
29  * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
30  *
31  * -->
32  *
33  * \brief LM3S1968 generic hardware macros.
34  */
35
36 #ifndef LM3S_TYPES_H
37 #define LM3S_TYPES_H
38
39 #include <cfg/compiler.h>
40
41 /**
42  * Macros for hardware access, both direct and via the bit-band region.
43  */
44 /*\{*/
45 #define HWREG(x) (*((reg32_t *)(x)))
46 #define HWREGH(x) (*((reg16_t *)(x)))
47 #define HWREGB(x) (*((reg8_t *)(x)))
48 #define HWREGBITW(x, b) \
49         HWREG(((reg32_t)(x) & 0xF0000000) | 0x02000000 |                \
50               (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
51 #define HWREGBITH(x, b) \
52         HWREGH(((reg32_t)(x) & 0xF0000000) | 0x02000000 |               \
53                (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
54 #define HWREGBITB(x, b) \
55         HWREGB(((reg32_t)(x) & 0xF0000000) | 0x02000000 |               \
56                (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
57 /*\}*/
58
59 /**
60  * Helper Macros for determining the particular hardware revision.
61  */
62 /*\{*/
63 #ifndef CLASS_IS_SANDSTORM
64 #define CLASS_IS_SANDSTORM                                                    \
65         (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_VER_M) == SYSCTL_DID0_VER_0) ||   \
66          ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
67           (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_SANDSTORM)))
68 #endif
69
70 #ifndef CLASS_IS_FURY
71 #define CLASS_IS_FURY                                                        \
72         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
73          (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_FURY))
74 #endif
75
76 #ifndef CLASS_IS_DUSTDEVIL
77 #define CLASS_IS_DUSTDEVIL                                                   \
78         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
79          (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_DUSTDEVIL))
80 #endif
81
82 #ifndef CLASS_IS_TEMPEST
83 #define CLASS_IS_TEMPEST                                                     \
84         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
85          (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_TEMPEST))
86 #endif
87
88 #ifndef REVISION_IS_A0
89 #define REVISION_IS_A0                                                     \
90         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
91          (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_0))
92 #endif
93
94 #ifndef REVISION_IS_A1
95 #define REVISION_IS_A1                                                     \
96         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
97          (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_0))
98 #endif
99
100 #ifndef REVISION_IS_A2
101 #define REVISION_IS_A2                                                     \
102         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
103          (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_2))
104 #endif
105
106 #ifndef REVISION_IS_B0
107 #define REVISION_IS_B0                                                     \
108         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
109          (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_0))
110 #endif
111
112 #ifndef REVISION_IS_B1
113 #define REVISION_IS_B1                                                     \
114         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
115          (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_1))
116 #endif
117
118 #ifndef REVISION_IS_C0
119 #define REVISION_IS_C0                                                     \
120         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
121          (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_0))
122 #endif
123
124 #ifndef REVISION_IS_C1
125 #define REVISION_IS_C1                                                     \
126         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
127          (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_1))
128 #endif
129
130 #ifndef REVISION_IS_C2
131 #define REVISION_IS_C2                                                     \
132         ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
133          (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_2))
134 #endif
135 /*\}*/
136
137 #endif /* LM3S_TYPES_H */