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_CC13X2X7)
105     #define DeviceFamily_ID             DeviceFamily_ID_CC13X2
106     #define DeviceFamily_DIRECTORY      cc13x2x7_cc26x2x7
107     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X2_CC26X2
108 
109 #elif defined(DeviceFamily_CC26X0)
110     #define DeviceFamily_ID             DeviceFamily_ID_CC26X0
111     #define DeviceFamily_DIRECTORY      cc26x0
112     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X0_CC26X0
113 
114 #elif defined(DeviceFamily_CC26X0R2)
115     #define DeviceFamily_ID             DeviceFamily_ID_CC26X0R2
116     #define DeviceFamily_DIRECTORY      cc26x0r2
117     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X0_CC26X0
118 
119 #elif defined(DeviceFamily_CC26X2)
120     #define DeviceFamily_ID             DeviceFamily_ID_CC26X2
121     #define DeviceFamily_DIRECTORY      cc13x2_cc26x2
122     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X2_CC26X2
123 
124 #elif defined(DeviceFamily_CC26X2X7)
125     #define DeviceFamily_ID             DeviceFamily_ID_CC26X2
126     #define DeviceFamily_DIRECTORY      cc13x2x7_cc26x2x7
127     #define DeviceFamily_PARENT         DeviceFamily_PARENT_CC13X2_CC26X2
128 
129 #elif defined(DeviceFamily_CC3200)
130     #define DeviceFamily_ID             DeviceFamily_ID_CC3200
131     #define DeviceFamily_DIRECTORY      cc32xx
132 
133 #elif defined(DeviceFamily_CC3220)
134     #define DeviceFamily_ID             DeviceFamily_ID_CC3220
135     #define DeviceFamily_DIRECTORY      cc32xx
136 
137 #elif defined(DeviceFamily_MSP432P401x) || defined(__MSP432P401R__)
138     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P401x
139     #define DeviceFamily_DIRECTORY      msp432p4xx
140     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P401R
141     #if !defined(__MSP432P401R__)
142         #define __MSP432P401R__
143     #endif
144 
145 #elif defined(DeviceFamily_MSP432P4x1xI)
146     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P4x1xI
147     #define DeviceFamily_DIRECTORY      msp432p4xx
148     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P4111
149     #if !defined(__MSP432P4111__)
150         #define __MSP432P4111__
151     #endif
152 
153 #elif defined(DeviceFamily_MSP432P4x1xT)
154     #define DeviceFamily_ID             DeviceFamily_ID_MSP432P4x1xT
155     #define DeviceFamily_DIRECTORY      msp432p4xx
156     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432P4111
157     #if !defined(__MSP432P4111__)
158         #define __MSP432P4111__
159     #endif
160 
161 #elif defined(DeviceFamily_MSP432E401Y)
162     #define DeviceFamily_ID             DeviceFamily_ID_MSP432E401Y
163     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432E4X1Y
164     #define DeviceFamily_DIRECTORY      msp432e4
165     #if !defined(__MSP432E401Y__)
166         #define __MSP432E401Y__
167     #endif
168 
169 #elif defined(DeviceFamily_MSP432E411Y)
170     #define DeviceFamily_ID             DeviceFamily_ID_MSP432E411Y
171     #define DeviceFamily_PARENT         DeviceFamily_PARENT_MSP432E4X1Y
172     #define DeviceFamily_DIRECTORY      msp432e4
173     #if !defined(__MSP432E411Y__)
174         #define __MSP432E411Y__
175     #endif
176 #elif defined(DeviceFamily_MTL)
177     #define DeviceFamily_ID             DeviceFamily_ID_MTL
178     #define DeviceFamily_DIRECTORY      mtxx
179     #if !defined(__MTL__)
180         #define __MTL__
181     #endif
182 
183     #if !defined(__CPUSS0__) && !defined(__CPUSS1__)
184         #error "CPU not selected. You must define '__CPUSS0__' or '__CPUSS1__' when building an MTXX image!"
185     #endif
186 
187 #else
188     #error "DeviceFamily_XYZ undefined. You must define a DeviceFamily_XYZ!"
189 #endif
190 
191 /* Ensure that only one DeviceFamily was specified */
192 #if (defined(DeviceFamily_CC13X0) + defined(DeviceFamily_CC13X2)        \
193     + defined(DeviceFamily_CC26X0) + defined(DeviceFamily_CC26X0R2)     \
194     + defined(DeviceFamily_CC26X2)                                      \
195     + defined(DeviceFamily_CC13X2X7) + defined(DeviceFamily_CC26X2X7)   \
196     + defined(DeviceFamily_CC3200) + defined(DeviceFamily_CC3220)       \
197     + defined(DeviceFamily_MSP432P401x) + defined(DeviceFamily_MSP432P4x1xI) \
198     + defined(DeviceFamily_MSP432P4x1xT) + defined(DeviceFamily_MSP432E401Y) \
199     + defined(DeviceFamily_MSP432E411Y)                                      \
200     + defined(DeviceFamily_MTL)                                              \
201     ) > 1
202     #error More then one DeviceFamily has been defined!
203 #endif
204 
205 /*!
206  *  @brief  Macro to include correct driverlib path.
207  *
208  *  @pre    DeviceFamily_XYZ which sets DeviceFamily_DIRECTORY must be defined
209  *          first.
210  *
211  *  @param  x   A token containing the path of the file to include based on
212  *              the root device folder. The preceding forward slash must be
213  *              omitted. For example:
214  *                  - #include DeviceFamily_constructPath(inc/hw_memmap.h)
215  *                  - #include DeviceFamily_constructPath(driverlib/ssi.h)
216  *
217  *  @return Returns an include path.
218  *
219  */
220 #define DeviceFamily_constructPath(x) <ti/devices/DeviceFamily_DIRECTORY/x>
221 
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif /* ti_devices_DeviceFamily__include */
227