1 //*****************************************************************************
\r
3 // hw_types.h - Common types and macros.
\r
5 // Copyright (c) 2005-2007 Luminary Micro, Inc. All rights reserved.
\r
7 // Software License Agreement
\r
9 // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
\r
10 // exclusively on LMI's microcontroller products.
\r
12 // The software is owned by LMI and/or its suppliers, and is protected under
\r
13 // applicable copyright laws. All rights are reserved. Any use in violation
\r
14 // of the foregoing restrictions may subject the user to criminal sanctions
\r
15 // under applicable laws, as well as to civil liability for the breach of the
\r
16 // terms and conditions of this license.
\r
18 // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
\r
19 // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
\r
20 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
\r
21 // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
\r
22 // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
\r
24 // This is part of revision 1582 of the Stellaris Peripheral Driver Library.
\r
26 //*****************************************************************************
\r
28 #ifndef __HW_TYPES_H__
\r
29 #define __HW_TYPES_H__
\r
31 //*****************************************************************************
\r
33 // Define a boolean type, and values for true and false.
\r
35 //*****************************************************************************
\r
36 typedef unsigned char tBoolean;
\r
46 //*****************************************************************************
\r
48 // Macros for hardware access, both direct and via the bit-band region.
\r
50 //*****************************************************************************
\r
52 (*((volatile unsigned long *)(x)))
\r
54 (*((volatile unsigned short *)(x)))
\r
56 (*((volatile unsigned char *)(x)))
\r
57 #define HWREGBITW(x, b) \
\r
58 HWREG(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
\r
59 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
\r
60 #define HWREGBITH(x, b) \
\r
61 HWREGH(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
\r
62 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
\r
63 #define HWREGBITB(x, b) \
\r
64 HWREGB(((unsigned long)(x) & 0xF0000000) | 0x02000000 | \
\r
65 (((unsigned long)(x) & 0x000FFFFF) << 5) | ((b) << 2))
\r
67 //*****************************************************************************
\r
69 // Helper Macros for determining silicon revisions, etc.
\r
71 // These macros will be used by Driverlib at "run-time" to create necessary
\r
72 // conditional code blocks that will allow a single version of the Driverlib
\r
73 // "binary" code to support multiple(all) Stellaris silicon revisions.
\r
75 // It is expected that these macros will be used inside of a standard 'C'
\r
76 // conditional block of code, e.g.
\r
78 // if(DEVICE_IS_SANDSTORM())
\r
80 // do some Sandstorm specific code here.
\r
83 // By default, these macros will be defined as run-time checks of the
\r
84 // appropriate register(s) to allow creation of run-time conditional code
\r
85 // blocks for a common DriverLib across the entire Stellaris family.
\r
87 // However, if code-space optimization is required, these macros can be "hard-
\r
88 // coded" for a specific version of Stellaris silicon. Many compilers will
\r
89 // then detect the "hard-coded" conditionals, and appropriately optimize the
\r
90 // code blocks, eliminating any "unreachable" code. This would result in
\r
91 // a smaller Driverlib, thus producing a smaller final application size, but
\r
92 // at the cost of limiting the Driverlib binary to a specific Stellaris
\r
93 // silicon revision.
\r
95 //*****************************************************************************
\r
96 #ifndef DEVICE_IS_SANDSTORM
\r
97 #define DEVICE_IS_SANDSTORM \
\r
98 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_VER_MASK) == SYSCTL_DID0_VER_0) || \
\r
99 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_VER_MASK) == SYSCTL_DID0_VER_1) && \
\r
100 ((HWREG(SYSCTL_DID0) & SYSCTL_DID0_CLASS_MASK) == \
\r
101 SYSCTL_DID0_CLASS_SANDSTORM)))
\r
104 #ifndef DEVICE_IS_FURY
\r
105 #define DEVICE_IS_FURY \
\r
106 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_VER_MASK) == SYSCTL_DID0_VER_1) && \
\r
107 ((HWREG(SYSCTL_DID0) & SYSCTL_DID0_CLASS_MASK) == \
\r
108 SYSCTL_DID0_CLASS_FURY))
\r
111 #ifndef DEVICE_IS_REVA2
\r
112 #define DEVICE_IS_REVA2 \
\r
113 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_MASK) == SYSCTL_DID0_MAJ_A) && \
\r
114 ((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MIN_MASK) == SYSCTL_DID0_MIN_2))
\r
117 #ifndef DEVICE_IS_REVC1
\r
118 #define DEVICE_IS_REVC1 \
\r
119 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_MASK) == SYSCTL_DID0_MAJ_C) && \
\r
120 ((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MIN_MASK) == SYSCTL_DID0_MIN_1))
\r
123 #ifndef DEVICE_IS_REVC2
\r
124 #define DEVICE_IS_REVC2 \
\r
125 (((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MAJ_MASK) == SYSCTL_DID0_MAJ_C) && \
\r
126 ((HWREG(SYSCTL_DID0) & SYSCTL_DID0_MIN_MASK) == SYSCTL_DID0_MIN_2))
\r
129 #endif // __HW_TYPES_H__
\r