4 * This file is part of BeRTOS.
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.
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.
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
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.
29 * Copyright 2010 Develer S.r.l. (http://www.develer.com/)
33 * \brief LM3S1968 generic hardware macros.
39 #include <cfg/compiler.h>
42 * Macros for hardware access, both direct and via the bit-band region.
45 #define HWREG(x) (*((reg32_t *)(x)))
46 #define HWREGH(x) (*((reg16_t *)(x)))
47 #define HWREGB(x) (*((reg8_t *)(x)))
49 #define HWREGBITW(x, b) \
50 HWREG(((reg32_t)(x) & 0xF0000000) | 0x02000000 | \
51 (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
52 #define HWREGBITH(x, b) \
53 HWREGH(((reg32_t)(x) & 0xF0000000) | 0x02000000 | \
54 (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
55 #define HWREGBITB(x, b) \
56 HWREGB(((reg32_t)(x) & 0xF0000000) | 0x02000000 | \
57 (((reg32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
61 * Helper Macros for determining the particular hardware revision.
64 #ifndef CLASS_IS_SANDSTORM
65 #define CLASS_IS_SANDSTORM \
66 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_VER_M) == SYSCTL_DID0_VER_0) || \
67 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
68 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_SANDSTORM)))
72 #define CLASS_IS_FURY \
73 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
74 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_FURY))
77 #ifndef CLASS_IS_DUSTDEVIL
78 #define CLASS_IS_DUSTDEVIL \
79 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
80 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_DUSTDEVIL))
83 #ifndef CLASS_IS_TEMPEST
84 #define CLASS_IS_TEMPEST \
85 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
86 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_TEMPEST))
89 #ifndef REVISION_IS_A0
90 #define REVISION_IS_A0 \
91 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
92 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_0))
95 #ifndef REVISION_IS_A1
96 #define REVISION_IS_A1 \
97 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
98 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_0))
101 #ifndef REVISION_IS_A2
102 #define REVISION_IS_A2 \
103 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
104 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_2))
107 #ifndef REVISION_IS_B0
108 #define REVISION_IS_B0 \
109 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
110 (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_0))
113 #ifndef REVISION_IS_B1
114 #define REVISION_IS_B1 \
115 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
116 (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_1))
119 #ifndef REVISION_IS_C0
120 #define REVISION_IS_C0 \
121 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
122 (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_0))
125 #ifndef REVISION_IS_C1
126 #define REVISION_IS_C1 \
127 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
128 (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_1))
131 #ifndef REVISION_IS_C2
132 #define REVISION_IS_C2 \
133 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
134 (SYSCTL_DID0_MAJ_REVC | SYSCTL_DID0_MIN_2))
138 #endif /* LM3S_TYPES_H */