mikroSDK Reference Manual
hw_types.h
1//*****************************************************************************
2//
3// hw_types.h - Common types and macros.
4//
5// Copyright (c) 2005-2020 Texas Instruments Incorporated. All rights reserved.
6// Software License Agreement
7//
8// Redistribution and use in source and binary forms, with or without
9// modification, are permitted provided that the following conditions
10// are met:
11//
12// Redistributions of source code must retain the above copyright
13// notice, this list of conditions and the following disclaimer.
14//
15// Redistributions in binary form must reproduce the above copyright
16// notice, this list of conditions and the following disclaimer in the
17// documentation and/or other materials provided with the
18// distribution.
19//
20// Neither the name of Texas Instruments Incorporated nor the names of
21// its contributors may be used to endorse or promote products derived
22// from this software without specific prior written permission.
23//
24// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35//
36// This is part of revision 2.2.0.295 of the Tiva Firmware Development Package.
37//
38//*****************************************************************************
39
40#ifndef __HW_TYPES_H__
41#define __HW_TYPES_H__
42
43//*****************************************************************************
44//
45// Macros for hardware access, both direct and via the bit-band region.
46//
47//*****************************************************************************
48#define HWREG(x) \
49 (*((volatile uint32_t *)(x)))
50#define HWREGH(x) \
51 (*((volatile uint16_t *)(x)))
52#define HWREGB(x) \
53 (*((volatile uint8_t *)(x)))
54#define HWREGBITW(x, b) \
55 HWREG(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
56 (((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
57#define HWREGBITH(x, b) \
58 HWREGH(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
59 (((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
60#define HWREGBITB(x, b) \
61 HWREGB(((uint32_t)(x) & 0xF0000000) | 0x02000000 | \
62 (((uint32_t)(x) & 0x000FFFFF) << 5) | ((b) << 2))
63
64//*****************************************************************************
65//
66// Helper Macros for determining silicon revisions, etc.
67//
68// These macros will be used by Driverlib at "run-time" to create necessary
69// conditional code blocks that will allow a single version of the Driverlib
70// "binary" code to support multiple(all) Tiva silicon revisions.
71//
72// It is expected that these macros will be used inside of a standard 'C'
73// conditional block of code, e.g.
74//
75// if(CLASS_IS_TM4C123)
76// {
77// do some TM4C123-class specific code here.
78// }
79//
80// By default, these macros will be defined as run-time checks of the
81// appropriate register(s) to allow creation of run-time conditional code
82// blocks for a common DriverLib across the entire Tiva family.
83//
84// However, if code-space optimization is required, these macros can be "hard-
85// coded" for a specific version of Tiva silicon. Many compilers will then
86// detect the "hard-coded" conditionals, and appropriately optimize the code
87// blocks, eliminating any "unreachable" code. This would result in a smaller
88// Driverlib, thus producing a smaller final application size, but at the cost
89// of limiting the Driverlib binary to a specific Tiva silicon revision.
90//
91//*****************************************************************************
92#ifndef CLASS_IS_TM4C123
93#define CLASS_IS_TM4C123 \
94 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
95 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_TM4C123))
96#endif
97
98#ifndef CLASS_IS_TM4C129
99#define CLASS_IS_TM4C129 \
100 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_VER_M | SYSCTL_DID0_CLASS_M)) == \
101 (SYSCTL_DID0_VER_1 | SYSCTL_DID0_CLASS_TM4C129))
102#endif
103
104#ifndef REVISION_IS_A0
105#define REVISION_IS_A0 \
106 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
107 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_0))
108#endif
109
110#ifndef REVISION_IS_A1
111#define REVISION_IS_A1 \
112 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
113 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_1))
114#endif
115
116#ifndef REVISION_IS_A2
117#define REVISION_IS_A2 \
118 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
119 (SYSCTL_DID0_MAJ_REVA | SYSCTL_DID0_MIN_2))
120#endif
121
122#ifndef REVISION_IS_B0
123#define REVISION_IS_B0 \
124 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
125 (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_0))
126#endif
127
128#ifndef REVISION_IS_B1
129#define REVISION_IS_B1 \
130 ((HWREG(SYSCTL_DID0) & (SYSCTL_DID0_MAJ_M | SYSCTL_DID0_MIN_M)) == \
131 (SYSCTL_DID0_MAJ_REVB | SYSCTL_DID0_MIN_1))
132#endif
133
134//*****************************************************************************
135//
136// For TivaWare 2.1, we removed all references to Tiva IC codenames from the
137// source. To ensure that existing customer code doesn't break as a result
138// of this change, make sure that the old definitions are still available at
139// least for the time being.
140//
141//*****************************************************************************
142#ifndef DEPRECATED
143#define CLASS_IS_BLIZZARD CLASS_IS_TM4C123
144#define CLASS_IS_SNOWFLAKE CLASS_IS_TM4C123
145#endif
146
147#endif // __HW_TYPES_H__