|
| 1 | +/* |
| 2 | + * Copyright (c) 2017-2020, 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 | +/* clang-format off */ |
| 54 | + |
| 55 | +/* |
| 56 | + * DeviceFamily_ID_XYZ values. |
| 57 | + * |
| 58 | + * DeviceFamily_ID may be used in the preprocessor for conditional compilation. |
| 59 | + * DeviceFamily_ID is set to one of these values based on the top level |
| 60 | + * DeviceFamily_XYZ define. |
| 61 | + */ |
| 62 | +#define DeviceFamily_ID_MSPM0L130X 1 |
| 63 | +#define DeviceFamily_ID_MSPM0L134X 2 |
| 64 | +#define DeviceFamily_ID_MSPM0L110X 3 |
| 65 | +#define DeviceFamily_ID_MSPM0G110X 4 |
| 66 | +#define DeviceFamily_ID_MSPM0G150X 5 |
| 67 | +#define DeviceFamily_ID_MSPM0G310X 6 |
| 68 | +#define DeviceFamily_ID_MSPM0G350X 7 |
| 69 | +#define DeviceFamily_ID_MSPM0C110X 8 |
| 70 | +#define DeviceFamily_ID_MSPS003FX 9 |
| 71 | +#define DeviceFamily_ID_MSPM0L122X 10 |
| 72 | +#define DeviceFamily_ID_MSPM0L222X 11 |
| 73 | +#define DeviceFamily_ID_MSPM0G151X 12 |
| 74 | +#define DeviceFamily_ID_MSPM0G351X 13 |
| 75 | +#define DeviceFamily_ID_MSPM0L111X 14 |
| 76 | +#define DeviceFamily_ID_MSPM0H321X 15 |
| 77 | + |
| 78 | +/* |
| 79 | + * DeviceFamily_PARENT_XYZ values. |
| 80 | + * |
| 81 | + * DeviceFamily_PARENT may be used in the preprocessor for conditional |
| 82 | + * compilation. DeviceFamily_PARENT is set to one of these values based |
| 83 | + * on the top-level DeviceFamily_XYZ define. |
| 84 | + */ |
| 85 | +#define DeviceFamily_PARENT_MSPM0L11XX_L13XX 1 |
| 86 | +#define DeviceFamily_PARENT_MSPM0G1X0X_G3X0X 2 |
| 87 | +#define DeviceFamily_PARENT_MSPM0C110X 3 |
| 88 | +#define DeviceFamily_PARENT_MSPS003FX 4 |
| 89 | +#define DeviceFamily_PARENT_MSPM0L122X_L222X 5 |
| 90 | +#define DeviceFamily_PARENT_MSPM0GX51X 6 |
| 91 | +#define DeviceFamily_PARENT_MSPM0L111X 7 |
| 92 | +#define DeviceFamily_PARENT_MSPM0H321X 8 |
| 93 | + |
| 94 | +/* |
| 95 | + * Lookup table that sets DeviceFamily_ID, DeviceFamily_DIRECTORY, and |
| 96 | + * DeviceFamily_PARENT based on the DeviceFamily_XYZ define. |
| 97 | + * If DeviceFamily_XYZ is undefined, a compiler error is thrown. If |
| 98 | + * multiple DeviceFamily_XYZ are defined, the first one encountered is used. |
| 99 | + */ |
| 100 | +#if defined(DeviceFamily_MSPM0L130X) || defined(__MSPM0L1306__) \ |
| 101 | + || defined(__MSPM0L1305__) || defined(__MSPM0L1304__) \ |
| 102 | + || defined(__MSPM0L1303__) |
| 103 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L130X |
| 104 | + #define DeviceFamily_DIRECTORY msp |
| 105 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L11XX_L13XX |
| 106 | + |
| 107 | +#elif defined(DeviceFamily_MSPM0L134X) || defined(__MSPM0L1346__) \ |
| 108 | + || defined(__MSPM0L1345__) || defined(__MSPM0L1344__) \ |
| 109 | + || defined(__MSPM0L1343__) |
| 110 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L134X |
| 111 | + #define DeviceFamily_DIRECTORY msp |
| 112 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L11XX_L13XX |
| 113 | + |
| 114 | +#elif defined(DeviceFamily_MSPM0L110X) || defined(__MSPM0L1106__) \ |
| 115 | + || defined(__MSPM0L1105__) |
| 116 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L110X |
| 117 | + #define DeviceFamily_DIRECTORY msp |
| 118 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L11XX_L13XX |
| 119 | + |
| 120 | +#elif defined(DeviceFamily_MSPM0G110X) || defined(__MSPM0G1107__) \ |
| 121 | + || defined(__MSPM0G1106__) || defined(__MSPM0G1105__) |
| 122 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G110X |
| 123 | + #define DeviceFamily_DIRECTORY msp |
| 124 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0G1X0X_G3X0X |
| 125 | + |
| 126 | +#elif defined(DeviceFamily_MSPM0G150X) || defined(__MSPM0G1507__) \ |
| 127 | + || defined(__MSPM0G1506__) || defined(__MSPM0G1505__) |
| 128 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G150X |
| 129 | + #define DeviceFamily_DIRECTORY msp |
| 130 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0G1X0X_G3X0X |
| 131 | + |
| 132 | +#elif defined(DeviceFamily_MSPM0G310X) || defined(__MSPM0G3107__) \ |
| 133 | + || defined(__MSPM0G3106__) || defined(__MSPM0G3105__) |
| 134 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G310X |
| 135 | + #define DeviceFamily_DIRECTORY msp |
| 136 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0G1X0X_G3X0X |
| 137 | + |
| 138 | +#elif defined(DeviceFamily_MSPM0G350X) || defined(__MSPM0G3507__) \ |
| 139 | + || defined(__MSPM0G3506__) || defined(__MSPM0G3505__) |
| 140 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G350X |
| 141 | + #define DeviceFamily_DIRECTORY msp |
| 142 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0G1X0X_G3X0X |
| 143 | +#elif defined(DeviceFamily_MSPM0C110X) || defined(__MSPM0C1104__) \ |
| 144 | + || defined(__MSPM0C1103__) |
| 145 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0C110X |
| 146 | + #define DeviceFamily_DIRECTORY msp |
| 147 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0C110X |
| 148 | + |
| 149 | +#elif defined(DeviceFamily_MSPS003FX) || defined(__MSPS003F4__) \ |
| 150 | + || defined(__MSPS003F3__) |
| 151 | + #define DeviceFamily_ID DeviceFamily_ID_MSPS003FX |
| 152 | + #define DeviceFamily_DIRECTORY msp |
| 153 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPS003FX |
| 154 | + |
| 155 | +#elif defined(DeviceFamily_MSPM0L122X) || defined(__MSPM0L1228__) \ |
| 156 | + || defined(__MSPM0L1227__) || defined(__MSPM0L1226__) |
| 157 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L122X |
| 158 | + #define DeviceFamily_DIRECTORY msp |
| 159 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L122X_L222X |
| 160 | + |
| 161 | +#elif defined(DeviceFamily_MSPM0L222X) || defined(__MSPM0L2228__) \ |
| 162 | + || defined(__MSPM0L2227__) || defined(__MSPM0L2226__) |
| 163 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L222X |
| 164 | + #define DeviceFamily_DIRECTORY msp |
| 165 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L122X_L222X |
| 166 | + |
| 167 | +#elif defined(DeviceFamily_MSPM0G151X) || defined(__MSPM0G1518__) \ |
| 168 | + || defined(__MSPM0G1519__) |
| 169 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G151X |
| 170 | + #define DeviceFamily_DIRECTORY msp |
| 171 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0GX51X |
| 172 | + |
| 173 | +#elif defined(DeviceFamily_MSPM0G351X) || defined(__MSPM0G3518__) \ |
| 174 | + || defined(__MSPM0G3519__) |
| 175 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0G351X |
| 176 | + #define DeviceFamily_DIRECTORY msp |
| 177 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0GX51X |
| 178 | + |
| 179 | +#elif defined(DeviceFamily_MSPM0L111X) || defined(__MSPM0L1117__) \ |
| 180 | + || defined(__MSPM0L1116__) |
| 181 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0L111X |
| 182 | + #define DeviceFamily_DIRECTORY msp |
| 183 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0L111X |
| 184 | + |
| 185 | +#elif defined(DeviceFamily_MSPM0H321X) || defined(__MSPM0H3216__) \ |
| 186 | + || defined(__MSPM0H3215__) |
| 187 | + #define DeviceFamily_ID DeviceFamily_ID_MSPM0H321X |
| 188 | + #define DeviceFamily_DIRECTORY msp |
| 189 | + #define DeviceFamily_PARENT DeviceFamily_PARENT_MSPM0H321X |
| 190 | + |
| 191 | + |
| 192 | +#else |
| 193 | + #error "DeviceFamily_XYZ undefined. You must define a DeviceFamily_XYZ!" |
| 194 | +#endif |
| 195 | + |
| 196 | +/* Ensure that only one DeviceFamily was specified */ |
| 197 | +#if (defined(DeviceFamily_MSPM0L130X) \ |
| 198 | + + defined(DeviceFamily_MSPM0L134X) \ |
| 199 | + + defined(DeviceFamily_MSPM0L110X) \ |
| 200 | + + defined(DeviceFamily_MSPM0G110X) \ |
| 201 | + + defined(DeviceFamily_MSPM0G150X) \ |
| 202 | + + defined(DeviceFamily_MSPM0G310X) \ |
| 203 | + + defined(DeviceFamily_MSPM0G350X) \ |
| 204 | + + defined(DeviceFamily_MSPM0C110X) \ |
| 205 | + + defined(DeviceFamily_MSPS003FX) \ |
| 206 | + + defined(DeviceFamily_MSPM0L122X) \ |
| 207 | + + defined(DeviceFamily_MSPM0L222X) \ |
| 208 | + + defined(DeviceFamily_MSPM0G151X) \ |
| 209 | + + defined(DeviceFamily_MSPM0G351X) \ |
| 210 | + + defined(DeviceFamily_MSPM0L111X) \ |
| 211 | + + defined(DeviceFamily_MSPM0H321X) \ |
| 212 | + ) > 1 |
| 213 | + #error More then one DeviceFamily has been defined! |
| 214 | +#endif |
| 215 | + |
| 216 | +/*! |
| 217 | + * @brief Macro to include correct driverlib path. |
| 218 | + * |
| 219 | + * @pre DeviceFamily_XYZ which sets DeviceFamily_DIRECTORY must be defined |
| 220 | + * first. |
| 221 | + * |
| 222 | + * @param x A token containing the path of the file to include based on |
| 223 | + * the root device folder. The preceding forward slash must be |
| 224 | + * omitted. For example: |
| 225 | + * - #include DeviceFamily_constructPath(inc/hw_memmap.h) |
| 226 | + * - #include DeviceFamily_constructPath(driverlib/ssi.h) |
| 227 | + * |
| 228 | + * @return Returns an include path. |
| 229 | + * |
| 230 | + */ |
| 231 | +#define DeviceFamily_constructPath(x) <ti/devices/DeviceFamily_DIRECTORY/x> |
| 232 | + |
| 233 | + /* clang-format on */ |
| 234 | + |
| 235 | +#ifdef __cplusplus |
| 236 | + } |
| 237 | +#endif |
| 238 | + |
| 239 | +#endif /* ti_devices_DeviceFamily__include */ |
0 commit comments