1 /*
2  * Copyright (c) 2017-2019, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /** ============================================================================
33  *  @file       DeviceFamily.h
34  *
35  *  @brief      Infrastructure to select correct driverlib path and identify devices
36  *
37  *  This module enables the selection of the correct driverlib path for the current
38  *  device. It also facilitates the use of per-device conditional compilation
39  *  to enable minor variations in drivers between devices.
40  *
41  *  In order to use this functionality, DeviceFamily_XYZ must be defined as one of
42  *  the supported values. The DeviceFamily_ID and DeviceFamily_DIRECTORY defines
43  *  are set based on DeviceFamily_XYZ.
44  */
45 
46 #ifndef ti_devices_DeviceFamily__include
47 #define ti_devices_DeviceFamily__include
48 
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 /*
54  * DeviceFamily_ID_XYZ values.
55  *
56  * DeviceFamily_ID may be used in the preprocessor for conditional compilation.
57  * DeviceFamily_ID is set to one of these values based on the top level
58  * DeviceFamily_XYZ define.
59  */
60 #define DeviceFamily_ID_CC13X0                 1
61 #define DeviceFamily_ID_CC26X0                 2
62 #define DeviceFamily_ID_CC26X0R2               3
63 #define DeviceFamily_ID_CC13X2                 4
64 #define DeviceFamily_ID_CC26X2                 5
65 #define DeviceFamily_ID_CC3200                 8
66 #define DeviceFamily_ID_CC3220                 9
67 #define DeviceFamily_ID_MSP432P401x            10
68 #define DeviceFamily_ID_MSP432P4x1xI           11
69 #define DeviceFamily_ID_MSP432P4x1xT           12
70 #define DeviceFamily_ID_MSP432E401Y            13
71 #define DeviceFamily_ID_MSP432E411Y            14
72 #define DeviceFamily_ID_MTL                    15
73 
74 /*
75  * DeviceFamily_PARENT_XYZ values.
76  *
77  * DeviceFamily_PARENT may be used in the preprocessor for conditional
78  * compilation. DeviceFamily_PARENT is set to one of these values based
79  * on the top-level DeviceFamily_XYZ define.
80  */
81 #define DeviceFamily_PARENT_CC13X0_CC26X0      1
82 #define DeviceFamily_PARENT_CC13X2_CC26X2      2
83 #define DeviceFamily_PARENT_MSP432P401R        3
84 #define DeviceFamily_PARENT_MSP432P4111        4
85 #define DeviceFamily_PARENT_MTL                5
86 #define DeviceFamily_PARENT_MSP432E4X1Y        6
87 
88 /*
89  * Lookup table that sets DeviceFamily_ID, DeviceFamily_DIRECTORY, and
90  * DeviceFamily_PARENT based on the DeviceFamily_XYZ define.
91  * If DeviceFamily_XYZ is undefined, a compiler error is thrown. If
92  * multiple DeviceFamily_XYZ are defined, the first one encountered is used.
93  */
94 #if defined(DeviceFamily_CC13X0)
95     #define DeviceFamily_ID             DeviceFamily_ID_CC13X0
96     #define DeviceFamily_DIRECTORY      cc13x0
97     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X0_CC26X0
98 
99 #elif defined(DeviceFamily_CC13X2)
100     #define DeviceFamily_ID             DeviceFamily_ID_CC13X2
101     #define DeviceFamily_DIRECTORY      cc13x2_cc26x2
102     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X2_CC26X2
103 
104 #elif defined(DeviceFamily_CC26X0)
105     #define DeviceFamily_ID             DeviceFamily_ID_CC26X0
106     #define DeviceFamily_DIRECTORY      cc26x0
107     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X0_CC26X0
108 
109 #elif defined(DeviceFamily_CC26X0R2)
110     #define DeviceFamily_ID             DeviceFamily_ID_CC26X0R2
111     #define DeviceFamily_DIRECTORY      cc26x0r2
112     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X0_CC26X0
113 
114 #elif defined(DeviceFamily_CC26X2)
115     #define DeviceFamily_ID             DeviceFamily_ID_CC26X2
116     #define DeviceFamily_DIRECTORY      cc13x2_cc26x2
117     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X2_CC26X2
118 
119 #elif defined(DeviceFamily_CC3200)
120     #define DeviceFamily_ID             DeviceFamily_ID_CC3200
121     #define DeviceFamily_DIRECTORY      cc32xx
122 
123 #elif defined(DeviceFamily_CC3220)
124     #define DeviceFamily_ID             DeviceFamily_ID_CC3220
125     #define DeviceFamily_DIRECTORY      cc32xx
126 
127 #elif defined(DeviceFamily_MSP432P401x) || defined(__MSP432P401R__)
128     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P401x
129     #define DeviceFamily_DIRECTORY      msp432p4xx
130     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P401R
131     #if !defined(__MSP432P401R__)
132         #define __MSP432P401R__
133     #endif
134 
135 #elif defined(DeviceFamily_MSP432P4x1xI)
136     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P4x1xI
137     #define DeviceFamily_DIRECTORY      msp432p4xx
138     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P4111
139     #if !defined(__MSP432P4111__)
140         #define __MSP432P4111__
141     #endif
142 
143 #elif defined(DeviceFamily_MSP432P4x1xT)
144     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P4x1xT
145     #define DeviceFamily_DIRECTORY      msp432p4xx
146     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P4111
147     #if !defined(__MSP432P4111__)
148         #define __MSP432P4111__
149     #endif
150 
151 #elif defined(DeviceFamily_MSP432E401Y)
152     #define DeviceFamily_ID             DeviceFamily_ID_MSP432E401Y
153     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432E4X1Y
154     #define DeviceFamily_DIRECTORY      msp432e4
155     #if !defined(__MSP432E401Y__)
156         #define __MSP432E401Y__
157     #endif
158 
159 #elif defined(DeviceFamily_MSP432E411Y)
160     #define DeviceFamily_ID             DeviceFamily_ID_MSP432E411Y
161     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432E4X1Y
162     #define DeviceFamily_DIRECTORY      msp432e4
163     #if !defined(__MSP432E411Y__)
164         #define __MSP432E411Y__
165     #endif
166 #elif defined(DeviceFamily_MTL)
167     #define DeviceFamily_ID             DeviceFamily_ID_MTL
168     #define DeviceFamily_DIRECTORY      mtxx
169     #if !defined(__MTL__)
170         #define __MTL__
171     #endif
172 
173     #if !defined(__CPUSS0__) && !defined(__CPUSS1__)
174         #error "CPU not selected. You must define '__CPUSS0__' or '__CPUSS1__' when building an MTXX image!"
175     #endif
176 
177 #else
178     #error "DeviceFamily_XYZ undefined. You must define a DeviceFamily_XYZ!"
179 #endif
180 
181 /* Ensure that only one DeviceFamily was specified */
182 #if (defined(DeviceFamily_CC13X0) + defined(DeviceFamily_CC13X2)        \
183     + defined(DeviceFamily_CC26X0) + defined(DeviceFamily_CC26X0R2)     \
184     + defined(DeviceFamily_CC26X2)                                      \
185     + defined(DeviceFamily_CC3200) + defined(DeviceFamily_CC3220)       \
186     + defined(DeviceFamily_MSP432P401x) + defined(DeviceFamily_MSP432P4x1xI) \
187     + defined(DeviceFamily_MSP432P4x1xT) + defined(DeviceFamily_MSP432E401Y) \
188     + defined(DeviceFamily_MSP432E411Y)                                      \
189     + defined(DeviceFamily_MTL)                                              \
190     ) > 1
191     #error More then one DeviceFamily has been defined!
192 #endif
193 
194 /*!
195  *  @brief  Macro to include correct driverlib path.
196  *
197  *  @pre    DeviceFamily_XYZ which sets DeviceFamily_DIRECTORY must be defined
198  *          first.
199  *
200  *  @param  x   A token containing the path of the file to include based on
201  *              the root device folder. The preceding forward slash must be
202  *              omitted. For example:
203  *                  - #include DeviceFamily_constructPath(inc/hw_memmap.h)
204  *                  - #include DeviceFamily_constructPath(driverlib/ssi.h)
205  *
206  *  @return Returns an include path.
207  *
208  */
209 #define DeviceFamily_constructPath(x) <ti/devices/DeviceFamily_DIRECTORY/x>
210 
211 #ifdef __cplusplus
212 }
213 #endif
214 
215 #endif /* ti_devices_DeviceFamily__include */
216